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