author | Claus Gittinger <cg@exept.de> |
Fri, 29 Aug 2003 21:21:35 +0200 | |
changeset 7589 | 2ac0ac814fc8 |
parent 5353 | 286dbcd4c605 |
child 8890 | 9e9df761477e |
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 |
||
49 |
Create a variableArgument block by sending #varArgs to a regular |
|
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 |
||
66 |
examples |
|
67 |
" |
|
68 |
the same block, evaluated with 2 or 5 arguments: |
|
2240 | 69 |
[exBegin] |
2239 | 70 |
|b| |
71 |
||
2240 | 72 |
b := [:args | Transcript show:'wow: '; showCR:args] beVarArg. |
2239 | 73 |
|
74 |
b value:'hi' value:'there'. |
|
75 |
b value:'hello' value:'there' value:'how' value:'about' value:'this'. |
|
2240 | 76 |
[exEnd] |
2239 | 77 |
|
78 |
||
79 |
does it accept a variable number of arguments ?: |
|
2240 | 80 |
[exBegin] |
2239 | 81 |
|b| |
82 |
||
83 |
b := [:args | Transcript showCR:args]. |
|
84 |
Transcript showCR:(b isVarArgBlock). |
|
85 |
||
2240 | 86 |
b := [:args | Transcript showCR:args] beVarArg. |
2239 | 87 |
Transcript showCR:(b isVarArgBlock) |
2240 | 88 |
[exEnd] |
2239 | 89 |
" |
90 |
||
91 |
"Created: 23.1.1997 / 04:57:26 / cg" |
|
92 |
! ! |
|
93 |
||
5351
f9529bd6b6e4
oops - must setup the isBLOCK / isBLOCKLIKE flags correctly
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
94 |
!VarArgBlock class methodsFor:'initialization'! |
f9529bd6b6e4
oops - must setup the isBLOCK / isBLOCKLIKE flags correctly
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
95 |
|
f9529bd6b6e4
oops - must setup the isBLOCK / isBLOCKLIKE flags correctly
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
96 |
initialize |
f9529bd6b6e4
oops - must setup the isBLOCK / isBLOCKLIKE flags correctly
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
97 |
"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
|
98 |
(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
|
99 |
|
5353 | 100 |
|flags| |
101 |
flags := self flags. |
|
5351
f9529bd6b6e4
oops - must setup the isBLOCK / isBLOCKLIKE flags correctly
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
102 |
flags := flags bitClear:(Behavior flagBlock). |
f9529bd6b6e4
oops - must setup the isBLOCK / isBLOCKLIKE flags correctly
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
103 |
flags := flags bitOr:(Behavior flagBlockLike). |
5353 | 104 |
self flags:flags. |
5351
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 |
" |
f9529bd6b6e4
oops - must setup the isBLOCK / isBLOCKLIKE flags correctly
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
107 |
self flags. |
f9529bd6b6e4
oops - must setup the isBLOCK / isBLOCKLIKE flags correctly
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
108 |
self initialize. |
f9529bd6b6e4
oops - must setup the isBLOCK / isBLOCKLIKE flags correctly
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
109 |
self flags. |
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 |
! ! |
f9529bd6b6e4
oops - must setup the isBLOCK / isBLOCKLIKE flags correctly
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
114 |
|
2239 | 115 |
!VarArgBlock methodsFor:'evaluation'! |
116 |
||
117 |
value |
|
118 |
"evaluate the receiver with no block args." |
|
119 |
||
120 |
^ super value:#() |
|
121 |
||
122 |
"Created: 23.1.1997 / 04:57:49 / cg" |
|
123 |
! |
|
124 |
||
125 |
value:arg |
|
126 |
"evaluate the receiver with a single argument." |
|
127 |
||
128 |
^ super value:(Array with:arg) |
|
129 |
||
130 |
"Created: 23.1.1997 / 04:57:57 / cg" |
|
131 |
! |
|
132 |
||
133 |
value:arg1 value:arg2 |
|
134 |
"evaluate the receiver with two arguments." |
|
135 |
||
136 |
^ super value:(Array with:arg1 with:arg2) |
|
137 |
||
138 |
"Created: 23.1.1997 / 04:58:03 / cg" |
|
139 |
! |
|
140 |
||
141 |
value:arg1 value:arg2 value:arg3 |
|
142 |
"evaluate the receiver with three arguments." |
|
143 |
||
144 |
^ super value:(Array with:arg1 with:arg2 with:arg3) |
|
145 |
||
146 |
"Created: 23.1.1997 / 04:58:09 / cg" |
|
147 |
! |
|
148 |
||
149 |
value:arg1 value:arg2 value:arg3 value:arg4 |
|
150 |
"evaluate the receiver with four arguments." |
|
151 |
||
152 |
^ super value:(Array |
|
153 |
with:arg1 |
|
154 |
with:arg2 |
|
155 |
with:arg3 |
|
156 |
with:arg4) |
|
157 |
||
158 |
"Modified: 22.1.1997 / 19:41:22 / cg" |
|
159 |
"Created: 23.1.1997 / 04:58:14 / cg" |
|
160 |
! |
|
161 |
||
162 |
value:arg1 value:arg2 value:arg3 value:arg4 value:arg5 |
|
163 |
"evaluate the receiver with five arguments." |
|
164 |
||
165 |
^ super value:(Array |
|
166 |
with:arg1 |
|
167 |
with:arg2 |
|
168 |
with:arg3 |
|
169 |
with:arg4 |
|
170 |
with:arg5) |
|
171 |
||
172 |
"Modified: 22.1.1997 / 19:41:26 / cg" |
|
173 |
"Created: 23.1.1997 / 04:58:18 / cg" |
|
174 |
! |
|
175 |
||
176 |
value:arg1 value:arg2 value:arg3 value:arg4 value:arg5 value:arg6 |
|
177 |
"evaluate the receiver with six arguments." |
|
178 |
||
179 |
^ super value:(Array |
|
180 |
with:arg1 |
|
181 |
with:arg2 |
|
182 |
with:arg3 |
|
183 |
with:arg4 |
|
184 |
with:arg5 |
|
185 |
with:arg6) |
|
186 |
||
187 |
"Modified: 22.1.1997 / 19:41:29 / cg" |
|
188 |
"Created: 23.1.1997 / 04:58:22 / cg" |
|
189 |
! |
|
190 |
||
191 |
value:arg1 value:arg2 value:arg3 value:arg4 value:arg5 value:arg6 value:arg7 |
|
192 |
"evaluate the receiver with seven arguments." |
|
193 |
||
194 |
^ super value:(Array |
|
195 |
with:arg1 |
|
196 |
with:arg2 |
|
197 |
with:arg3 |
|
198 |
with:arg4 |
|
199 |
with:arg5 |
|
200 |
with:arg6 |
|
201 |
with:arg7) |
|
202 |
||
203 |
"Modified: 22.1.1997 / 19:41:33 / cg" |
|
204 |
"Created: 23.1.1997 / 04:58:26 / cg" |
|
205 |
! |
|
206 |
||
207 |
value:arg1 value:arg2 value:arg3 value:arg4 value:arg5 value:arg6 value:arg7 value:arg8 |
|
208 |
"evaluate the receiver with eight arguments." |
|
209 |
||
210 |
^ super value:(Array |
|
211 |
with:arg1 |
|
212 |
with:arg2 |
|
213 |
with:arg3 |
|
214 |
with:arg4 |
|
215 |
with:arg5 |
|
216 |
with:arg6 |
|
217 |
with:arg7 |
|
218 |
with:arg8) |
|
219 |
||
220 |
"Created: 23.1.1997 / 04:58:30 / cg" |
|
221 |
! |
|
222 |
||
223 |
valueWithArguments:argArray |
|
224 |
"evaluate the receiver with all arguments in argArray." |
|
225 |
||
226 |
^ super value:argArray |
|
227 |
||
228 |
"Created: 23.1.1997 / 04:59:16 / cg" |
|
229 |
! ! |
|
230 |
||
231 |
!VarArgBlock methodsFor:'testing'! |
|
232 |
||
233 |
isVarArgBlock |
|
234 |
"return true, if this block accepts a variable number of arguments" |
|
235 |
||
236 |
^ true |
|
237 |
||
238 |
"Created: 23.1.1997 / 05:00:18 / cg" |
|
239 |
! ! |
|
240 |
||
2240 | 241 |
!VarArgBlock class methodsFor:'documentation'! |
2239 | 242 |
|
2240 | 243 |
version |
7589 | 244 |
^ '$Header: /cvs/stx/stx/libbasic/VarArgBlock.st,v 1.5 2003-08-29 19:21:32 cg Exp $' |
2240 | 245 |
! ! |
7589 | 246 |
|
5351
f9529bd6b6e4
oops - must setup the isBLOCK / isBLOCKLIKE flags correctly
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
247 |
VarArgBlock initialize! |