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