author | Jan Vrany <jan.vrany@labware.com> |
Thu, 27 Oct 2022 14:53:59 +0100 | |
branch | jv |
changeset 4735 | 3b11fb3ede98 |
parent 4720 | f34e80b9a88f |
permissions | -rw-r--r-- |
283 | 1 |
" |
2 |
COPYRIGHT (c) 1996 by Claus Gittinger |
|
3 |
All Rights Reserved |
|
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 |
" |
|
1129 | 12 |
"{ Package: 'stx:libcomp' }" |
13 |
||
3626 | 14 |
"{ NameSpace: Smalltalk }" |
15 |
||
3903 | 16 |
Behavior subclass:#Structure |
17 |
instanceVariableNames:'i1 i2 i3 i4 i5 i6 i7 i8 i9 i10 i11 i12 i13 i14 i15 i16 i17 i18 |
|
18 |
i19 i20 i21 i22 i23 i24 i25 i26 i27 i28 i29 i30 i31 i32 i33 i34 |
|
19 |
i35 i36 i37 i38 i39 i40 i41 i42 i43 i44 i45 i46 i47 i48 i49 i50' |
|
4248 | 20 |
classVariableNames:'DummyClass IndexOfFlags IndexOfInstSize IndexOfMethodDictionary |
21 |
OneInstance OtherMethods OtherSelectors ReadAccessMethods |
|
22 |
WriteAccessMethods' |
|
2351 | 23 |
poolDictionaries:'' |
4248 | 24 |
category:'Kernel-Classes' |
282 | 25 |
! |
26 |
||
616 | 27 |
!Structure class methodsFor:'documentation'! |
282 | 28 |
|
283 | 29 |
copyright |
30 |
" |
|
31 |
COPYRIGHT (c) 1996 by Claus Gittinger |
|
32 |
All Rights Reserved |
|
33 |
||
34 |
This software is furnished under a license and may be used |
|
35 |
only in accordance with the terms of that license and with the |
|
36 |
inclusion of the above copyright notice. This software may not |
|
37 |
be provided or otherwise made available to, or used by, any |
|
38 |
other person. No title to or ownership of the software is |
|
39 |
hereby transferred. |
|
40 |
" |
|
41 |
! |
|
42 |
||
282 | 43 |
documentation |
44 |
" |
|
616 | 45 |
This is an experimental class, stressing the metaObject capabilities. |
282 | 46 |
|
616 | 47 |
Structures are objects which are class-less, |
48 |
only holding some values, and provide a protocol to access |
|
49 |
those fields. In addition, they support the array-protocol, |
|
50 |
so they can be used as backward compatible replacements in |
|
282 | 51 |
places where arrays were returned. |
616 | 52 |
(However, we recommend using private classes, since they are easier |
1037 | 53 |
to understand and maintain). |
616 | 54 |
|
55 |
For example, some structure object can be create with: |
|
56 |
^ Structure with:#foo->'someFooValue' with:#bar->'someBarValue' |
|
282 | 57 |
|
58 |
and access these values either as: |
|
616 | 59 |
retVal at:1 -> returns the foo instvar value |
60 |
retVal at:2 -> returns the bar instvar value |
|
282 | 61 |
or (much more convenient and readable) as: |
616 | 62 |
retVal foo |
63 |
retVal bar |
|
282 | 64 |
|
616 | 65 |
Implementation note: |
294
6f937c0ba907
fixes for new MethodDictionary
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
66 |
this is a very tricky (but fully legal) implementation, |
2341
d05835f10cb8
better check for behavior compatibility
Claus Gittinger <cg@exept.de>
parents:
2215
diff
changeset
|
67 |
creating an object which is its own class. |
616 | 68 |
Therefore, no additional overhead by extra (class) objects is involved. |
69 |
These are very lightweight objects. |
|
70 |
||
294
6f937c0ba907
fixes for new MethodDictionary
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
71 |
Another prove that smalltalk is a powerful & flexible programming language. |
6f937c0ba907
fixes for new MethodDictionary
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
72 |
However, some smalltalk systems crash if your try this ;-) |
282 | 73 |
|
343 | 74 |
CAVEAT: |
616 | 75 |
tricky implementation - not the full object protocol is supported; |
343 | 76 |
a maximum of 50 instance variables is allowed. |
77 |
||
616 | 78 |
[WARNING:] |
79 |
this is an experimental goody - for our amusement and not meant |
|
80 |
to be used in real applications. |
|
81 |
It may be removed without notice and/or no longer maintained in the furure. |
|
82 |
||
282 | 83 |
[author:] |
294
6f937c0ba907
fixes for new MethodDictionary
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
84 |
Claus Gittinger |
282 | 85 |
|
86 |
[see also:] |
|
2341
d05835f10cb8
better check for behavior compatibility
Claus Gittinger <cg@exept.de>
parents:
2215
diff
changeset
|
87 |
Array |
294
6f937c0ba907
fixes for new MethodDictionary
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
88 |
Behavior |
282 | 89 |
" |
90 |
! |
|
91 |
||
92 |
examples |
|
93 |
" |
|
294
6f937c0ba907
fixes for new MethodDictionary
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
94 |
access is possibly by name: |
6f937c0ba907
fixes for new MethodDictionary
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
95 |
[exBegin] |
6f937c0ba907
fixes for new MethodDictionary
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
96 |
Transcript showCR: |
6f937c0ba907
fixes for new MethodDictionary
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
97 |
(Structure with:#foo->'foo value') foo |
6f937c0ba907
fixes for new MethodDictionary
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
98 |
[exEnd] |
282 | 99 |
|
294
6f937c0ba907
fixes for new MethodDictionary
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
100 |
AND also by index (for backward compatibility): |
6f937c0ba907
fixes for new MethodDictionary
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
101 |
[exBegin] |
6f937c0ba907
fixes for new MethodDictionary
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
102 |
Transcript showCR: |
6f937c0ba907
fixes for new MethodDictionary
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
103 |
((Structure with:#foo->'foo value') at:1) |
6f937c0ba907
fixes for new MethodDictionary
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
104 |
[exEnd] |
282 | 105 |
|
294
6f937c0ba907
fixes for new MethodDictionary
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
106 |
it can be inspected: |
6f937c0ba907
fixes for new MethodDictionary
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
107 |
[exBegin] |
6f937c0ba907
fixes for new MethodDictionary
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
108 |
(Structure with:#foo->'foo value') inspect |
6f937c0ba907
fixes for new MethodDictionary
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
109 |
[exEnd] |
282 | 110 |
|
294
6f937c0ba907
fixes for new MethodDictionary
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
111 |
and presents its contents nicely: |
6f937c0ba907
fixes for new MethodDictionary
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
112 |
[exBegin] |
6f937c0ba907
fixes for new MethodDictionary
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
113 |
(Structure with:#foo->'foo value' with:#bar->'bar value') inspect |
6f937c0ba907
fixes for new MethodDictionary
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
114 |
[exEnd] |
6f937c0ba907
fixes for new MethodDictionary
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
115 |
|
6f937c0ba907
fixes for new MethodDictionary
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
116 |
[exBegin] |
282 | 117 |
(Structure with:#foo->'hello' with:#bar->true with:#baz->'world') inspect |
294
6f937c0ba907
fixes for new MethodDictionary
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
118 |
[exEnd] |
282 | 119 |
|
120 |
" |
|
121 |
! ! |
|
122 |
||
616 | 123 |
!Structure class methodsFor:'initialization'! |
282 | 124 |
|
3627 | 125 |
initializeOneInstance |
282 | 126 |
OneInstance isNil ifTrue:[ |
2341
d05835f10cb8
better check for behavior compatibility
Claus Gittinger <cg@exept.de>
parents:
2215
diff
changeset
|
127 |
"/ check if the first few instvars correspond to Behavior's definition: |
d05835f10cb8
better check for behavior compatibility
Claus Gittinger <cg@exept.de>
parents:
2215
diff
changeset
|
128 |
|
3903 | 129 |
"/ (Behavior instSize + 1) == (self instanceVariableNames indexOf:#i1) ifFalse:[ |
130 |
"/ self halt:'you must change the definition of this class (instvars before i1 must match behavior''s)'. |
|
131 |
"/ ]. |
|
132 |
IndexOfFlags := Behavior instVarIndexFor:'flags'. |
|
133 |
IndexOfMethodDictionary := Behavior instVarIndexFor:'methodDictionary'. |
|
134 |
IndexOfInstSize := Behavior instVarIndexFor:'instSize'. |
|
135 |
||
282 | 136 |
OneInstance := self basicNew. |
137 |
||
138 |
DummyClass := Behavior shallowCopy. |
|
139 |
DummyClass flags:(Behavior flagBehavior bitOr:Behavior flagPointers). |
|
953 | 140 |
DummyClass setName:#DummyClass. |
294
6f937c0ba907
fixes for new MethodDictionary
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
141 |
|
2341
d05835f10cb8
better check for behavior compatibility
Claus Gittinger <cg@exept.de>
parents:
2215
diff
changeset
|
142 |
ReadAccessMethods := (1 to:50) |
616 | 143 |
collect:[:i | |m| |
144 |
m := self compiledMethodAt:('i', i printString) asSymbol. |
|
145 |
(m notNil and:[m isLazyMethod]) ifTrue:[m makeRealMethod]. |
|
146 |
m |
|
294
6f937c0ba907
fixes for new MethodDictionary
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
147 |
]. |
2341
d05835f10cb8
better check for behavior compatibility
Claus Gittinger <cg@exept.de>
parents:
2215
diff
changeset
|
148 |
WriteAccessMethods := (1 to:50) |
616 | 149 |
collect:[:i | |m| |
3403 | 150 |
m := self compiledMethodAt:('i', i printString) asMutator. |
616 | 151 |
(m notNil and:[m isLazyMethod]) ifTrue:[m makeRealMethod]. |
152 |
m |
|
294
6f937c0ba907
fixes for new MethodDictionary
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
153 |
]. |
6f937c0ba907
fixes for new MethodDictionary
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
154 |
|
616 | 155 |
OtherMethods := OrderedCollection new. |
2341
d05835f10cb8
better check for behavior compatibility
Claus Gittinger <cg@exept.de>
parents:
2215
diff
changeset
|
156 |
OtherMethods |
616 | 157 |
add:(self compiledMethodAt:#doesNotUnderstand:); |
158 |
add:(Object compiledMethodAt:#class); |
|
159 |
add:(Object compiledMethodAt:#identityHash); |
|
160 |
add:(Object compiledMethodAt:#at:); |
|
161 |
add:(Object compiledMethodAt:#at:put:); |
|
162 |
add:(Object compiledMethodAt:#basicAt:); |
|
163 |
add:(Object compiledMethodAt:#basicAt:put:); |
|
164 |
add:(Object compiledMethodAt:#printString); |
|
165 |
add:(Object compiledMethodAt:#printOn:); |
|
2186 | 166 |
add:(Object compiledMethodAt:#basicPrintOn:); |
616 | 167 |
add:(Object compiledMethodAt:#addDependent:); |
168 |
add:(Object compiledMethodAt:#removeDependent:); |
|
169 |
add:(Object compiledMethodAt:#dependents); |
|
170 |
add:(Object compiledMethodAt:#dependents:); |
|
171 |
add:(Object compiledMethodAt:#perform:); |
|
2186 | 172 |
add:(Object compiledMethodAt:#perform:with:); |
3628 | 173 |
add:(Object compiledMethodAt:#respondsTo:); |
2186 | 174 |
add:(Object compiledMethodAt:#isBoolean). |
616 | 175 |
OtherMethods := OtherMethods asArray. |
176 |
||
2341
d05835f10cb8
better check for behavior compatibility
Claus Gittinger <cg@exept.de>
parents:
2215
diff
changeset
|
177 |
OtherSelectors := #(#doesNotUnderstand: |
616 | 178 |
#class #identityHash |
2341
d05835f10cb8
better check for behavior compatibility
Claus Gittinger <cg@exept.de>
parents:
2215
diff
changeset
|
179 |
#at: #at:put: #basicAt: #basicAt:put: |
2186 | 180 |
#printString #printOn: #basicPrintOn: |
616 | 181 |
#addDependent: #removeDependent: #dependents #dependents: |
2186 | 182 |
#perform: #perform:with: |
3628 | 183 |
#respondsTo: |
2186 | 184 |
#isBoolean). |
282 | 185 |
]. |
186 |
||
187 |
" |
|
294
6f937c0ba907
fixes for new MethodDictionary
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
188 |
OneInstance := nil. |
6f937c0ba907
fixes for new MethodDictionary
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
189 |
self initialize. |
282 | 190 |
" |
191 |
||
343 | 192 |
"Modified: 21.9.1996 / 16:01:48 / cg" |
282 | 193 |
! ! |
194 |
||
616 | 195 |
!Structure class methodsFor:'instance creation'! |
282 | 196 |
|
197 |
newWith:names |
|
198 |
"return a new structure containing fields as passed in the names collection. |
|
199 |
The argument must be a sequenceable collection of symbols. |
|
294
6f937c0ba907
fixes for new MethodDictionary
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
200 |
The new structures values are all initialized to nil." |
282 | 201 |
|
202 |
^ self newWith:names values:nil |
|
203 |
||
204 |
" |
|
205 |
Structure newWith:#(foo bar) |
|
206 |
" |
|
207 |
||
208 |
"Created: 13.5.1996 / 20:03:42 / cg" |
|
209 |
! |
|
210 |
||
211 |
newWith:names values:values |
|
212 |
"return a new structure containing fields as passed in the names collection. |
|
213 |
The argument must be a sequenceable collection of symbols. |
|
214 |
The new structures values are set to corresponding values from the second argument, values." |
|
215 |
||
1424 | 216 |
|arr sels mthds nInsts behviorsInstSize| |
616 | 217 |
|
3627 | 218 |
OneInstance isNil ifTrue:[ |
219 |
self initializeOneInstance |
|
220 |
]. |
|
221 |
||
616 | 222 |
nInsts := names size. |
282 | 223 |
|
224 |
sels := names collect:[:nm | nm asSymbol]. |
|
3403 | 225 |
sels := sels , (names collect:[:nm | nm asMutator]). |
616 | 226 |
sels := sels , OtherSelectors. |
282 | 227 |
|
2341
d05835f10cb8
better check for behavior compatibility
Claus Gittinger <cg@exept.de>
parents:
2215
diff
changeset
|
228 |
mthds := ReadAccessMethods copyTo:nInsts. |
616 | 229 |
mthds := mthds , (WriteAccessMethods copyTo:nInsts). |
294
6f937c0ba907
fixes for new MethodDictionary
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
230 |
mthds := mthds , OtherMethods. |
282 | 231 |
|
294
6f937c0ba907
fixes for new MethodDictionary
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
232 |
"/ create a prototype object as an array ... |
616 | 233 |
"/ the object will be its own class, and have the indexable flag bit set; |
1424 | 234 |
"/ therefore, the first behviorsInstSize instVars must correspond to Behavior instvars, |
616 | 235 |
"/ the remaining ones will be the indexed instvars. |
1424 | 236 |
behviorsInstSize := Behavior instSize. |
282 | 237 |
|
1424 | 238 |
arr := Array new:(behviorsInstSize + nInsts). |
2351 | 239 |
"/ arr at:1 put:nil. "/ superclass |
3903 | 240 |
arr at:IndexOfFlags put:(Behavior flagBehavior bitOr:Behavior flagPointers). "/ flags |
241 |
arr at:IndexOfMethodDictionary put:(MethodDictionary withKeys:sels andValues:mthds). "/ selectors & methods |
|
242 |
"/ arr at:IndexOfLookupObject put:nil. "/ lookupObject |
|
243 |
arr at:IndexOfInstSize put:behviorsInstSize. "/ instSize |
|
244 |
||
294
6f937c0ba907
fixes for new MethodDictionary
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
245 |
"/ now, the big trick ... |
282 | 246 |
|
247 |
arr changeClassTo:DummyClass. |
|
248 |
arr changeClassTo:arr. |
|
249 |
||
250 |
values notNil ifTrue:[ |
|
251 |
values keysAndValuesDo:[:i :val | |
|
252 |
arr at:i put:val |
|
253 |
] |
|
254 |
]. |
|
255 |
||
2341
d05835f10cb8
better check for behavior compatibility
Claus Gittinger <cg@exept.de>
parents:
2215
diff
changeset
|
256 |
^ arr. |
282 | 257 |
|
258 |
" |
|
259 |
Structure newWith:#(foo bar) values:#('foo' 'bar') |
|
260 |
" |
|
261 |
||
262 |
"Created: 13.5.1996 / 20:03:42 / cg" |
|
294
6f937c0ba907
fixes for new MethodDictionary
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
263 |
"Modified: 3.7.1996 / 10:24:43 / cg" |
282 | 264 |
! |
265 |
||
266 |
with:assoc |
|
267 |
"return a new structure with a single field, named to the assocs key, |
|
268 |
and initialized with assocs value." |
|
269 |
||
270 |
^ self newWith:(Array with:assoc key) values:(Array with:assoc value) |
|
271 |
||
272 |
" |
|
273 |
Structure with:#foo->'foo' |
|
274 |
" |
|
275 |
! |
|
276 |
||
277 |
with:assoc1 with:assoc2 |
|
278 |
"return a new structure with two fields, named as defined by the arguments' |
|
279 |
keys, and and initialized with the assocs' values." |
|
280 |
||
2341
d05835f10cb8
better check for behavior compatibility
Claus Gittinger <cg@exept.de>
parents:
2215
diff
changeset
|
281 |
^ self newWith:(Array with:assoc1 key with:assoc2 key) |
294
6f937c0ba907
fixes for new MethodDictionary
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
282 |
values:(Array with:assoc1 value with:assoc2 value) |
282 | 283 |
|
284 |
" |
|
285 |
Structure with:#foo->'foo' with:#bar->'bar' |
|
286 |
" |
|
287 |
! |
|
288 |
||
289 |
with:assoc1 with:assoc2 with:assoc3 |
|
290 |
"return a new structure with three fields, named as defined by the arguments' |
|
291 |
keys, and and initialized with the assocs' values." |
|
292 |
||
2341
d05835f10cb8
better check for behavior compatibility
Claus Gittinger <cg@exept.de>
parents:
2215
diff
changeset
|
293 |
^ self newWith:(Array with:assoc1 key with:assoc2 key with:assoc3 key) |
294
6f937c0ba907
fixes for new MethodDictionary
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
294 |
values:(Array with:assoc1 value with:assoc2 value with:assoc3 value) |
282 | 295 |
|
296 |
" |
|
297 |
Structure with:#foo->'foo' with:#bar->'bar' with:#baz->'baz' |
|
298 |
" |
|
299 |
! |
|
300 |
||
301 |
with:assoc1 with:assoc2 with:assoc3 with:assoc4 |
|
302 |
"return a new structure with four fields, named as defined by the arguments' |
|
303 |
keys, and and initialized with the assocs' values." |
|
304 |
||
2341
d05835f10cb8
better check for behavior compatibility
Claus Gittinger <cg@exept.de>
parents:
2215
diff
changeset
|
305 |
^ self newWith:(Array with:assoc1 key with:assoc2 key |
d05835f10cb8
better check for behavior compatibility
Claus Gittinger <cg@exept.de>
parents:
2215
diff
changeset
|
306 |
with:assoc3 key with:assoc4 key) |
d05835f10cb8
better check for behavior compatibility
Claus Gittinger <cg@exept.de>
parents:
2215
diff
changeset
|
307 |
values:(Array with:assoc1 value with:assoc2 value |
294
6f937c0ba907
fixes for new MethodDictionary
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
308 |
with:assoc3 value with:assoc4 value) |
282 | 309 |
|
310 |
" |
|
311 |
Structure with:#foo->'foo' with:#bar->'bar' with:#baz->'baz' with:#hello->'hello' |
|
312 |
" |
|
313 |
! |
|
314 |
||
315 |
with:assoc1 with:assoc2 with:assoc3 with:assoc4 with:assoc5 |
|
316 |
"return a new structure with five fields, named as defined by the arguments' |
|
317 |
keys, and and initialized with the assocs' values." |
|
318 |
||
2341
d05835f10cb8
better check for behavior compatibility
Claus Gittinger <cg@exept.de>
parents:
2215
diff
changeset
|
319 |
^ self newWith:(Array with:assoc1 key with:assoc2 key |
d05835f10cb8
better check for behavior compatibility
Claus Gittinger <cg@exept.de>
parents:
2215
diff
changeset
|
320 |
with:assoc3 key with:assoc4 key |
d05835f10cb8
better check for behavior compatibility
Claus Gittinger <cg@exept.de>
parents:
2215
diff
changeset
|
321 |
with:assoc5 key) |
d05835f10cb8
better check for behavior compatibility
Claus Gittinger <cg@exept.de>
parents:
2215
diff
changeset
|
322 |
values:(Array with:assoc1 value with:assoc2 value |
d05835f10cb8
better check for behavior compatibility
Claus Gittinger <cg@exept.de>
parents:
2215
diff
changeset
|
323 |
with:assoc3 value with:assoc4 value |
282 | 324 |
with:assoc5 value) |
325 |
||
326 |
" |
|
327 |
Structure with:#foo->'foo' with:#bar->'bar' with:#baz->'baz' with:#hello->'hello' with:#world->'world' |
|
328 |
" |
|
1131 | 329 |
! |
330 |
||
331 |
with:assoc1 with:assoc2 with:assoc3 with:assoc4 with:assoc5 with:assoc6 |
|
332 |
"return a new structure with five fields, named as defined by the arguments' |
|
333 |
keys, and and initialized with the assocs' values." |
|
334 |
||
2341
d05835f10cb8
better check for behavior compatibility
Claus Gittinger <cg@exept.de>
parents:
2215
diff
changeset
|
335 |
^ self newWith:(Array with:assoc1 key with:assoc2 key |
d05835f10cb8
better check for behavior compatibility
Claus Gittinger <cg@exept.de>
parents:
2215
diff
changeset
|
336 |
with:assoc3 key with:assoc4 key |
d05835f10cb8
better check for behavior compatibility
Claus Gittinger <cg@exept.de>
parents:
2215
diff
changeset
|
337 |
with:assoc5 key with:assoc6 key) |
d05835f10cb8
better check for behavior compatibility
Claus Gittinger <cg@exept.de>
parents:
2215
diff
changeset
|
338 |
values:(Array with:assoc1 value with:assoc2 value |
d05835f10cb8
better check for behavior compatibility
Claus Gittinger <cg@exept.de>
parents:
2215
diff
changeset
|
339 |
with:assoc3 value with:assoc4 value |
1131 | 340 |
with:assoc5 value with:assoc6 value) |
341 |
||
342 |
" |
|
343 |
Structure with:#foo->'foo' with:#bar->'bar' with:#baz->'baz' with:#hello->'hello' with:#world->'world' |
|
344 |
" |
|
345 |
! |
|
346 |
||
347 |
with:assoc1 with:assoc2 with:assoc3 with:assoc4 with:assoc5 with:assoc6 with:assoc7 |
|
348 |
"return a new structure with five fields, named as defined by the arguments' |
|
349 |
keys, and and initialized with the assocs' values." |
|
350 |
||
2341
d05835f10cb8
better check for behavior compatibility
Claus Gittinger <cg@exept.de>
parents:
2215
diff
changeset
|
351 |
^ self newWith:(Array with:assoc1 key with:assoc2 key |
d05835f10cb8
better check for behavior compatibility
Claus Gittinger <cg@exept.de>
parents:
2215
diff
changeset
|
352 |
with:assoc3 key with:assoc4 key |
1131 | 353 |
with:assoc5 key with:assoc6 key |
2341
d05835f10cb8
better check for behavior compatibility
Claus Gittinger <cg@exept.de>
parents:
2215
diff
changeset
|
354 |
with:assoc7 key) |
d05835f10cb8
better check for behavior compatibility
Claus Gittinger <cg@exept.de>
parents:
2215
diff
changeset
|
355 |
values:(Array with:assoc1 value with:assoc2 value |
d05835f10cb8
better check for behavior compatibility
Claus Gittinger <cg@exept.de>
parents:
2215
diff
changeset
|
356 |
with:assoc3 value with:assoc4 value |
1131 | 357 |
with:assoc5 value with:assoc6 value |
358 |
with:assoc7 value) |
|
359 |
||
360 |
" |
|
361 |
Structure with:#foo->'foo' with:#bar->'bar' with:#baz->'baz' with:#hello->'hello' with:#world->'world' |
|
362 |
" |
|
282 | 363 |
! ! |
364 |
||
616 | 365 |
!Structure class methodsFor:'special'! |
366 |
||
367 |
primAddSelector:newSelector withMethod:newMethod |
|
368 |
"must reinit myself when methods are accepted." |
|
369 |
||
370 |
|val| |
|
371 |
||
372 |
val := super primAddSelector:newSelector withMethod:newMethod. |
|
373 |
OneInstance := nil. |
|
3627 | 374 |
"/ self initializeOneInstance. |
616 | 375 |
^ val |
376 |
! ! |
|
377 |
||
282 | 378 |
!Structure methodsFor:'accessing'! |
379 |
||
380 |
flags |
|
381 |
"return the flags - required class protocol" |
|
382 |
||
383 |
^ flags |
|
384 |
||
385 |
"Created: 13.5.1996 / 21:19:23 / cg" |
|
386 |
! |
|
387 |
||
388 |
flags:something |
|
389 |
"set the flags - required class protocol" |
|
390 |
||
391 |
flags := something. |
|
392 |
||
393 |
"Created: 13.5.1996 / 21:19:23 / cg" |
|
394 |
! |
|
395 |
||
396 |
i1 |
|
616 | 397 |
"prototype method to return the first instance variable" |
282 | 398 |
|
399 |
^ i1 |
|
400 |
||
401 |
"Created: 13.5.1996 / 21:19:25 / cg" |
|
402 |
! |
|
403 |
||
404 |
i10 |
|
616 | 405 |
"prototype method to return the 10th instance variable" |
282 | 406 |
|
407 |
^ i10 |
|
408 |
||
409 |
"Created: 13.5.1996 / 21:19:27 / cg" |
|
410 |
! |
|
411 |
||
412 |
i10:something |
|
616 | 413 |
"prototype method to set the 10th instance variable" |
282 | 414 |
|
415 |
i10 := something. |
|
416 |
||
417 |
"Created: 13.5.1996 / 21:19:27 / cg" |
|
418 |
! |
|
419 |
||
420 |
i11 |
|
421 |
"return i11" |
|
422 |
||
423 |
^ i11 |
|
424 |
||
425 |
"Created: 13.5.1996 / 21:19:27 / cg" |
|
426 |
! |
|
427 |
||
428 |
i11:something |
|
616 | 429 |
"prototype method to set the 11th instance variable" |
282 | 430 |
|
431 |
i11 := something. |
|
432 |
||
433 |
"Created: 13.5.1996 / 21:19:27 / cg" |
|
434 |
! |
|
435 |
||
436 |
i12 |
|
437 |
"return i12" |
|
438 |
||
439 |
^ i12 |
|
440 |
||
441 |
"Created: 13.5.1996 / 21:19:27 / cg" |
|
442 |
! |
|
443 |
||
444 |
i12:something |
|
445 |
"set i12" |
|
446 |
||
447 |
i12 := something. |
|
448 |
||
449 |
"Created: 13.5.1996 / 21:19:27 / cg" |
|
450 |
! |
|
451 |
||
452 |
i13 |
|
453 |
"return i13" |
|
454 |
||
455 |
^ i13 |
|
456 |
||
457 |
"Created: 13.5.1996 / 21:19:28 / cg" |
|
458 |
! |
|
459 |
||
460 |
i13:something |
|
461 |
"set i13" |
|
462 |
||
463 |
i13 := something. |
|
464 |
||
465 |
"Created: 13.5.1996 / 21:19:28 / cg" |
|
466 |
! |
|
467 |
||
468 |
i14 |
|
469 |
"return i14" |
|
470 |
||
471 |
^ i14 |
|
472 |
||
473 |
"Created: 13.5.1996 / 21:19:28 / cg" |
|
474 |
! |
|
475 |
||
476 |
i14:something |
|
477 |
"set i14" |
|
478 |
||
479 |
i14 := something. |
|
480 |
||
481 |
"Created: 13.5.1996 / 21:19:28 / cg" |
|
482 |
! |
|
483 |
||
484 |
i15 |
|
485 |
"return i15" |
|
486 |
||
487 |
^ i15 |
|
488 |
||
489 |
"Created: 13.5.1996 / 21:19:28 / cg" |
|
490 |
! |
|
491 |
||
492 |
i15:something |
|
493 |
"set i15" |
|
494 |
||
495 |
i15 := something. |
|
496 |
||
497 |
"Created: 13.5.1996 / 21:19:28 / cg" |
|
498 |
! |
|
499 |
||
500 |
i16 |
|
501 |
"return i16" |
|
502 |
||
503 |
^ i16 |
|
504 |
||
505 |
"Created: 13.5.1996 / 21:19:28 / cg" |
|
506 |
! |
|
507 |
||
508 |
i16:something |
|
509 |
"set i16" |
|
510 |
||
511 |
i16 := something. |
|
512 |
||
513 |
"Created: 13.5.1996 / 21:19:28 / cg" |
|
514 |
! |
|
515 |
||
516 |
i17 |
|
517 |
"return i17" |
|
518 |
||
519 |
^ i17 |
|
520 |
||
521 |
"Created: 13.5.1996 / 21:19:28 / cg" |
|
522 |
! |
|
523 |
||
524 |
i17:something |
|
525 |
"set i17" |
|
526 |
||
527 |
i17 := something. |
|
528 |
||
529 |
"Created: 13.5.1996 / 21:19:29 / cg" |
|
530 |
! |
|
531 |
||
532 |
i18 |
|
533 |
"return i18" |
|
534 |
||
535 |
^ i18 |
|
536 |
||
537 |
"Created: 13.5.1996 / 21:19:29 / cg" |
|
538 |
! |
|
539 |
||
540 |
i18:something |
|
541 |
"set i18" |
|
542 |
||
543 |
i18 := something. |
|
544 |
||
545 |
"Created: 13.5.1996 / 21:19:29 / cg" |
|
546 |
! |
|
547 |
||
548 |
i19 |
|
549 |
"return i19" |
|
550 |
||
551 |
^ i19 |
|
552 |
||
553 |
"Created: 13.5.1996 / 21:19:29 / cg" |
|
554 |
! |
|
555 |
||
556 |
i19:something |
|
557 |
"set i19" |
|
558 |
||
559 |
i19 := something. |
|
560 |
||
561 |
"Created: 13.5.1996 / 21:19:29 / cg" |
|
562 |
! |
|
563 |
||
564 |
i1:something |
|
616 | 565 |
"prototype method to set the 1st instance variable" |
282 | 566 |
|
567 |
i1 := something. |
|
568 |
||
569 |
"Created: 13.5.1996 / 21:19:25 / cg" |
|
570 |
! |
|
571 |
||
572 |
i2 |
|
616 | 573 |
"prototype method to return the 2nd instance variable" |
282 | 574 |
|
575 |
^ i2 |
|
576 |
||
577 |
"Created: 13.5.1996 / 21:19:25 / cg" |
|
578 |
! |
|
579 |
||
580 |
i20 |
|
581 |
"return i20" |
|
582 |
||
583 |
^ i20 |
|
584 |
||
585 |
"Created: 13.5.1996 / 21:19:29 / cg" |
|
586 |
! |
|
587 |
||
588 |
i20:something |
|
589 |
"set i20" |
|
590 |
||
591 |
i20 := something. |
|
592 |
||
593 |
"Created: 13.5.1996 / 21:19:29 / cg" |
|
594 |
! |
|
595 |
||
343 | 596 |
i21 |
597 |
"return i21" |
|
598 |
||
599 |
^ i21 |
|
600 |
||
601 |
"Created: 21.9.1996 / 16:06:21 / cg" |
|
602 |
! |
|
603 |
||
604 |
i21:something |
|
605 |
"set i21" |
|
606 |
||
607 |
i21 := something. |
|
608 |
||
609 |
"Created: 21.9.1996 / 16:06:21 / cg" |
|
610 |
! |
|
611 |
||
612 |
i22 |
|
613 |
"return i22" |
|
614 |
||
615 |
^ i22 |
|
616 |
||
617 |
"Created: 21.9.1996 / 16:06:21 / cg" |
|
618 |
! |
|
619 |
||
620 |
i22:something |
|
621 |
"set i22" |
|
622 |
||
623 |
i22 := something. |
|
624 |
||
625 |
"Created: 21.9.1996 / 16:06:21 / cg" |
|
626 |
! |
|
627 |
||
628 |
i23 |
|
629 |
"return i23" |
|
630 |
||
631 |
^ i23 |
|
632 |
||
633 |
"Created: 21.9.1996 / 16:06:21 / cg" |
|
634 |
! |
|
635 |
||
636 |
i23:something |
|
637 |
"set i23" |
|
638 |
||
639 |
i23 := something. |
|
640 |
||
641 |
"Created: 21.9.1996 / 16:06:21 / cg" |
|
642 |
! |
|
643 |
||
644 |
i24 |
|
645 |
"return i24" |
|
646 |
||
647 |
^ i24 |
|
648 |
||
649 |
"Created: 21.9.1996 / 16:06:21 / cg" |
|
650 |
! |
|
651 |
||
652 |
i24:something |
|
653 |
"set i24" |
|
654 |
||
655 |
i24 := something. |
|
656 |
||
657 |
"Created: 21.9.1996 / 16:06:21 / cg" |
|
658 |
! |
|
659 |
||
660 |
i25 |
|
661 |
"return i25" |
|
662 |
||
663 |
^ i25 |
|
664 |
||
665 |
"Created: 21.9.1996 / 16:06:21 / cg" |
|
666 |
! |
|
667 |
||
668 |
i25:something |
|
669 |
"set i25" |
|
670 |
||
671 |
i25 := something. |
|
672 |
||
673 |
"Created: 21.9.1996 / 16:06:22 / cg" |
|
674 |
! |
|
675 |
||
676 |
i26 |
|
677 |
"return i26" |
|
678 |
||
679 |
^ i26 |
|
680 |
||
681 |
"Created: 21.9.1996 / 16:06:22 / cg" |
|
682 |
! |
|
683 |
||
684 |
i26:something |
|
685 |
"set i26" |
|
686 |
||
687 |
i26 := something. |
|
688 |
||
689 |
"Created: 21.9.1996 / 16:06:22 / cg" |
|
690 |
! |
|
691 |
||
692 |
i27 |
|
693 |
"return i27" |
|
694 |
||
695 |
^ i27 |
|
696 |
||
697 |
"Created: 21.9.1996 / 16:06:22 / cg" |
|
698 |
! |
|
699 |
||
700 |
i27:something |
|
701 |
"set i27" |
|
702 |
||
703 |
i27 := something. |
|
704 |
||
705 |
"Created: 21.9.1996 / 16:06:22 / cg" |
|
706 |
! |
|
707 |
||
708 |
i28 |
|
709 |
"return i28" |
|
710 |
||
711 |
^ i28 |
|
712 |
||
713 |
"Created: 21.9.1996 / 16:06:22 / cg" |
|
714 |
! |
|
715 |
||
716 |
i28:something |
|
717 |
"set i28" |
|
718 |
||
719 |
i28 := something. |
|
720 |
||
721 |
"Created: 21.9.1996 / 16:06:22 / cg" |
|
722 |
! |
|
723 |
||
724 |
i29 |
|
725 |
"return i29" |
|
726 |
||
727 |
^ i29 |
|
728 |
||
729 |
"Created: 21.9.1996 / 16:06:22 / cg" |
|
730 |
! |
|
731 |
||
732 |
i29:something |
|
733 |
"set i29" |
|
734 |
||
735 |
i29 := something. |
|
736 |
||
737 |
"Created: 21.9.1996 / 16:06:22 / cg" |
|
738 |
! |
|
739 |
||
282 | 740 |
i2:something |
616 | 741 |
"prototype method to set the 2nd instance variable" |
282 | 742 |
|
743 |
i2 := something. |
|
744 |
||
745 |
"Created: 13.5.1996 / 21:19:25 / cg" |
|
746 |
! |
|
747 |
||
748 |
i3 |
|
616 | 749 |
"prototype method to return the 3rd instance variable" |
282 | 750 |
|
751 |
^ i3 |
|
752 |
||
753 |
"Created: 13.5.1996 / 21:19:25 / cg" |
|
754 |
! |
|
755 |
||
343 | 756 |
i30:something |
757 |
"set i30" |
|
758 |
||
759 |
i30 := something. |
|
760 |
||
761 |
"Created: 21.9.1996 / 16:06:22 / cg" |
|
762 |
! |
|
763 |
||
764 |
i31 |
|
765 |
"return i31" |
|
766 |
||
767 |
^ i31 |
|
768 |
||
769 |
"Created: 21.9.1996 / 16:06:22 / cg" |
|
770 |
! |
|
771 |
||
772 |
i31:something |
|
773 |
"set i31" |
|
774 |
||
775 |
i31 := something. |
|
776 |
||
777 |
"Created: 21.9.1996 / 16:06:22 / cg" |
|
778 |
! |
|
779 |
||
780 |
i32 |
|
781 |
"return i32" |
|
782 |
||
783 |
^ i32 |
|
784 |
||
785 |
"Created: 21.9.1996 / 16:06:22 / cg" |
|
786 |
! |
|
787 |
||
788 |
i32:something |
|
789 |
"set i32" |
|
790 |
||
791 |
i32 := something. |
|
792 |
||
793 |
"Created: 21.9.1996 / 16:06:22 / cg" |
|
794 |
! |
|
795 |
||
796 |
i33 |
|
797 |
"return i33" |
|
798 |
||
799 |
^ i33 |
|
800 |
||
801 |
"Created: 21.9.1996 / 16:06:22 / cg" |
|
802 |
! |
|
803 |
||
804 |
i33:something |
|
805 |
"set i33" |
|
806 |
||
807 |
i33 := something. |
|
808 |
||
809 |
"Created: 21.9.1996 / 16:06:22 / cg" |
|
810 |
! |
|
811 |
||
812 |
i34 |
|
813 |
"return i34" |
|
814 |
||
815 |
^ i34 |
|
816 |
||
817 |
"Created: 21.9.1996 / 16:06:22 / cg" |
|
818 |
! |
|
819 |
||
820 |
i34:something |
|
821 |
"set i34" |
|
822 |
||
823 |
i34 := something. |
|
824 |
||
825 |
"Created: 21.9.1996 / 16:06:22 / cg" |
|
826 |
! |
|
827 |
||
828 |
i35 |
|
829 |
"return i35" |
|
830 |
||
831 |
^ i35 |
|
832 |
||
833 |
"Created: 21.9.1996 / 16:06:22 / cg" |
|
834 |
! |
|
835 |
||
836 |
i35:something |
|
837 |
"set i35" |
|
838 |
||
839 |
i35 := something. |
|
840 |
||
841 |
"Created: 21.9.1996 / 16:06:22 / cg" |
|
842 |
! |
|
843 |
||
844 |
i36 |
|
845 |
"return i36" |
|
846 |
||
847 |
^ i36 |
|
848 |
||
849 |
"Created: 21.9.1996 / 16:06:22 / cg" |
|
850 |
! |
|
851 |
||
852 |
i36:something |
|
853 |
"set i36" |
|
854 |
||
855 |
i36 := something. |
|
856 |
||
857 |
"Created: 21.9.1996 / 16:06:22 / cg" |
|
858 |
! |
|
859 |
||
860 |
i37 |
|
861 |
"return i37" |
|
862 |
||
863 |
^ i37 |
|
864 |
||
865 |
"Created: 21.9.1996 / 16:06:22 / cg" |
|
866 |
! |
|
867 |
||
868 |
i37:something |
|
869 |
"set i37" |
|
870 |
||
871 |
i37 := something. |
|
872 |
||
873 |
"Created: 21.9.1996 / 16:06:22 / cg" |
|
874 |
! |
|
875 |
||
876 |
i38 |
|
877 |
"return i38" |
|
878 |
||
879 |
^ i38 |
|
880 |
||
881 |
"Created: 21.9.1996 / 16:06:22 / cg" |
|
882 |
! |
|
883 |
||
884 |
i38:something |
|
885 |
"set i38" |
|
886 |
||
887 |
i38 := something. |
|
888 |
||
889 |
"Created: 21.9.1996 / 16:06:22 / cg" |
|
890 |
! |
|
891 |
||
892 |
i39 |
|
893 |
"return i39" |
|
894 |
||
895 |
^ i39 |
|
896 |
||
897 |
"Created: 21.9.1996 / 16:06:22 / cg" |
|
898 |
! |
|
899 |
||
900 |
i39:something |
|
901 |
"set i39" |
|
902 |
||
903 |
i39 := something. |
|
904 |
||
905 |
"Created: 21.9.1996 / 16:06:22 / cg" |
|
906 |
! |
|
907 |
||
282 | 908 |
i3:something |
616 | 909 |
"prototype method to set the 3rd instance variable" |
282 | 910 |
|
911 |
i3 := something. |
|
912 |
||
913 |
"Created: 13.5.1996 / 21:19:25 / cg" |
|
914 |
! |
|
915 |
||
916 |
i4 |
|
616 | 917 |
"prototype method to return the 4th instance variable" |
282 | 918 |
|
919 |
^ i4 |
|
920 |
||
921 |
"Created: 13.5.1996 / 21:19:25 / cg" |
|
922 |
! |
|
923 |
||
616 | 924 |
i40 |
925 |
"return the value of the instance variable 'i40' (automatically generated)" |
|
926 |
||
1129 | 927 |
^ i40 |
928 |
! |
|
616 | 929 |
|
343 | 930 |
i40:something |
616 | 931 |
"prototype method" |
343 | 932 |
|
933 |
i40 := something. |
|
934 |
||
935 |
"Created: 21.9.1996 / 16:06:22 / cg" |
|
936 |
! |
|
937 |
||
938 |
i41 |
|
616 | 939 |
"prototype method" |
343 | 940 |
|
941 |
^ i41 |
|
942 |
||
943 |
"Created: 21.9.1996 / 16:06:23 / cg" |
|
944 |
! |
|
945 |
||
946 |
i41:something |
|
616 | 947 |
"prototype method" |
343 | 948 |
|
949 |
i41 := something. |
|
950 |
||
951 |
"Created: 21.9.1996 / 16:06:23 / cg" |
|
952 |
! |
|
953 |
||
954 |
i42 |
|
616 | 955 |
"prototype method" |
343 | 956 |
|
957 |
^ i42 |
|
958 |
||
959 |
"Created: 21.9.1996 / 16:06:23 / cg" |
|
960 |
! |
|
961 |
||
962 |
i42:something |
|
616 | 963 |
"prototype method" |
343 | 964 |
|
965 |
i42 := something. |
|
966 |
||
967 |
"Created: 21.9.1996 / 16:06:23 / cg" |
|
968 |
! |
|
969 |
||
970 |
i43 |
|
616 | 971 |
"prototype method" |
343 | 972 |
|
973 |
^ i43 |
|
974 |
||
975 |
"Created: 21.9.1996 / 16:06:23 / cg" |
|
976 |
! |
|
977 |
||
978 |
i43:something |
|
616 | 979 |
"prototype method" |
343 | 980 |
|
981 |
i43 := something. |
|
982 |
||
983 |
"Created: 21.9.1996 / 16:06:23 / cg" |
|
984 |
! |
|
985 |
||
986 |
i44 |
|
616 | 987 |
"prototype method" |
343 | 988 |
|
989 |
^ i44 |
|
990 |
||
991 |
"Created: 21.9.1996 / 16:06:23 / cg" |
|
992 |
! |
|
993 |
||
994 |
i44:something |
|
616 | 995 |
"prototype method" |
343 | 996 |
|
997 |
i44 := something. |
|
998 |
||
999 |
"Created: 21.9.1996 / 16:06:23 / cg" |
|
1000 |
! |
|
1001 |
||
1002 |
i45 |
|
616 | 1003 |
"prototype method" |
343 | 1004 |
|
1005 |
^ i45 |
|
1006 |
||
1007 |
"Created: 21.9.1996 / 16:06:23 / cg" |
|
1008 |
! |
|
1009 |
||
1010 |
i45:something |
|
616 | 1011 |
"prototype method" |
343 | 1012 |
|
1013 |
i45 := something. |
|
1014 |
||
1015 |
"Created: 21.9.1996 / 16:06:23 / cg" |
|
1016 |
! |
|
1017 |
||
1018 |
i46 |
|
616 | 1019 |
"prototype method" |
343 | 1020 |
|
1021 |
^ i46 |
|
1022 |
||
1023 |
"Created: 21.9.1996 / 16:06:23 / cg" |
|
1024 |
! |
|
1025 |
||
1026 |
i46:something |
|
616 | 1027 |
"prototype method" |
343 | 1028 |
|
1029 |
i46 := something. |
|
1030 |
||
1031 |
"Created: 21.9.1996 / 16:06:23 / cg" |
|
1032 |
! |
|
1033 |
||
1034 |
i47 |
|
616 | 1035 |
"prototype method" |
343 | 1036 |
|
1037 |
^ i47 |
|
1038 |
||
1039 |
"Created: 21.9.1996 / 16:06:23 / cg" |
|
1040 |
! |
|
1041 |
||
1042 |
i47:something |
|
616 | 1043 |
"prototype method" |
343 | 1044 |
|
1045 |
i47 := something. |
|
1046 |
||
1047 |
"Created: 21.9.1996 / 16:06:23 / cg" |
|
1048 |
! |
|
1049 |
||
1050 |
i48 |
|
616 | 1051 |
"prototype method" |
343 | 1052 |
|
1053 |
^ i48 |
|
1054 |
||
1055 |
"Created: 21.9.1996 / 16:06:23 / cg" |
|
1056 |
! |
|
1057 |
||
1058 |
i48:something |
|
616 | 1059 |
"prototype method" |
343 | 1060 |
|
1061 |
i48 := something. |
|
1062 |
||
1063 |
"Created: 21.9.1996 / 16:06:23 / cg" |
|
1064 |
! |
|
1065 |
||
1066 |
i49 |
|
616 | 1067 |
"prototype method" |
343 | 1068 |
|
1069 |
^ i49 |
|
1070 |
||
1071 |
"Created: 21.9.1996 / 16:06:23 / cg" |
|
1072 |
! |
|
1073 |
||
1074 |
i49:something |
|
616 | 1075 |
"prototype method" |
343 | 1076 |
|
1077 |
i49 := something. |
|
1078 |
||
1079 |
"Created: 21.9.1996 / 16:06:24 / cg" |
|
1080 |
! |
|
1081 |
||
282 | 1082 |
i4:something |
616 | 1083 |
"prototype method to set the 4th instance variable" |
282 | 1084 |
|
1085 |
i4 := something. |
|
1086 |
||
1087 |
"Created: 13.5.1996 / 21:19:25 / cg" |
|
1088 |
! |
|
1089 |
||
1090 |
i5 |
|
616 | 1091 |
"prototype method to return the 5th instance variable" |
282 | 1092 |
|
1093 |
^ i5 |
|
1094 |
||
1095 |
"Created: 13.5.1996 / 21:19:26 / cg" |
|
1096 |
! |
|
1097 |
||
343 | 1098 |
i50 |
616 | 1099 |
"prototype method" |
343 | 1100 |
|
1101 |
^ i50 |
|
1102 |
||
1103 |
"Created: 21.9.1996 / 16:06:24 / cg" |
|
1104 |
! |
|
1105 |
||
1106 |
i50:something |
|
616 | 1107 |
"prototype method" |
343 | 1108 |
|
1109 |
i50 := something. |
|
1110 |
||
1111 |
"Created: 21.9.1996 / 16:06:24 / cg" |
|
1112 |
! |
|
1113 |
||
282 | 1114 |
i5:something |
616 | 1115 |
"prototype method to set the 5th instance variable" |
282 | 1116 |
|
1117 |
i5 := something. |
|
1118 |
||
1119 |
"Created: 13.5.1996 / 21:19:26 / cg" |
|
1120 |
! |
|
1121 |
||
1122 |
i6 |
|
616 | 1123 |
"prototype method to return the 6th instance variable" |
282 | 1124 |
|
1125 |
^ i6 |
|
1126 |
||
1127 |
"Created: 13.5.1996 / 21:19:26 / cg" |
|
1128 |
! |
|
1129 |
||
1130 |
i6:something |
|
616 | 1131 |
"prototype method to set the 6th instance variable" |
282 | 1132 |
|
1133 |
i6 := something. |
|
1134 |
||
1135 |
"Created: 13.5.1996 / 21:19:26 / cg" |
|
1136 |
! |
|
1137 |
||
1138 |
i7 |
|
616 | 1139 |
"prototype method to return the 7th instance variable" |
282 | 1140 |
|
1141 |
^ i7 |
|
1142 |
||
1143 |
"Created: 13.5.1996 / 21:19:26 / cg" |
|
1144 |
! |
|
1145 |
||
1146 |
i7:something |
|
616 | 1147 |
"prototype method to set the 7th instance variable" |
282 | 1148 |
|
1149 |
i7 := something. |
|
1150 |
||
1151 |
"Created: 13.5.1996 / 21:19:26 / cg" |
|
1152 |
! |
|
1153 |
||
1154 |
i8 |
|
616 | 1155 |
"prototype method to return the 8th instance variable" |
282 | 1156 |
|
1157 |
^ i8 |
|
1158 |
||
1159 |
"Created: 13.5.1996 / 21:19:26 / cg" |
|
1160 |
! |
|
1161 |
||
1162 |
i8:something |
|
616 | 1163 |
"prototype method to set the 8th instance variable" |
282 | 1164 |
|
1165 |
i8 := something. |
|
1166 |
||
1167 |
"Created: 13.5.1996 / 21:19:26 / cg" |
|
1168 |
! |
|
1169 |
||
1170 |
i9 |
|
616 | 1171 |
"prototype method to return the 9th instance variable" |
282 | 1172 |
|
1173 |
^ i9 |
|
1174 |
||
1175 |
"Created: 13.5.1996 / 21:19:26 / cg" |
|
1176 |
! |
|
1177 |
||
1178 |
i9:something |
|
616 | 1179 |
"prototype method to set the 9th instance variable" |
282 | 1180 |
|
1181 |
i9 := something. |
|
1182 |
||
1183 |
"Created: 13.5.1996 / 21:19:27 / cg" |
|
1184 |
! |
|
1185 |
||
1186 |
instSize |
|
1187 |
"return instSize - required class protocol" |
|
1188 |
||
1189 |
^ instSize |
|
1190 |
||
1191 |
"Created: 13.5.1996 / 21:19:24 / cg" |
|
1192 |
! |
|
1193 |
||
1194 |
instSize:something |
|
1195 |
"set instSize - required class protocol" |
|
1196 |
||
1197 |
instSize := something. |
|
1198 |
||
1199 |
"Created: 13.5.1996 / 21:19:25 / cg" |
|
1200 |
! |
|
1201 |
||
429 | 1202 |
methodDictionary |
1203 |
"return the methodDictionary - required class protocol" |
|
282 | 1204 |
|
429 | 1205 |
^ methodDictionary |
282 | 1206 |
! |
1207 |
||
1208 |
superclass |
|
1209 |
"return superclass - required class protocol" |
|
1210 |
||
1211 |
^ superclass |
|
1212 |
||
1213 |
"Created: 13.5.1996 / 21:19:23 / cg" |
|
1214 |
! |
|
1215 |
||
1216 |
superclass:something |
|
1217 |
"set superclass - required class protocol" |
|
1218 |
||
1219 |
superclass := something. |
|
1220 |
||
1221 |
"Created: 13.5.1996 / 21:19:23 / cg" |
|
1222 |
! ! |
|
1223 |
||
1224 |
!Structure methodsFor:'stubs'! |
|
1225 |
||
1226 |
doesNotUnderstand:aMessage |
|
294
6f937c0ba907
fixes for new MethodDictionary
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
1227 |
"catch unimplemented messages - pass some to the superclass. |
6f937c0ba907
fixes for new MethodDictionary
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
1228 |
Notice that although this method calls super messages, |
6f937c0ba907
fixes for new MethodDictionary
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
1229 |
actual instances will have no valid superClass." |
282 | 1230 |
|
4167 | 1231 |
<ignore: RBReturnsBooleanAndOtherRule rationale:'returns whatever the forwarded method returns' author:'cg'> |
1232 |
||
616 | 1233 |
|sel args names sz s idx| |
282 | 1234 |
|
1235 |
"/ instance protocol |
|
1236 |
||
1237 |
sel := aMessage selector. |
|
1238 |
args := aMessage arguments. |
|
1239 |
||
4170 | 1240 |
(sel == #displayOn:) ifTrue:[ |
1241 |
s := args at:1. |
|
1242 |
s nextPutAll:'Structure('. |
|
1243 |
names := self allInstVarNames. |
|
1244 |
names notNil ifTrue:[ |
|
1245 |
names keysAndValuesDo:[:idx :nm | |
|
1246 |
s nextPutAll:nm; nextPutAll:'->'. |
|
1247 |
(self at:idx) displayOn:s. |
|
1248 |
s space |
|
1249 |
]. |
|
1250 |
]. |
|
1251 |
s nextPut:$). |
|
1252 |
^ self. |
|
1253 |
]. |
|
1254 |
||
2186 | 1255 |
(sel == #displayString) ifTrue:[ |
4720 | 1256 |
s := CharacterWriteStream new. |
4170 | 1257 |
self displayOn:s. |
1258 |
^ s contents |
|
294
6f937c0ba907
fixes for new MethodDictionary
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
1259 |
]. |
6f937c0ba907
fixes for new MethodDictionary
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
1260 |
|
282 | 1261 |
sel == #basicInspect ifTrue:[ |
1262 |
^ InspectorView openOn:self |
|
1263 |
]. |
|
1264 |
||
1424 | 1265 |
sel == #inspectorClass ifTrue:[ |
1266 |
^ InspectorView |
|
1267 |
]. |
|
282 | 1268 |
sel == #inspect ifTrue:[ |
1269 |
^ InspectorView openOn:self |
|
1270 |
]. |
|
4327 | 1271 |
sel == #'inspectorValueListIconFor:' ifTrue:[ |
1272 |
^ (args at:1) imageFor_others |
|
1273 |
]. |
|
1274 |
self == #'inspectorValueStringInListFor:' ifTrue:[ |
|
1275 |
^ '{...}' |
|
1276 |
]. |
|
1277 |
||
282 | 1278 |
sel == #instVarAt: ifTrue:[ |
1279 |
|nr| |
|
1280 |
||
1281 |
nr := args at:1. |
|
1282 |
nr == 1 ifTrue:[^ i1]. |
|
1283 |
nr == 2 ifTrue:[^ i2]. |
|
1284 |
nr == 3 ifTrue:[^ i3]. |
|
1285 |
nr == 4 ifTrue:[^ i4]. |
|
1286 |
nr == 5 ifTrue:[^ i5]. |
|
1287 |
nr == 6 ifTrue:[^ i6]. |
|
1481 | 1288 |
nr == 7 ifTrue:[^ i7]. |
1289 |
nr == 8 ifTrue:[^ i8]. |
|
1290 |
nr == 9 ifTrue:[^ i9]. |
|
1291 |
nr == 10 ifTrue:[^ i10]. |
|
1292 |
nr == 11 ifTrue:[^ i11]. |
|
1293 |
nr == 12 ifTrue:[^ i12]. |
|
1294 |
nr == 13 ifTrue:[^ i13]. |
|
1295 |
nr == 14 ifTrue:[^ i14]. |
|
282 | 1296 |
^ nil |
1297 |
]. |
|
1298 |
||
4002 | 1299 |
(sel == #perform:) ifTrue:[ |
1129 | 1300 |
^ super perform:(args at:1) |
1301 |
]. |
|
4002 | 1302 |
(sel == #perform:with:) ifTrue:[ |
1559 | 1303 |
^ super perform:(args at:1) with:(args at:2) |
1304 |
]. |
|
1129 | 1305 |
|
4002 | 1306 |
(sel == #=) ifTrue:[ |
1130 | 1307 |
(args at:1) class == (args at:1) ifFalse:[^ false]. "/ must be another struct |
1308 |
names := self allInstVarNames. |
|
1309 |
names notNil ifTrue:[ |
|
1377
24f668298ef1
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
1243
diff
changeset
|
1310 |
Error handle:[:ex | |
1130 | 1311 |
^ false |
1312 |
] do:[ |
|
1313 |
names do:[:slotName | |
|
1314 |
((args at:1) perform:slotName asSymbol) = (self perform:slotName asSymbol) |
|
1315 |
ifFalse:[slotName halt. ^ false] |
|
1316 |
] |
|
1317 |
]. |
|
1318 |
]. |
|
1319 |
^ true. |
|
1129 | 1320 |
]. |
4002 | 1321 |
(sel == #~=) ifTrue:[ |
1129 | 1322 |
^ super ~= (args at:1) |
1323 |
]. |
|
1324 |
||
4002 | 1325 |
(sel == #size or:[sel == #basicSize]) ifTrue:[ |
282 | 1326 |
^ super basicSize |
1327 |
]. |
|
1328 |
||
4002 | 1329 |
(sel == #at: or:[sel == #basicAt:]) ifTrue:[ |
282 | 1330 |
^ super basicAt:(args at:1) |
1331 |
]. |
|
1332 |
||
4002 | 1333 |
(sel == #at:put: or:[sel == #basicAt:put:]) ifTrue:[ |
282 | 1334 |
^ super basicAt:(args at:1) put:(args at:2) |
1335 |
]. |
|
1336 |
||
1337 |
sel == #== ifTrue:[ |
|
1338 |
^ self == (args at:1) |
|
1339 |
]. |
|
1340 |
||
945 | 1341 |
sel == #clone ifTrue:[ |
1342 |
^ super clone |
|
1343 |
]. |
|
1344 |
sel == #shallowCopy ifTrue:[ |
|
1345 |
^ super shallowCopy |
|
1346 |
]. |
|
2215
8ae61b93c7eb
changed: #doesNotUnderstand: - hash
Michael Beyl <mb@exept.de>
parents:
2186
diff
changeset
|
1347 |
sel == #identityHash ifTrue:[ |
8ae61b93c7eb
changed: #doesNotUnderstand: - hash
Michael Beyl <mb@exept.de>
parents:
2186
diff
changeset
|
1348 |
^ super identityHash |
8ae61b93c7eb
changed: #doesNotUnderstand: - hash
Michael Beyl <mb@exept.de>
parents:
2186
diff
changeset
|
1349 |
]. |
4003 | 1350 |
sel == #hash ifTrue:[ |
1351 |
^ super hash |
|
1352 |
]. |
|
2186 | 1353 |
(sel == #isException) ifTrue:[ |
1354 |
^ false |
|
1355 |
]. |
|
4002 | 1356 |
(sel == #isStructure) ifTrue:[ |
1357 |
^ true |
|
1358 |
]. |
|
4003 | 1359 |
(sel == #class) ifTrue:[ |
1360 |
^ Structure |
|
1361 |
]. |
|
1362 |
(sel == #theMetaclass) ifTrue:[ |
|
1363 |
^ Structure class |
|
1364 |
]. |
|
4002 | 1365 |
|
945 | 1366 |
|
282 | 1367 |
"/ class protocol |
1368 |
||
4003 | 1369 |
(sel == #name or:[sel == #className or:[sel == #fullName or:[sel == #nameInBrowser]]]) ifTrue:[ |
4002 | 1370 |
^ #Structure |
282 | 1371 |
]. |
4003 | 1372 |
(sel == #package) ifTrue:[ |
1373 |
^ #'stx:libcomp' |
|
1374 |
]. |
|
282 | 1375 |
sel == #isVariable ifTrue:[ |
1376 |
^ false |
|
1377 |
]. |
|
3981 | 1378 |
sel == #isImmediate ifTrue:[ |
1379 |
^ false |
|
1380 |
]. |
|
4003 | 1381 |
sel == #isImage ifTrue:[ |
1382 |
^ false |
|
1383 |
]. |
|
1384 |
sel == #isFilename ifTrue:[ |
|
1385 |
^ false |
|
1386 |
]. |
|
1387 |
sel == #isLazyValue ifTrue:[ |
|
1388 |
^ false |
|
1389 |
]. |
|
282 | 1390 |
sel == #isClass ifTrue:[ |
1391 |
^ false |
|
1392 |
]. |
|
1393 |
sel == #isMeta ifTrue:[ |
|
1394 |
^ false |
|
1395 |
]. |
|
1396 |
sel == #isBehavior ifTrue:[ |
|
1397 |
^ false |
|
1398 |
]. |
|
1243 | 1399 |
sel == #isKindOf: ifTrue:[ |
1400 |
^ false |
|
1401 |
]. |
|
4002 | 1402 |
sel == #includesBehavior: ifTrue:[ |
4003 | 1403 |
^ (args at:1) == Structure or:[(args at:1) == Behavior]. |
4002 | 1404 |
]. |
2006 | 1405 |
sel == #isString ifTrue:[ |
1406 |
^ false |
|
1407 |
]. |
|
4003 | 1408 |
sel == #hasImmediateInstances ifTrue:[ |
1409 |
^ false |
|
1410 |
]. |
|
282 | 1411 |
sel == #respondsTo: ifTrue:[ |
1412 |
^ false |
|
1413 |
]. |
|
4170 | 1414 |
sel == #canUnderstand: ifTrue:[ |
1415 |
methodDictionary isNil ifTrue:[ |
|
1416 |
^ false |
|
1417 |
]. |
|
1418 |
^ methodDictionary includesKey:(args at:1). |
|
1419 |
]. |
|
616 | 1420 |
sel == #whichClassIncludesSelector: ifTrue:[ |
1421 |
^ nil |
|
1422 |
]. |
|
282 | 1423 |
sel == #evaluatorClass ifTrue:[ |
1424 |
^ Compiler |
|
1425 |
]. |
|
4003 | 1426 |
sel == #theNonMetaclass ifTrue:[ |
1427 |
^ self |
|
1428 |
]. |
|
282 | 1429 |
sel == #classNameWithArticle ifTrue:[ |
1430 |
^ self displayString |
|
1431 |
]. |
|
4068 | 1432 |
sel == #nameWithArticle ifTrue:[ |
1433 |
^ 'a Structure' |
|
1434 |
]. |
|
4003 | 1435 |
(sel == #allSubclasses or:[sel == #subclasses]) ifTrue:[ |
282 | 1436 |
^ #() |
1437 |
]. |
|
1438 |
sel == #allClassVarNames ifTrue:[ |
|
1439 |
^ #() |
|
1440 |
]. |
|
4003 | 1441 |
sel == #inspector2TabCommon ifTrue:[ |
1442 |
^ super inspector2TabForInspectorClass |
|
1443 |
]. |
|
1444 |
sel == #programmingLanguage ifTrue:[ |
|
1445 |
^ Object programmingLanguage |
|
1446 |
]. |
|
1447 |
||
1559 | 1448 |
sel == #methodDictionary ifTrue:[ |
4002 | 1449 |
^ methodDictionary |
1559 | 1450 |
]. |
282 | 1451 |
sel == #allInstVarNames ifTrue:[ |
616 | 1452 |
methodDictionary isNil ifTrue:[ |
4674 | 1453 |
Logger info:'Structure: oops - nil methodDict'. |
616 | 1454 |
^ #() |
1455 |
]. |
|
1456 |
||
282 | 1457 |
sz := super basicSize. |
1458 |
names := Array new:sz. |
|
1459 |
||
616 | 1460 |
methodDictionary keysAndValuesDo:[:sel :mthd| |
1461 |
|index mysel| |
|
1462 |
||
282 | 1463 |
(sel endsWith:$:) ifFalse:[ |
1464 |
(sel ~~ #class) ifTrue:[ |
|
1465 |
"/ |
|
1466 |
"/ which method is it ? |
|
1467 |
"/ |
|
616 | 1468 |
idx := 1. |
1469 |
[idx <= sz] whileTrue:[ |
|
1470 |
mysel := ('i' , idx printString) asSymbol. |
|
282 | 1471 |
mthd == (Structure compiledMethodAt:mysel) ifTrue:[ |
616 | 1472 |
names at:idx put:sel. |
1473 |
idx := sz. "/ break |
|
1474 |
]. |
|
1475 |
idx := idx + 1. |
|
282 | 1476 |
]. |
1477 |
] |
|
1478 |
] |
|
1479 |
]. |
|
2341
d05835f10cb8
better check for behavior compatibility
Claus Gittinger <cg@exept.de>
parents:
2215
diff
changeset
|
1480 |
|
282 | 1481 |
^ names |
1482 |
]. |
|
1483 |
||
943
5a9699ed4b9b
give the dummy class another name, to avoid confusion with
Claus Gittinger <cg@exept.de>
parents:
654
diff
changeset
|
1484 |
(sel == #instSize) ifTrue:[ |
5a9699ed4b9b
give the dummy class another name, to avoid confusion with
Claus Gittinger <cg@exept.de>
parents:
654
diff
changeset
|
1485 |
^ instSize |
5a9699ed4b9b
give the dummy class another name, to avoid confusion with
Claus Gittinger <cg@exept.de>
parents:
654
diff
changeset
|
1486 |
]. |
4169 | 1487 |
((sel startsWith:'is') or:[sel startsWith:'has']) ifTrue:[ |
4003 | 1488 |
^ false. |
1489 |
]. |
|
4248 | 1490 |
(sel == #acceptVisitor:with:) ifTrue:[ |
1491 |
^ (args at:1) visitObject:self with:(args at:2) |
|
1492 |
]. |
|
1493 |
(sel == #acceptVisitor:) ifTrue:[ |
|
1494 |
^ (args at:1) visitObject:self with:nil |
|
1495 |
]. |
|
4674 | 1496 |
Logger info:'Structure: return nil for: #%1 args %2' with:sel with:args. |
282 | 1497 |
|
294
6f937c0ba907
fixes for new MethodDictionary
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
1498 |
^ nil. |
282 | 1499 |
|
4167 | 1500 |
"Created: / 13-05-1996 / 20:22:22 / cg" |
1501 |
"Modified: / 16-07-2017 / 13:54:58 / cg" |
|
4170 | 1502 |
"Modified (format): / 24-07-2017 / 16:43:06 / stefan" |
4327 | 1503 |
"Modified: / 31-01-2019 / 23:57:16 / Claus Gittinger" |
282 | 1504 |
! ! |
1505 |
||
616 | 1506 |
!Structure class methodsFor:'documentation'! |
282 | 1507 |
|
1508 |
version |
|
3898 | 1509 |
^ '$Header$' |
2215
8ae61b93c7eb
changed: #doesNotUnderstand: - hash
Michael Beyl <mb@exept.de>
parents:
2186
diff
changeset
|
1510 |
! |
8ae61b93c7eb
changed: #doesNotUnderstand: - hash
Michael Beyl <mb@exept.de>
parents:
2186
diff
changeset
|
1511 |
|
8ae61b93c7eb
changed: #doesNotUnderstand: - hash
Michael Beyl <mb@exept.de>
parents:
2186
diff
changeset
|
1512 |
version_CVS |
3898 | 1513 |
^ '$Header$' |
282 | 1514 |
! ! |
1377
24f668298ef1
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
1243
diff
changeset
|
1515 |