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