author | Claus Gittinger <cg@exept.de> |
Wed, 22 Oct 2008 00:20:59 +0200 | |
changeset 11261 | e8dcdce0b2ae |
parent 8890 | 9e9df761477e |
child 13752 | e3a3e70985c1 |
child 17711 | 39faaaf888b4 |
permissions | -rw-r--r-- |
2240 | 1 |
" |
2 |
COPYRIGHT (c) 1997 by eXept Software AG / 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 |
" |
|
12 |
||
13 |
||
14 |
||
5351
f9529bd6b6e4
oops - must setup the isBLOCK / isBLOCKLIKE flags correctly
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
15 |
"{ Package: 'stx:libbasic' }" |
f9529bd6b6e4
oops - must setup the isBLOCK / isBLOCKLIKE flags correctly
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
16 |
|
f9529bd6b6e4
oops - must setup the isBLOCK / isBLOCKLIKE flags correctly
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
17 |
Block variableSubclass:#VarArgBlock |
2239 | 18 |
instanceVariableNames:'' |
19 |
classVariableNames:'' |
|
20 |
poolDictionaries:'' |
|
21 |
category:'Kernel-Methods' |
|
22 |
! |
|
23 |
||
24 |
!VarArgBlock class methodsFor:'documentation'! |
|
25 |
||
26 |
copyright |
|
27 |
" |
|
28 |
COPYRIGHT (c) 1997 by eXept Software AG / Claus Gittinger |
|
29 |
All Rights Reserved |
|
30 |
||
31 |
This software is furnished under a license and may be used |
|
32 |
only in accordance with the terms of that license and with the |
|
33 |
inclusion of the above copyright notice. This software may not |
|
34 |
be provided or otherwise made available to, or used by, any |
|
35 |
other person. No title to or ownership of the software is |
|
36 |
hereby transferred. |
|
37 |
" |
|
38 |
||
39 |
||
40 |
! |
|
41 |
||
42 |
documentation |
|
43 |
" |
|
44 |
VarArgBlocks are much like blocks, but can accept a variable |
|
45 |
number of arguments. They must be defined as a regular block, |
|
46 |
with 1 argument. When executed, the actual argument list is |
|
47 |
passed in that single argument (as a collection). |
|
48 |
||
8890 | 49 |
Create a variableArgument block by sending #asVarArgBlock to a regular |
2239 | 50 |
block. |
51 |
||
2240 | 52 |
This is a goody add-on, which may not be available/possible in other |
53 |
smalltalk implementations. Do not use it if cross-platform |
|
54 |
portability is required. |
|
55 |
||
56 |
||
2239 | 57 |
[author:] |
2240 | 58 |
Claus Gittinger |
2239 | 59 |
|
60 |
[see also:] |
|
2240 | 61 |
Block |
2239 | 62 |
" |
63 |
! |
|
64 |
||
65 |
examples |
|
66 |
" |
|
67 |
the same block, evaluated with 2 or 5 arguments: |
|
2240 | 68 |
[exBegin] |
2239 | 69 |
|b| |
70 |
||
8890 | 71 |
b := [:args | Transcript show:'wow: '; showCR:args] asVarArgBlock. |
2239 | 72 |
|
73 |
b value:'hi' value:'there'. |
|
74 |
b value:'hello' value:'there' value:'how' value:'about' value:'this'. |
|
2240 | 75 |
[exEnd] |
2239 | 76 |
|
77 |
||
78 |
does it accept a variable number of arguments ?: |
|
2240 | 79 |
[exBegin] |
2239 | 80 |
|b| |
81 |
||
82 |
b := [:args | Transcript showCR:args]. |
|
83 |
Transcript showCR:(b isVarArgBlock). |
|
84 |
||
8890 | 85 |
b := [:args | Transcript showCR:args] asVarArgBlock. |
2239 | 86 |
Transcript showCR:(b isVarArgBlock) |
2240 | 87 |
[exEnd] |
2239 | 88 |
" |
89 |
||
90 |
"Created: 23.1.1997 / 04:57:26 / cg" |
|
91 |
! ! |
|
92 |
||
5351
f9529bd6b6e4
oops - must setup the isBLOCK / isBLOCKLIKE flags correctly
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
93 |
!VarArgBlock class methodsFor:'initialization'! |
f9529bd6b6e4
oops - must setup the isBLOCK / isBLOCKLIKE flags correctly
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
94 |
|
f9529bd6b6e4
oops - must setup the isBLOCK / isBLOCKLIKE flags correctly
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
95 |
initialize |
f9529bd6b6e4
oops - must setup the isBLOCK / isBLOCKLIKE flags correctly
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
96 |
"must clear the is-block flag bit in the class |
f9529bd6b6e4
oops - must setup the isBLOCK / isBLOCKLIKE flags correctly
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
97 |
(otherwise, the VM might try to inline value-messages)" |
f9529bd6b6e4
oops - must setup the isBLOCK / isBLOCKLIKE flags correctly
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
98 |
|
5353 | 99 |
|flags| |
100 |
flags := self flags. |
|
5351
f9529bd6b6e4
oops - must setup the isBLOCK / isBLOCKLIKE flags correctly
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
101 |
flags := flags bitClear:(Behavior flagBlock). |
f9529bd6b6e4
oops - must setup the isBLOCK / isBLOCKLIKE flags correctly
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
102 |
flags := flags bitOr:(Behavior flagBlockLike). |
5353 | 103 |
self flags:flags. |
5351
f9529bd6b6e4
oops - must setup the isBLOCK / isBLOCKLIKE flags correctly
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
104 |
|
f9529bd6b6e4
oops - must setup the isBLOCK / isBLOCKLIKE flags correctly
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
105 |
" |
f9529bd6b6e4
oops - must setup the isBLOCK / isBLOCKLIKE flags correctly
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
106 |
self flags. |
f9529bd6b6e4
oops - must setup the isBLOCK / isBLOCKLIKE flags correctly
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
107 |
self initialize. |
f9529bd6b6e4
oops - must setup the isBLOCK / isBLOCKLIKE flags correctly
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
108 |
self flags. |
f9529bd6b6e4
oops - must setup the isBLOCK / isBLOCKLIKE flags correctly
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
109 |
" |
f9529bd6b6e4
oops - must setup the isBLOCK / isBLOCKLIKE flags correctly
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
110 |
|
f9529bd6b6e4
oops - must setup the isBLOCK / isBLOCKLIKE flags correctly
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
111 |
|
f9529bd6b6e4
oops - must setup the isBLOCK / isBLOCKLIKE flags correctly
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
112 |
! ! |
f9529bd6b6e4
oops - must setup the isBLOCK / isBLOCKLIKE flags correctly
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
113 |
|
2239 | 114 |
!VarArgBlock methodsFor:'evaluation'! |
115 |
||
116 |
value |
|
117 |
"evaluate the receiver with no block args." |
|
118 |
||
119 |
^ super value:#() |
|
120 |
||
121 |
"Created: 23.1.1997 / 04:57:49 / cg" |
|
122 |
! |
|
123 |
||
124 |
value:arg |
|
125 |
"evaluate the receiver with a single argument." |
|
126 |
||
127 |
^ super value:(Array with:arg) |
|
128 |
||
129 |
"Created: 23.1.1997 / 04:57:57 / cg" |
|
130 |
! |
|
131 |
||
132 |
value:arg1 value:arg2 |
|
133 |
"evaluate the receiver with two arguments." |
|
134 |
||
135 |
^ super value:(Array with:arg1 with:arg2) |
|
136 |
||
137 |
"Created: 23.1.1997 / 04:58:03 / cg" |
|
138 |
! |
|
139 |
||
140 |
value:arg1 value:arg2 value:arg3 |
|
141 |
"evaluate the receiver with three arguments." |
|
142 |
||
143 |
^ super value:(Array with:arg1 with:arg2 with:arg3) |
|
144 |
||
145 |
"Created: 23.1.1997 / 04:58:09 / cg" |
|
146 |
! |
|
147 |
||
148 |
value:arg1 value:arg2 value:arg3 value:arg4 |
|
149 |
"evaluate the receiver with four arguments." |
|
150 |
||
151 |
^ super value:(Array |
|
152 |
with:arg1 |
|
153 |
with:arg2 |
|
154 |
with:arg3 |
|
155 |
with:arg4) |
|
156 |
||
157 |
"Modified: 22.1.1997 / 19:41:22 / cg" |
|
158 |
"Created: 23.1.1997 / 04:58:14 / cg" |
|
159 |
! |
|
160 |
||
161 |
value:arg1 value:arg2 value:arg3 value:arg4 value:arg5 |
|
162 |
"evaluate the receiver with five arguments." |
|
163 |
||
164 |
^ super value:(Array |
|
165 |
with:arg1 |
|
166 |
with:arg2 |
|
167 |
with:arg3 |
|
168 |
with:arg4 |
|
169 |
with:arg5) |
|
170 |
||
171 |
"Modified: 22.1.1997 / 19:41:26 / cg" |
|
172 |
"Created: 23.1.1997 / 04:58:18 / cg" |
|
173 |
! |
|
174 |
||
175 |
value:arg1 value:arg2 value:arg3 value:arg4 value:arg5 value:arg6 |
|
176 |
"evaluate the receiver with six arguments." |
|
177 |
||
178 |
^ super value:(Array |
|
179 |
with:arg1 |
|
180 |
with:arg2 |
|
181 |
with:arg3 |
|
182 |
with:arg4 |
|
183 |
with:arg5 |
|
184 |
with:arg6) |
|
185 |
||
186 |
"Modified: 22.1.1997 / 19:41:29 / cg" |
|
187 |
"Created: 23.1.1997 / 04:58:22 / cg" |
|
188 |
! |
|
189 |
||
190 |
value:arg1 value:arg2 value:arg3 value:arg4 value:arg5 value:arg6 value:arg7 |
|
191 |
"evaluate the receiver with seven arguments." |
|
192 |
||
193 |
^ super value:(Array |
|
194 |
with:arg1 |
|
195 |
with:arg2 |
|
196 |
with:arg3 |
|
197 |
with:arg4 |
|
198 |
with:arg5 |
|
199 |
with:arg6 |
|
200 |
with:arg7) |
|
201 |
||
202 |
"Modified: 22.1.1997 / 19:41:33 / cg" |
|
203 |
"Created: 23.1.1997 / 04:58:26 / cg" |
|
204 |
! |
|
205 |
||
206 |
value:arg1 value:arg2 value:arg3 value:arg4 value:arg5 value:arg6 value:arg7 value:arg8 |
|
207 |
"evaluate the receiver with eight arguments." |
|
208 |
||
209 |
^ super value:(Array |
|
210 |
with:arg1 |
|
211 |
with:arg2 |
|
212 |
with:arg3 |
|
213 |
with:arg4 |
|
214 |
with:arg5 |
|
215 |
with:arg6 |
|
216 |
with:arg7 |
|
217 |
with:arg8) |
|
218 |
||
219 |
"Created: 23.1.1997 / 04:58:30 / cg" |
|
220 |
! |
|
221 |
||
222 |
valueWithArguments:argArray |
|
223 |
"evaluate the receiver with all arguments in argArray." |
|
224 |
||
225 |
^ super value:argArray |
|
226 |
||
227 |
"Created: 23.1.1997 / 04:59:16 / cg" |
|
228 |
! ! |
|
229 |
||
230 |
!VarArgBlock methodsFor:'testing'! |
|
231 |
||
232 |
isVarArgBlock |
|
233 |
"return true, if this block accepts a variable number of arguments" |
|
234 |
||
235 |
^ true |
|
236 |
||
237 |
"Created: 23.1.1997 / 05:00:18 / cg" |
|
238 |
! ! |
|
239 |
||
2240 | 240 |
!VarArgBlock class methodsFor:'documentation'! |
2239 | 241 |
|
2240 | 242 |
version |
8890 | 243 |
^ '$Header: /cvs/stx/stx/libbasic/VarArgBlock.st,v 1.6 2005-06-16 14:49:37 stefan Exp $' |
2240 | 244 |
! ! |
7589 | 245 |
|
5351
f9529bd6b6e4
oops - must setup the isBLOCK / isBLOCKLIKE flags correctly
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
246 |
VarArgBlock initialize! |