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