author | Claus Gittinger <cg@exept.de> |
Wed, 07 Apr 2010 16:53:33 +0200 | |
changeset 2341 | d05835f10cb8 |
parent 2215 | 8ae61b93c7eb |
child 2351 | 4371af1faf81 |
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 |
2341
d05835f10cb8
better check for behavior compatibility
Claus Gittinger <cg@exept.de>
parents:
2215
diff
changeset
|
15 |
instanceVariableNames:'superclass flags methodDictionary lookupFunction instSize i1 i2 i3 i4 i5 i6 i7 |
d05835f10cb8
better check for behavior compatibility
Claus Gittinger <cg@exept.de>
parents:
2215
diff
changeset
|
16 |
i8 i9 i10 i11 i12 i13 i14 i15 i16 i17 i18 i19 i20 i21 i22 i23 i24 |
d05835f10cb8
better check for behavior compatibility
Claus Gittinger <cg@exept.de>
parents:
2215
diff
changeset
|
17 |
i25 i26 i27 i28 i29 i30 i31 i32 i33 i34 i35 i36 i37 i38 i39 i40 |
d05835f10cb8
better check for behavior compatibility
Claus Gittinger <cg@exept.de>
parents:
2215
diff
changeset
|
18 |
i41 i42 i43 i44 i45 i46 i47 i48 i49 i50' |
d05835f10cb8
better check for behavior compatibility
Claus Gittinger <cg@exept.de>
parents:
2215
diff
changeset
|
19 |
classVariableNames:'OneInstance DummyClass ReadAccessMethods WriteAccessMethods |
d05835f10cb8
better check for behavior compatibility
Claus Gittinger <cg@exept.de>
parents:
2215
diff
changeset
|
20 |
OtherMethods OtherSelectors' |
d05835f10cb8
better check for behavior compatibility
Claus Gittinger <cg@exept.de>
parents:
2215
diff
changeset
|
21 |
poolDictionaries:'' |
d05835f10cb8
better check for behavior compatibility
Claus Gittinger <cg@exept.de>
parents:
2215
diff
changeset
|
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| |
145 |
m := self compiledMethodAt:('i', i printString , ':') asSymbol. |
|
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]. |
|
214 |
sels := sels , (names collect:[:nm | (nm , ':') asSymbol]). |
|
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). |
282 | 228 |
arr at:1 put:nil. "/ superclass |
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 |
2341
d05835f10cb8
better check for behavior compatibility
Claus Gittinger <cg@exept.de>
parents:
2215
diff
changeset
|
231 |
arr at:4 put:behviorsInstSize. "/ instSize |
294
6f937c0ba907
fixes for new MethodDictionary
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
232 |
|
6f937c0ba907
fixes for new MethodDictionary
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
233 |
"/ now, the big trick ... |
282 | 234 |
|
235 |
arr changeClassTo:DummyClass. |
|
236 |
arr changeClassTo:arr. |
|
237 |
||
238 |
values notNil ifTrue:[ |
|
239 |
values keysAndValuesDo:[:i :val | |
|
240 |
arr at:i put:val |
|
241 |
] |
|
242 |
]. |
|
243 |
||
2341
d05835f10cb8
better check for behavior compatibility
Claus Gittinger <cg@exept.de>
parents:
2215
diff
changeset
|
244 |
^ arr. |
282 | 245 |
|
246 |
" |
|
247 |
Structure newWith:#(foo bar) values:#('foo' 'bar') |
|
248 |
" |
|
249 |
||
250 |
"Created: 13.5.1996 / 20:03:42 / cg" |
|
294
6f937c0ba907
fixes for new MethodDictionary
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
251 |
"Modified: 3.7.1996 / 10:24:43 / cg" |
282 | 252 |
! |
253 |
||
254 |
with:assoc |
|
255 |
"return a new structure with a single field, named to the assocs key, |
|
256 |
and initialized with assocs value." |
|
257 |
||
258 |
^ self newWith:(Array with:assoc key) values:(Array with:assoc value) |
|
259 |
||
260 |
" |
|
261 |
Structure with:#foo->'foo' |
|
262 |
" |
|
263 |
! |
|
264 |
||
265 |
with:assoc1 with:assoc2 |
|
266 |
"return a new structure with two fields, named as defined by the arguments' |
|
267 |
keys, and and initialized with the assocs' values." |
|
268 |
||
2341
d05835f10cb8
better check for behavior compatibility
Claus Gittinger <cg@exept.de>
parents:
2215
diff
changeset
|
269 |
^ self newWith:(Array with:assoc1 key with:assoc2 key) |
294
6f937c0ba907
fixes for new MethodDictionary
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
270 |
values:(Array with:assoc1 value with:assoc2 value) |
282 | 271 |
|
272 |
" |
|
273 |
Structure with:#foo->'foo' with:#bar->'bar' |
|
274 |
" |
|
275 |
! |
|
276 |
||
277 |
with:assoc1 with:assoc2 with:assoc3 |
|
278 |
"return a new structure with three fields, named as defined by the arguments' |
|
279 |
keys, and and initialized with the assocs' values." |
|
280 |
||
2341
d05835f10cb8
better check for behavior compatibility
Claus Gittinger <cg@exept.de>
parents:
2215
diff
changeset
|
281 |
^ self newWith:(Array with:assoc1 key with:assoc2 key with:assoc3 key) |
294
6f937c0ba907
fixes for new MethodDictionary
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
282 |
values:(Array with:assoc1 value with:assoc2 value with:assoc3 value) |
282 | 283 |
|
284 |
" |
|
285 |
Structure with:#foo->'foo' with:#bar->'bar' with:#baz->'baz' |
|
286 |
" |
|
287 |
! |
|
288 |
||
289 |
with:assoc1 with:assoc2 with:assoc3 with:assoc4 |
|
290 |
"return a new structure with four fields, named as defined by the arguments' |
|
291 |
keys, and and initialized with the assocs' values." |
|
292 |
||
2341
d05835f10cb8
better check for behavior compatibility
Claus Gittinger <cg@exept.de>
parents:
2215
diff
changeset
|
293 |
^ self newWith:(Array with:assoc1 key with:assoc2 key |
d05835f10cb8
better check for behavior compatibility
Claus Gittinger <cg@exept.de>
parents:
2215
diff
changeset
|
294 |
with:assoc3 key with:assoc4 key) |
d05835f10cb8
better check for behavior compatibility
Claus Gittinger <cg@exept.de>
parents:
2215
diff
changeset
|
295 |
values:(Array with:assoc1 value with:assoc2 value |
294
6f937c0ba907
fixes for new MethodDictionary
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
296 |
with:assoc3 value with:assoc4 value) |
282 | 297 |
|
298 |
" |
|
299 |
Structure with:#foo->'foo' with:#bar->'bar' with:#baz->'baz' with:#hello->'hello' |
|
300 |
" |
|
301 |
! |
|
302 |
||
303 |
with:assoc1 with:assoc2 with:assoc3 with:assoc4 with:assoc5 |
|
304 |
"return a new structure with five 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 |
with:assoc5 key) |
d05835f10cb8
better check for behavior compatibility
Claus Gittinger <cg@exept.de>
parents:
2215
diff
changeset
|
310 |
values:(Array with:assoc1 value with:assoc2 value |
d05835f10cb8
better check for behavior compatibility
Claus Gittinger <cg@exept.de>
parents:
2215
diff
changeset
|
311 |
with:assoc3 value with:assoc4 value |
282 | 312 |
with:assoc5 value) |
313 |
||
314 |
" |
|
315 |
Structure with:#foo->'foo' with:#bar->'bar' with:#baz->'baz' with:#hello->'hello' with:#world->'world' |
|
316 |
" |
|
1131 | 317 |
! |
318 |
||
319 |
with:assoc1 with:assoc2 with:assoc3 with:assoc4 with:assoc5 with:assoc6 |
|
320 |
"return a new structure with five fields, named as defined by the arguments' |
|
321 |
keys, and and initialized with the assocs' values." |
|
322 |
||
2341
d05835f10cb8
better check for behavior compatibility
Claus Gittinger <cg@exept.de>
parents:
2215
diff
changeset
|
323 |
^ self newWith:(Array with:assoc1 key with:assoc2 key |
d05835f10cb8
better check for behavior compatibility
Claus Gittinger <cg@exept.de>
parents:
2215
diff
changeset
|
324 |
with:assoc3 key with:assoc4 key |
d05835f10cb8
better check for behavior compatibility
Claus Gittinger <cg@exept.de>
parents:
2215
diff
changeset
|
325 |
with:assoc5 key with:assoc6 key) |
d05835f10cb8
better check for behavior compatibility
Claus Gittinger <cg@exept.de>
parents:
2215
diff
changeset
|
326 |
values:(Array with:assoc1 value with:assoc2 value |
d05835f10cb8
better check for behavior compatibility
Claus Gittinger <cg@exept.de>
parents:
2215
diff
changeset
|
327 |
with:assoc3 value with:assoc4 value |
1131 | 328 |
with:assoc5 value with:assoc6 value) |
329 |
||
330 |
" |
|
331 |
Structure with:#foo->'foo' with:#bar->'bar' with:#baz->'baz' with:#hello->'hello' with:#world->'world' |
|
332 |
" |
|
333 |
! |
|
334 |
||
335 |
with:assoc1 with:assoc2 with:assoc3 with:assoc4 with:assoc5 with:assoc6 with:assoc7 |
|
336 |
"return a new structure with five fields, named as defined by the arguments' |
|
337 |
keys, and and initialized with the assocs' values." |
|
338 |
||
2341
d05835f10cb8
better check for behavior compatibility
Claus Gittinger <cg@exept.de>
parents:
2215
diff
changeset
|
339 |
^ self newWith:(Array with:assoc1 key with:assoc2 key |
d05835f10cb8
better check for behavior compatibility
Claus Gittinger <cg@exept.de>
parents:
2215
diff
changeset
|
340 |
with:assoc3 key with:assoc4 key |
1131 | 341 |
with:assoc5 key with:assoc6 key |
2341
d05835f10cb8
better check for behavior compatibility
Claus Gittinger <cg@exept.de>
parents:
2215
diff
changeset
|
342 |
with:assoc7 key) |
d05835f10cb8
better check for behavior compatibility
Claus Gittinger <cg@exept.de>
parents:
2215
diff
changeset
|
343 |
values:(Array with:assoc1 value with:assoc2 value |
d05835f10cb8
better check for behavior compatibility
Claus Gittinger <cg@exept.de>
parents:
2215
diff
changeset
|
344 |
with:assoc3 value with:assoc4 value |
1131 | 345 |
with:assoc5 value with:assoc6 value |
346 |
with:assoc7 value) |
|
347 |
||
348 |
" |
|
349 |
Structure with:#foo->'foo' with:#bar->'bar' with:#baz->'baz' with:#hello->'hello' with:#world->'world' |
|
350 |
" |
|
282 | 351 |
! ! |
352 |
||
616 | 353 |
!Structure class methodsFor:'special'! |
354 |
||
355 |
primAddSelector:newSelector withMethod:newMethod |
|
356 |
"must reinit myself when methods are accepted." |
|
357 |
||
358 |
|val| |
|
359 |
||
360 |
val := super primAddSelector:newSelector withMethod:newMethod. |
|
361 |
OneInstance := nil. |
|
362 |
self initialize. |
|
363 |
^ val |
|
364 |
! ! |
|
365 |
||
282 | 366 |
!Structure methodsFor:'accessing'! |
367 |
||
368 |
flags |
|
369 |
"return the flags - required class protocol" |
|
370 |
||
371 |
^ flags |
|
372 |
||
373 |
"Created: 13.5.1996 / 21:19:23 / cg" |
|
374 |
! |
|
375 |
||
376 |
flags:something |
|
377 |
"set the flags - required class protocol" |
|
378 |
||
379 |
flags := something. |
|
380 |
||
381 |
"Created: 13.5.1996 / 21:19:23 / cg" |
|
382 |
! |
|
383 |
||
384 |
i1 |
|
616 | 385 |
"prototype method to return the first instance variable" |
282 | 386 |
|
387 |
^ i1 |
|
388 |
||
389 |
"Created: 13.5.1996 / 21:19:25 / cg" |
|
390 |
! |
|
391 |
||
392 |
i10 |
|
616 | 393 |
"prototype method to return the 10th instance variable" |
282 | 394 |
|
395 |
^ i10 |
|
396 |
||
397 |
"Created: 13.5.1996 / 21:19:27 / cg" |
|
398 |
! |
|
399 |
||
400 |
i10:something |
|
616 | 401 |
"prototype method to set the 10th instance variable" |
282 | 402 |
|
403 |
i10 := something. |
|
404 |
||
405 |
"Created: 13.5.1996 / 21:19:27 / cg" |
|
406 |
! |
|
407 |
||
408 |
i11 |
|
409 |
"return i11" |
|
410 |
||
411 |
^ i11 |
|
412 |
||
413 |
"Created: 13.5.1996 / 21:19:27 / cg" |
|
414 |
! |
|
415 |
||
416 |
i11:something |
|
616 | 417 |
"prototype method to set the 11th instance variable" |
282 | 418 |
|
419 |
i11 := something. |
|
420 |
||
421 |
"Created: 13.5.1996 / 21:19:27 / cg" |
|
422 |
! |
|
423 |
||
424 |
i12 |
|
425 |
"return i12" |
|
426 |
||
427 |
^ i12 |
|
428 |
||
429 |
"Created: 13.5.1996 / 21:19:27 / cg" |
|
430 |
! |
|
431 |
||
432 |
i12:something |
|
433 |
"set i12" |
|
434 |
||
435 |
i12 := something. |
|
436 |
||
437 |
"Created: 13.5.1996 / 21:19:27 / cg" |
|
438 |
! |
|
439 |
||
440 |
i13 |
|
441 |
"return i13" |
|
442 |
||
443 |
^ i13 |
|
444 |
||
445 |
"Created: 13.5.1996 / 21:19:28 / cg" |
|
446 |
! |
|
447 |
||
448 |
i13:something |
|
449 |
"set i13" |
|
450 |
||
451 |
i13 := something. |
|
452 |
||
453 |
"Created: 13.5.1996 / 21:19:28 / cg" |
|
454 |
! |
|
455 |
||
456 |
i14 |
|
457 |
"return i14" |
|
458 |
||
459 |
^ i14 |
|
460 |
||
461 |
"Created: 13.5.1996 / 21:19:28 / cg" |
|
462 |
! |
|
463 |
||
464 |
i14:something |
|
465 |
"set i14" |
|
466 |
||
467 |
i14 := something. |
|
468 |
||
469 |
"Created: 13.5.1996 / 21:19:28 / cg" |
|
470 |
! |
|
471 |
||
472 |
i15 |
|
473 |
"return i15" |
|
474 |
||
475 |
^ i15 |
|
476 |
||
477 |
"Created: 13.5.1996 / 21:19:28 / cg" |
|
478 |
! |
|
479 |
||
480 |
i15:something |
|
481 |
"set i15" |
|
482 |
||
483 |
i15 := something. |
|
484 |
||
485 |
"Created: 13.5.1996 / 21:19:28 / cg" |
|
486 |
! |
|
487 |
||
488 |
i16 |
|
489 |
"return i16" |
|
490 |
||
491 |
^ i16 |
|
492 |
||
493 |
"Created: 13.5.1996 / 21:19:28 / cg" |
|
494 |
! |
|
495 |
||
496 |
i16:something |
|
497 |
"set i16" |
|
498 |
||
499 |
i16 := something. |
|
500 |
||
501 |
"Created: 13.5.1996 / 21:19:28 / cg" |
|
502 |
! |
|
503 |
||
504 |
i17 |
|
505 |
"return i17" |
|
506 |
||
507 |
^ i17 |
|
508 |
||
509 |
"Created: 13.5.1996 / 21:19:28 / cg" |
|
510 |
! |
|
511 |
||
512 |
i17:something |
|
513 |
"set i17" |
|
514 |
||
515 |
i17 := something. |
|
516 |
||
517 |
"Created: 13.5.1996 / 21:19:29 / cg" |
|
518 |
! |
|
519 |
||
520 |
i18 |
|
521 |
"return i18" |
|
522 |
||
523 |
^ i18 |
|
524 |
||
525 |
"Created: 13.5.1996 / 21:19:29 / cg" |
|
526 |
! |
|
527 |
||
528 |
i18:something |
|
529 |
"set i18" |
|
530 |
||
531 |
i18 := something. |
|
532 |
||
533 |
"Created: 13.5.1996 / 21:19:29 / cg" |
|
534 |
! |
|
535 |
||
536 |
i19 |
|
537 |
"return i19" |
|
538 |
||
539 |
^ i19 |
|
540 |
||
541 |
"Created: 13.5.1996 / 21:19:29 / cg" |
|
542 |
! |
|
543 |
||
544 |
i19:something |
|
545 |
"set i19" |
|
546 |
||
547 |
i19 := something. |
|
548 |
||
549 |
"Created: 13.5.1996 / 21:19:29 / cg" |
|
550 |
! |
|
551 |
||
552 |
i1:something |
|
616 | 553 |
"prototype method to set the 1st instance variable" |
282 | 554 |
|
555 |
i1 := something. |
|
556 |
||
557 |
"Created: 13.5.1996 / 21:19:25 / cg" |
|
558 |
! |
|
559 |
||
560 |
i2 |
|
616 | 561 |
"prototype method to return the 2nd instance variable" |
282 | 562 |
|
563 |
^ i2 |
|
564 |
||
565 |
"Created: 13.5.1996 / 21:19:25 / cg" |
|
566 |
! |
|
567 |
||
568 |
i20 |
|
569 |
"return i20" |
|
570 |
||
571 |
^ i20 |
|
572 |
||
573 |
"Created: 13.5.1996 / 21:19:29 / cg" |
|
574 |
! |
|
575 |
||
576 |
i20:something |
|
577 |
"set i20" |
|
578 |
||
579 |
i20 := something. |
|
580 |
||
581 |
"Created: 13.5.1996 / 21:19:29 / cg" |
|
582 |
! |
|
583 |
||
343 | 584 |
i21 |
585 |
"return i21" |
|
586 |
||
587 |
^ i21 |
|
588 |
||
589 |
"Created: 21.9.1996 / 16:06:21 / cg" |
|
590 |
! |
|
591 |
||
592 |
i21:something |
|
593 |
"set i21" |
|
594 |
||
595 |
i21 := something. |
|
596 |
||
597 |
"Created: 21.9.1996 / 16:06:21 / cg" |
|
598 |
! |
|
599 |
||
600 |
i22 |
|
601 |
"return i22" |
|
602 |
||
603 |
^ i22 |
|
604 |
||
605 |
"Created: 21.9.1996 / 16:06:21 / cg" |
|
606 |
! |
|
607 |
||
608 |
i22:something |
|
609 |
"set i22" |
|
610 |
||
611 |
i22 := something. |
|
612 |
||
613 |
"Created: 21.9.1996 / 16:06:21 / cg" |
|
614 |
! |
|
615 |
||
616 |
i23 |
|
617 |
"return i23" |
|
618 |
||
619 |
^ i23 |
|
620 |
||
621 |
"Created: 21.9.1996 / 16:06:21 / cg" |
|
622 |
! |
|
623 |
||
624 |
i23:something |
|
625 |
"set i23" |
|
626 |
||
627 |
i23 := something. |
|
628 |
||
629 |
"Created: 21.9.1996 / 16:06:21 / cg" |
|
630 |
! |
|
631 |
||
632 |
i24 |
|
633 |
"return i24" |
|
634 |
||
635 |
^ i24 |
|
636 |
||
637 |
"Created: 21.9.1996 / 16:06:21 / cg" |
|
638 |
! |
|
639 |
||
640 |
i24:something |
|
641 |
"set i24" |
|
642 |
||
643 |
i24 := something. |
|
644 |
||
645 |
"Created: 21.9.1996 / 16:06:21 / cg" |
|
646 |
! |
|
647 |
||
648 |
i25 |
|
649 |
"return i25" |
|
650 |
||
651 |
^ i25 |
|
652 |
||
653 |
"Created: 21.9.1996 / 16:06:21 / cg" |
|
654 |
! |
|
655 |
||
656 |
i25:something |
|
657 |
"set i25" |
|
658 |
||
659 |
i25 := something. |
|
660 |
||
661 |
"Created: 21.9.1996 / 16:06:22 / cg" |
|
662 |
! |
|
663 |
||
664 |
i26 |
|
665 |
"return i26" |
|
666 |
||
667 |
^ i26 |
|
668 |
||
669 |
"Created: 21.9.1996 / 16:06:22 / cg" |
|
670 |
! |
|
671 |
||
672 |
i26:something |
|
673 |
"set i26" |
|
674 |
||
675 |
i26 := something. |
|
676 |
||
677 |
"Created: 21.9.1996 / 16:06:22 / cg" |
|
678 |
! |
|
679 |
||
680 |
i27 |
|
681 |
"return i27" |
|
682 |
||
683 |
^ i27 |
|
684 |
||
685 |
"Created: 21.9.1996 / 16:06:22 / cg" |
|
686 |
! |
|
687 |
||
688 |
i27:something |
|
689 |
"set i27" |
|
690 |
||
691 |
i27 := something. |
|
692 |
||
693 |
"Created: 21.9.1996 / 16:06:22 / cg" |
|
694 |
! |
|
695 |
||
696 |
i28 |
|
697 |
"return i28" |
|
698 |
||
699 |
^ i28 |
|
700 |
||
701 |
"Created: 21.9.1996 / 16:06:22 / cg" |
|
702 |
! |
|
703 |
||
704 |
i28:something |
|
705 |
"set i28" |
|
706 |
||
707 |
i28 := something. |
|
708 |
||
709 |
"Created: 21.9.1996 / 16:06:22 / cg" |
|
710 |
! |
|
711 |
||
712 |
i29 |
|
713 |
"return i29" |
|
714 |
||
715 |
^ i29 |
|
716 |
||
717 |
"Created: 21.9.1996 / 16:06:22 / cg" |
|
718 |
! |
|
719 |
||
720 |
i29:something |
|
721 |
"set i29" |
|
722 |
||
723 |
i29 := something. |
|
724 |
||
725 |
"Created: 21.9.1996 / 16:06:22 / cg" |
|
726 |
! |
|
727 |
||
282 | 728 |
i2:something |
616 | 729 |
"prototype method to set the 2nd instance variable" |
282 | 730 |
|
731 |
i2 := something. |
|
732 |
||
733 |
"Created: 13.5.1996 / 21:19:25 / cg" |
|
734 |
! |
|
735 |
||
736 |
i3 |
|
616 | 737 |
"prototype method to return the 3rd instance variable" |
282 | 738 |
|
739 |
^ i3 |
|
740 |
||
741 |
"Created: 13.5.1996 / 21:19:25 / cg" |
|
742 |
! |
|
743 |
||
343 | 744 |
i30:something |
745 |
"set i30" |
|
746 |
||
747 |
i30 := something. |
|
748 |
||
749 |
"Created: 21.9.1996 / 16:06:22 / cg" |
|
750 |
! |
|
751 |
||
752 |
i31 |
|
753 |
"return i31" |
|
754 |
||
755 |
^ i31 |
|
756 |
||
757 |
"Created: 21.9.1996 / 16:06:22 / cg" |
|
758 |
! |
|
759 |
||
760 |
i31:something |
|
761 |
"set i31" |
|
762 |
||
763 |
i31 := something. |
|
764 |
||
765 |
"Created: 21.9.1996 / 16:06:22 / cg" |
|
766 |
! |
|
767 |
||
768 |
i32 |
|
769 |
"return i32" |
|
770 |
||
771 |
^ i32 |
|
772 |
||
773 |
"Created: 21.9.1996 / 16:06:22 / cg" |
|
774 |
! |
|
775 |
||
776 |
i32:something |
|
777 |
"set i32" |
|
778 |
||
779 |
i32 := something. |
|
780 |
||
781 |
"Created: 21.9.1996 / 16:06:22 / cg" |
|
782 |
! |
|
783 |
||
784 |
i33 |
|
785 |
"return i33" |
|
786 |
||
787 |
^ i33 |
|
788 |
||
789 |
"Created: 21.9.1996 / 16:06:22 / cg" |
|
790 |
! |
|
791 |
||
792 |
i33:something |
|
793 |
"set i33" |
|
794 |
||
795 |
i33 := something. |
|
796 |
||
797 |
"Created: 21.9.1996 / 16:06:22 / cg" |
|
798 |
! |
|
799 |
||
800 |
i34 |
|
801 |
"return i34" |
|
802 |
||
803 |
^ i34 |
|
804 |
||
805 |
"Created: 21.9.1996 / 16:06:22 / cg" |
|
806 |
! |
|
807 |
||
808 |
i34:something |
|
809 |
"set i34" |
|
810 |
||
811 |
i34 := something. |
|
812 |
||
813 |
"Created: 21.9.1996 / 16:06:22 / cg" |
|
814 |
! |
|
815 |
||
816 |
i35 |
|
817 |
"return i35" |
|
818 |
||
819 |
^ i35 |
|
820 |
||
821 |
"Created: 21.9.1996 / 16:06:22 / cg" |
|
822 |
! |
|
823 |
||
824 |
i35:something |
|
825 |
"set i35" |
|
826 |
||
827 |
i35 := something. |
|
828 |
||
829 |
"Created: 21.9.1996 / 16:06:22 / cg" |
|
830 |
! |
|
831 |
||
832 |
i36 |
|
833 |
"return i36" |
|
834 |
||
835 |
^ i36 |
|
836 |
||
837 |
"Created: 21.9.1996 / 16:06:22 / cg" |
|
838 |
! |
|
839 |
||
840 |
i36:something |
|
841 |
"set i36" |
|
842 |
||
843 |
i36 := something. |
|
844 |
||
845 |
"Created: 21.9.1996 / 16:06:22 / cg" |
|
846 |
! |
|
847 |
||
848 |
i37 |
|
849 |
"return i37" |
|
850 |
||
851 |
^ i37 |
|
852 |
||
853 |
"Created: 21.9.1996 / 16:06:22 / cg" |
|
854 |
! |
|
855 |
||
856 |
i37:something |
|
857 |
"set i37" |
|
858 |
||
859 |
i37 := something. |
|
860 |
||
861 |
"Created: 21.9.1996 / 16:06:22 / cg" |
|
862 |
! |
|
863 |
||
864 |
i38 |
|
865 |
"return i38" |
|
866 |
||
867 |
^ i38 |
|
868 |
||
869 |
"Created: 21.9.1996 / 16:06:22 / cg" |
|
870 |
! |
|
871 |
||
872 |
i38:something |
|
873 |
"set i38" |
|
874 |
||
875 |
i38 := something. |
|
876 |
||
877 |
"Created: 21.9.1996 / 16:06:22 / cg" |
|
878 |
! |
|
879 |
||
880 |
i39 |
|
881 |
"return i39" |
|
882 |
||
883 |
^ i39 |
|
884 |
||
885 |
"Created: 21.9.1996 / 16:06:22 / cg" |
|
886 |
! |
|
887 |
||
888 |
i39:something |
|
889 |
"set i39" |
|
890 |
||
891 |
i39 := something. |
|
892 |
||
893 |
"Created: 21.9.1996 / 16:06:22 / cg" |
|
894 |
! |
|
895 |
||
282 | 896 |
i3:something |
616 | 897 |
"prototype method to set the 3rd instance variable" |
282 | 898 |
|
899 |
i3 := something. |
|
900 |
||
901 |
"Created: 13.5.1996 / 21:19:25 / cg" |
|
902 |
! |
|
903 |
||
904 |
i4 |
|
616 | 905 |
"prototype method to return the 4th instance variable" |
282 | 906 |
|
907 |
^ i4 |
|
908 |
||
909 |
"Created: 13.5.1996 / 21:19:25 / cg" |
|
910 |
! |
|
911 |
||
616 | 912 |
i40 |
913 |
"return the value of the instance variable 'i40' (automatically generated)" |
|
914 |
||
1129 | 915 |
^ i40 |
916 |
! |
|
616 | 917 |
|
343 | 918 |
i40:something |
616 | 919 |
"prototype method" |
343 | 920 |
|
921 |
i40 := something. |
|
922 |
||
923 |
"Created: 21.9.1996 / 16:06:22 / cg" |
|
924 |
! |
|
925 |
||
926 |
i41 |
|
616 | 927 |
"prototype method" |
343 | 928 |
|
929 |
^ i41 |
|
930 |
||
931 |
"Created: 21.9.1996 / 16:06:23 / cg" |
|
932 |
! |
|
933 |
||
934 |
i41:something |
|
616 | 935 |
"prototype method" |
343 | 936 |
|
937 |
i41 := something. |
|
938 |
||
939 |
"Created: 21.9.1996 / 16:06:23 / cg" |
|
940 |
! |
|
941 |
||
942 |
i42 |
|
616 | 943 |
"prototype method" |
343 | 944 |
|
945 |
^ i42 |
|
946 |
||
947 |
"Created: 21.9.1996 / 16:06:23 / cg" |
|
948 |
! |
|
949 |
||
950 |
i42:something |
|
616 | 951 |
"prototype method" |
343 | 952 |
|
953 |
i42 := something. |
|
954 |
||
955 |
"Created: 21.9.1996 / 16:06:23 / cg" |
|
956 |
! |
|
957 |
||
958 |
i43 |
|
616 | 959 |
"prototype method" |
343 | 960 |
|
961 |
^ i43 |
|
962 |
||
963 |
"Created: 21.9.1996 / 16:06:23 / cg" |
|
964 |
! |
|
965 |
||
966 |
i43:something |
|
616 | 967 |
"prototype method" |
343 | 968 |
|
969 |
i43 := something. |
|
970 |
||
971 |
"Created: 21.9.1996 / 16:06:23 / cg" |
|
972 |
! |
|
973 |
||
974 |
i44 |
|
616 | 975 |
"prototype method" |
343 | 976 |
|
977 |
^ i44 |
|
978 |
||
979 |
"Created: 21.9.1996 / 16:06:23 / cg" |
|
980 |
! |
|
981 |
||
982 |
i44:something |
|
616 | 983 |
"prototype method" |
343 | 984 |
|
985 |
i44 := something. |
|
986 |
||
987 |
"Created: 21.9.1996 / 16:06:23 / cg" |
|
988 |
! |
|
989 |
||
990 |
i45 |
|
616 | 991 |
"prototype method" |
343 | 992 |
|
993 |
^ i45 |
|
994 |
||
995 |
"Created: 21.9.1996 / 16:06:23 / cg" |
|
996 |
! |
|
997 |
||
998 |
i45:something |
|
616 | 999 |
"prototype method" |
343 | 1000 |
|
1001 |
i45 := something. |
|
1002 |
||
1003 |
"Created: 21.9.1996 / 16:06:23 / cg" |
|
1004 |
! |
|
1005 |
||
1006 |
i46 |
|
616 | 1007 |
"prototype method" |
343 | 1008 |
|
1009 |
^ i46 |
|
1010 |
||
1011 |
"Created: 21.9.1996 / 16:06:23 / cg" |
|
1012 |
! |
|
1013 |
||
1014 |
i46:something |
|
616 | 1015 |
"prototype method" |
343 | 1016 |
|
1017 |
i46 := something. |
|
1018 |
||
1019 |
"Created: 21.9.1996 / 16:06:23 / cg" |
|
1020 |
! |
|
1021 |
||
1022 |
i47 |
|
616 | 1023 |
"prototype method" |
343 | 1024 |
|
1025 |
^ i47 |
|
1026 |
||
1027 |
"Created: 21.9.1996 / 16:06:23 / cg" |
|
1028 |
! |
|
1029 |
||
1030 |
i47:something |
|
616 | 1031 |
"prototype method" |
343 | 1032 |
|
1033 |
i47 := something. |
|
1034 |
||
1035 |
"Created: 21.9.1996 / 16:06:23 / cg" |
|
1036 |
! |
|
1037 |
||
1038 |
i48 |
|
616 | 1039 |
"prototype method" |
343 | 1040 |
|
1041 |
^ i48 |
|
1042 |
||
1043 |
"Created: 21.9.1996 / 16:06:23 / cg" |
|
1044 |
! |
|
1045 |
||
1046 |
i48:something |
|
616 | 1047 |
"prototype method" |
343 | 1048 |
|
1049 |
i48 := something. |
|
1050 |
||
1051 |
"Created: 21.9.1996 / 16:06:23 / cg" |
|
1052 |
! |
|
1053 |
||
1054 |
i49 |
|
616 | 1055 |
"prototype method" |
343 | 1056 |
|
1057 |
^ i49 |
|
1058 |
||
1059 |
"Created: 21.9.1996 / 16:06:23 / cg" |
|
1060 |
! |
|
1061 |
||
1062 |
i49:something |
|
616 | 1063 |
"prototype method" |
343 | 1064 |
|
1065 |
i49 := something. |
|
1066 |
||
1067 |
"Created: 21.9.1996 / 16:06:24 / cg" |
|
1068 |
! |
|
1069 |
||
282 | 1070 |
i4:something |
616 | 1071 |
"prototype method to set the 4th instance variable" |
282 | 1072 |
|
1073 |
i4 := something. |
|
1074 |
||
1075 |
"Created: 13.5.1996 / 21:19:25 / cg" |
|
1076 |
! |
|
1077 |
||
1078 |
i5 |
|
616 | 1079 |
"prototype method to return the 5th instance variable" |
282 | 1080 |
|
1081 |
^ i5 |
|
1082 |
||
1083 |
"Created: 13.5.1996 / 21:19:26 / cg" |
|
1084 |
! |
|
1085 |
||
343 | 1086 |
i50 |
616 | 1087 |
"prototype method" |
343 | 1088 |
|
1089 |
^ i50 |
|
1090 |
||
1091 |
"Created: 21.9.1996 / 16:06:24 / cg" |
|
1092 |
! |
|
1093 |
||
1094 |
i50:something |
|
616 | 1095 |
"prototype method" |
343 | 1096 |
|
1097 |
i50 := something. |
|
1098 |
||
1099 |
"Created: 21.9.1996 / 16:06:24 / cg" |
|
1100 |
! |
|
1101 |
||
282 | 1102 |
i5:something |
616 | 1103 |
"prototype method to set the 5th instance variable" |
282 | 1104 |
|
1105 |
i5 := something. |
|
1106 |
||
1107 |
"Created: 13.5.1996 / 21:19:26 / cg" |
|
1108 |
! |
|
1109 |
||
1110 |
i6 |
|
616 | 1111 |
"prototype method to return the 6th instance variable" |
282 | 1112 |
|
1113 |
^ i6 |
|
1114 |
||
1115 |
"Created: 13.5.1996 / 21:19:26 / cg" |
|
1116 |
! |
|
1117 |
||
1118 |
i6:something |
|
616 | 1119 |
"prototype method to set the 6th instance variable" |
282 | 1120 |
|
1121 |
i6 := something. |
|
1122 |
||
1123 |
"Created: 13.5.1996 / 21:19:26 / cg" |
|
1124 |
! |
|
1125 |
||
1126 |
i7 |
|
616 | 1127 |
"prototype method to return the 7th instance variable" |
282 | 1128 |
|
1129 |
^ i7 |
|
1130 |
||
1131 |
"Created: 13.5.1996 / 21:19:26 / cg" |
|
1132 |
! |
|
1133 |
||
1134 |
i7:something |
|
616 | 1135 |
"prototype method to set the 7th instance variable" |
282 | 1136 |
|
1137 |
i7 := something. |
|
1138 |
||
1139 |
"Created: 13.5.1996 / 21:19:26 / cg" |
|
1140 |
! |
|
1141 |
||
1142 |
i8 |
|
616 | 1143 |
"prototype method to return the 8th instance variable" |
282 | 1144 |
|
1145 |
^ i8 |
|
1146 |
||
1147 |
"Created: 13.5.1996 / 21:19:26 / cg" |
|
1148 |
! |
|
1149 |
||
1150 |
i8:something |
|
616 | 1151 |
"prototype method to set the 8th instance variable" |
282 | 1152 |
|
1153 |
i8 := something. |
|
1154 |
||
1155 |
"Created: 13.5.1996 / 21:19:26 / cg" |
|
1156 |
! |
|
1157 |
||
1158 |
i9 |
|
616 | 1159 |
"prototype method to return the 9th instance variable" |
282 | 1160 |
|
1161 |
^ i9 |
|
1162 |
||
1163 |
"Created: 13.5.1996 / 21:19:26 / cg" |
|
1164 |
! |
|
1165 |
||
1166 |
i9:something |
|
616 | 1167 |
"prototype method to set the 9th instance variable" |
282 | 1168 |
|
1169 |
i9 := something. |
|
1170 |
||
1171 |
"Created: 13.5.1996 / 21:19:27 / cg" |
|
1172 |
! |
|
1173 |
||
1174 |
instSize |
|
1175 |
"return instSize - required class protocol" |
|
1176 |
||
1177 |
^ instSize |
|
1178 |
||
1179 |
"Created: 13.5.1996 / 21:19:24 / cg" |
|
1180 |
! |
|
1181 |
||
1182 |
instSize:something |
|
1183 |
"set instSize - required class protocol" |
|
1184 |
||
1185 |
instSize := something. |
|
1186 |
||
1187 |
"Created: 13.5.1996 / 21:19:25 / cg" |
|
1188 |
! |
|
1189 |
||
429 | 1190 |
methodDictionary |
1191 |
"return the methodDictionary - required class protocol" |
|
282 | 1192 |
|
429 | 1193 |
^ methodDictionary |
282 | 1194 |
! |
1195 |
||
1196 |
superclass |
|
1197 |
"return superclass - required class protocol" |
|
1198 |
||
1199 |
^ superclass |
|
1200 |
||
1201 |
"Created: 13.5.1996 / 21:19:23 / cg" |
|
1202 |
! |
|
1203 |
||
1204 |
superclass:something |
|
1205 |
"set superclass - required class protocol" |
|
1206 |
||
1207 |
superclass := something. |
|
1208 |
||
1209 |
"Created: 13.5.1996 / 21:19:23 / cg" |
|
1210 |
! ! |
|
1211 |
||
1212 |
!Structure methodsFor:'stubs'! |
|
1213 |
||
1214 |
doesNotUnderstand:aMessage |
|
294
6f937c0ba907
fixes for new MethodDictionary
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
1215 |
"catch unimplemented messages - pass some to the superclass. |
6f937c0ba907
fixes for new MethodDictionary
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
1216 |
Notice that although this method calls super messages, |
6f937c0ba907
fixes for new MethodDictionary
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
1217 |
actual instances will have no valid superClass." |
282 | 1218 |
|
616 | 1219 |
|sel args names sz s idx| |
282 | 1220 |
|
1221 |
"/ instance protocol |
|
1222 |
||
1223 |
sel := aMessage selector. |
|
1224 |
args := aMessage arguments. |
|
1225 |
||
2186 | 1226 |
(sel == #displayString) ifTrue:[ |
294
6f937c0ba907
fixes for new MethodDictionary
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
1227 |
s := WriteStream on:''. |
282 | 1228 |
s nextPutAll:'Structure('. |
1130 | 1229 |
names := self allInstVarNames. |
1230 |
names notNil ifTrue:[ |
|
1231 |
names keysAndValuesDo:[:idx :nm | |
|
1232 |
s nextPutAll:nm; nextPutAll:'->'. |
|
1233 |
s nextPutAll:(self at:idx) displayString. |
|
1234 |
s space |
|
1235 |
]. |
|
1236 |
]. |
|
1237 |
s nextPutAll:')'. |
|
1238 |
^ s contents |
|
294
6f937c0ba907
fixes for new MethodDictionary
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
1239 |
]. |
6f937c0ba907
fixes for new MethodDictionary
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
1240 |
|
282 | 1241 |
sel == #basicInspect ifTrue:[ |
1242 |
^ InspectorView openOn:self |
|
1243 |
]. |
|
1244 |
||
1424 | 1245 |
sel == #inspectorClass ifTrue:[ |
1246 |
^ InspectorView |
|
1247 |
]. |
|
282 | 1248 |
sel == #inspect ifTrue:[ |
1249 |
^ InspectorView openOn:self |
|
1250 |
]. |
|
1251 |
||
1252 |
sel == #instVarAt: ifTrue:[ |
|
1253 |
|nr| |
|
1254 |
||
1255 |
nr := args at:1. |
|
1256 |
nr == 1 ifTrue:[^ i1]. |
|
1257 |
nr == 2 ifTrue:[^ i2]. |
|
1258 |
nr == 3 ifTrue:[^ i3]. |
|
1259 |
nr == 4 ifTrue:[^ i4]. |
|
1260 |
nr == 5 ifTrue:[^ i5]. |
|
1261 |
nr == 6 ifTrue:[^ i6]. |
|
1481 | 1262 |
nr == 7 ifTrue:[^ i7]. |
1263 |
nr == 8 ifTrue:[^ i8]. |
|
1264 |
nr == 9 ifTrue:[^ i9]. |
|
1265 |
nr == 10 ifTrue:[^ i10]. |
|
1266 |
nr == 11 ifTrue:[^ i11]. |
|
1267 |
nr == 12 ifTrue:[^ i12]. |
|
1268 |
nr == 13 ifTrue:[^ i13]. |
|
1269 |
nr == 14 ifTrue:[^ i14]. |
|
282 | 1270 |
^ nil |
1271 |
]. |
|
1272 |
||
1129 | 1273 |
(sel == #'perform:') ifTrue:[ |
1274 |
^ super perform:(args at:1) |
|
1275 |
]. |
|
1559 | 1276 |
(sel == #'perform:with:') ifTrue:[ |
1277 |
^ super perform:(args at:1) with:(args at:2) |
|
1278 |
]. |
|
1129 | 1279 |
|
1280 |
(sel == #'=') ifTrue:[ |
|
1130 | 1281 |
(args at:1) class == (args at:1) ifFalse:[^ false]. "/ must be another struct |
1282 |
names := self allInstVarNames. |
|
1283 |
names notNil ifTrue:[ |
|
1377
24f668298ef1
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
1243
diff
changeset
|
1284 |
Error handle:[:ex | |
1130 | 1285 |
^ false |
1286 |
] do:[ |
|
1287 |
names do:[:slotName | |
|
1288 |
((args at:1) perform:slotName asSymbol) = (self perform:slotName asSymbol) |
|
1289 |
ifFalse:[slotName halt. ^ false] |
|
1290 |
] |
|
1291 |
]. |
|
1292 |
]. |
|
1293 |
^ true. |
|
1129 | 1294 |
]. |
1295 |
(sel == #'~=') ifTrue:[ |
|
1296 |
^ super ~= (args at:1) |
|
1297 |
]. |
|
1298 |
||
282 | 1299 |
(sel == #size |
1300 |
or:[sel == #basicSize]) ifTrue:[ |
|
1301 |
^ super basicSize |
|
1302 |
]. |
|
1303 |
||
1304 |
(sel == #at: |
|
1305 |
or:[sel == #basicAt:]) ifTrue:[ |
|
1306 |
^ super basicAt:(args at:1) |
|
1307 |
]. |
|
1308 |
||
1309 |
(sel == #at:put: |
|
1310 |
or:[sel == #basicAt:put:]) ifTrue:[ |
|
1311 |
^ super basicAt:(args at:1) put:(args at:2) |
|
1312 |
]. |
|
1313 |
||
1314 |
sel == #== ifTrue:[ |
|
1315 |
^ self == (args at:1) |
|
1316 |
]. |
|
1317 |
||
945 | 1318 |
sel == #clone ifTrue:[ |
1319 |
^ super clone |
|
1320 |
]. |
|
1321 |
sel == #shallowCopy ifTrue:[ |
|
1322 |
^ super shallowCopy |
|
1323 |
]. |
|
2215
8ae61b93c7eb
changed: #doesNotUnderstand: - hash
Michael Beyl <mb@exept.de>
parents:
2186
diff
changeset
|
1324 |
sel == #identityHash ifTrue:[ |
8ae61b93c7eb
changed: #doesNotUnderstand: - hash
Michael Beyl <mb@exept.de>
parents:
2186
diff
changeset
|
1325 |
^ super identityHash |
8ae61b93c7eb
changed: #doesNotUnderstand: - hash
Michael Beyl <mb@exept.de>
parents:
2186
diff
changeset
|
1326 |
]. |
2186 | 1327 |
(sel == #isException) ifTrue:[ |
1328 |
^ false |
|
1329 |
]. |
|
945 | 1330 |
|
282 | 1331 |
"/ class protocol |
1332 |
||
2186 | 1333 |
sel == #name ifTrue:[ |
282 | 1334 |
^ 'Structure' |
1335 |
]. |
|
1336 |
||
1337 |
sel == #isVariable ifTrue:[ |
|
1338 |
^ false |
|
1339 |
]. |
|
1340 |
||
1341 |
sel == #isClass ifTrue:[ |
|
1342 |
^ false |
|
1343 |
]. |
|
1344 |
||
1345 |
sel == #isMeta ifTrue:[ |
|
1346 |
^ false |
|
1347 |
]. |
|
1348 |
||
1349 |
sel == #isBehavior ifTrue:[ |
|
1350 |
^ false |
|
1351 |
]. |
|
1352 |
||
1243 | 1353 |
sel == #isKindOf: ifTrue:[ |
1354 |
^ false |
|
1355 |
]. |
|
1356 |
||
2006 | 1357 |
sel == #isString ifTrue:[ |
1358 |
^ false |
|
1359 |
]. |
|
1360 |
||
282 | 1361 |
sel == #respondsTo: ifTrue:[ |
1362 |
^ false |
|
1363 |
]. |
|
1364 |
||
616 | 1365 |
sel == #whichClassIncludesSelector: ifTrue:[ |
1366 |
^ nil |
|
1367 |
]. |
|
1368 |
||
282 | 1369 |
sel == #evaluatorClass ifTrue:[ |
1370 |
^ Compiler |
|
1371 |
]. |
|
1372 |
||
1373 |
sel == #classNameWithArticle ifTrue:[ |
|
1374 |
^ self displayString |
|
1375 |
]. |
|
1376 |
||
1377 |
sel == #allSubclasses ifTrue:[ |
|
1378 |
^ #() |
|
1379 |
]. |
|
1380 |
||
1381 |
sel == #allClassVarNames ifTrue:[ |
|
1382 |
^ #() |
|
1383 |
]. |
|
1559 | 1384 |
sel == #methodDictionary ifTrue:[ |
1385 |
^methodDictionary |
|
1386 |
]. |
|
282 | 1387 |
|
1388 |
sel == #allInstVarNames ifTrue:[ |
|
616 | 1389 |
methodDictionary isNil ifTrue:[ |
1486 | 1390 |
'Structure [info]: oops - nil methodDict' infoPrintCR. |
616 | 1391 |
^ #() |
1392 |
]. |
|
1393 |
||
282 | 1394 |
sz := super basicSize. |
1395 |
names := Array new:sz. |
|
1396 |
||
616 | 1397 |
methodDictionary keysAndValuesDo:[:sel :mthd| |
1398 |
|index mysel| |
|
1399 |
||
282 | 1400 |
(sel endsWith:$:) ifFalse:[ |
1401 |
(sel ~~ #class) ifTrue:[ |
|
1402 |
"/ |
|
1403 |
"/ which method is it ? |
|
1404 |
"/ |
|
616 | 1405 |
idx := 1. |
1406 |
[idx <= sz] whileTrue:[ |
|
1407 |
mysel := ('i' , idx printString) asSymbol. |
|
282 | 1408 |
mthd == (Structure compiledMethodAt:mysel) ifTrue:[ |
616 | 1409 |
names at:idx put:sel. |
1410 |
idx := sz. "/ break |
|
1411 |
]. |
|
1412 |
idx := idx + 1. |
|
282 | 1413 |
]. |
1414 |
] |
|
1415 |
] |
|
1416 |
]. |
|
2341
d05835f10cb8
better check for behavior compatibility
Claus Gittinger <cg@exept.de>
parents:
2215
diff
changeset
|
1417 |
|
282 | 1418 |
^ names |
1419 |
]. |
|
1420 |
||
943
5a9699ed4b9b
give the dummy class another name, to avoid confusion with
Claus Gittinger <cg@exept.de>
parents:
654
diff
changeset
|
1421 |
(sel == #instSize) ifTrue:[ |
5a9699ed4b9b
give the dummy class another name, to avoid confusion with
Claus Gittinger <cg@exept.de>
parents:
654
diff
changeset
|
1422 |
^ instSize |
5a9699ed4b9b
give the dummy class another name, to avoid confusion with
Claus Gittinger <cg@exept.de>
parents:
654
diff
changeset
|
1423 |
]. |
1486 | 1424 |
'Structure [warning]: return nil for: ' infoPrint. |
1425 |
aMessage infoPrint. |
|
1426 |
' args ' infoPrint. args infoPrintCR. |
|
2186 | 1427 |
"/ Object halt. |
282 | 1428 |
|
294
6f937c0ba907
fixes for new MethodDictionary
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
1429 |
^ nil. |
282 | 1430 |
|
1431 |
"Created: 13.5.1996 / 20:22:22 / cg" |
|
1432 |
"Modified: 13.5.1996 / 21:12:54 / cg" |
|
1433 |
! ! |
|
1434 |
||
616 | 1435 |
!Structure class methodsFor:'documentation'! |
282 | 1436 |
|
1437 |
version |
|
2341
d05835f10cb8
better check for behavior compatibility
Claus Gittinger <cg@exept.de>
parents:
2215
diff
changeset
|
1438 |
^ '$Header: /cvs/stx/stx/libcomp/Structure.st,v 1.24 2010-04-07 14:53:33 cg Exp $' |
2215
8ae61b93c7eb
changed: #doesNotUnderstand: - hash
Michael Beyl <mb@exept.de>
parents:
2186
diff
changeset
|
1439 |
! |
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 |
version_CVS |
2341
d05835f10cb8
better check for behavior compatibility
Claus Gittinger <cg@exept.de>
parents:
2215
diff
changeset
|
1442 |
^ '$Header: /cvs/stx/stx/libcomp/Structure.st,v 1.24 2010-04-07 14:53:33 cg Exp $' |
282 | 1443 |
! ! |
1377
24f668298ef1
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
1243
diff
changeset
|
1444 |
|
282 | 1445 |
Structure initialize! |