@@ -161,33 +161,6 @@ PyObject* PyObject_CallObject(PyObject* callable, PyObject* args) {
161
161
return PyObject_Call (callable , args , PyDict_New ());
162
162
}
163
163
164
- // (tfel): this is used a couple of times in this file only, for now
165
- #define CALL_WITH_VARARGS (retval , funcname , skipN , ...) \
166
- switch (polyglot_get_arg_count() - skipN) { \
167
- case 0: \
168
- retval = funcname(__VA_ARGS__); break; \
169
- case 1: \
170
- retval = funcname(__VA_ARGS__, polyglot_get_arg(skipN)); break; \
171
- case 2: \
172
- retval = funcname(__VA_ARGS__, polyglot_get_arg(skipN), polyglot_get_arg(skipN + 1)); break; \
173
- case 3: \
174
- retval = funcname(__VA_ARGS__, polyglot_get_arg(skipN), polyglot_get_arg(skipN + 1), polyglot_get_arg(skipN + 2)); break; \
175
- case 4: \
176
- retval = funcname(__VA_ARGS__, polyglot_get_arg(skipN), polyglot_get_arg(skipN + 1), polyglot_get_arg(skipN + 2), polyglot_get_arg(skipN + 3)); break; \
177
- case 5: \
178
- retval = funcname(__VA_ARGS__, polyglot_get_arg(skipN), polyglot_get_arg(skipN + 1), polyglot_get_arg(skipN + 2), polyglot_get_arg(skipN + 3), polyglot_get_arg(skipN + 4)); break; \
179
- case 6: \
180
- retval = funcname(__VA_ARGS__, polyglot_get_arg(skipN), polyglot_get_arg(skipN + 1), polyglot_get_arg(skipN + 2), polyglot_get_arg(skipN + 3), polyglot_get_arg(skipN + 4), polyglot_get_arg(skipN + 5)); break; \
181
- case 7: \
182
- retval = funcname(__VA_ARGS__, polyglot_get_arg(skipN), polyglot_get_arg(skipN + 1), polyglot_get_arg(skipN + 2), polyglot_get_arg(skipN + 3), polyglot_get_arg(skipN + 4), polyglot_get_arg(skipN + 5), polyglot_get_arg(skipN + 6)); break; \
183
- case 8: \
184
- retval = funcname(__VA_ARGS__, polyglot_get_arg(skipN), polyglot_get_arg(skipN + 1), polyglot_get_arg(skipN + 2), polyglot_get_arg(skipN + 3), polyglot_get_arg(skipN + 4), polyglot_get_arg(skipN + 5), polyglot_get_arg(skipN + 6), polyglot_get_arg(skipN + 7)); break; \
185
- case 9: \
186
- retval = funcname(__VA_ARGS__, polyglot_get_arg(skipN), polyglot_get_arg(skipN + 1), polyglot_get_arg(skipN + 2), polyglot_get_arg(skipN + 3), polyglot_get_arg(skipN + 4), polyglot_get_arg(skipN + 5), polyglot_get_arg(skipN + 6), polyglot_get_arg(skipN + 7), polyglot_get_arg(skipN + 8)); break; \
187
- default: \
188
- fprintf(stderr, "Too many arguments passed through varargs: %d", polyglot_get_arg_count() - skipN); \
189
- }
190
-
191
164
NO_INLINE
192
165
PyObject * PyObject_CallFunction (PyObject * callable , const char * fmt , ...) {
193
166
PyObject * args ;
@@ -196,7 +169,7 @@ PyObject* PyObject_CallFunction(PyObject* callable, const char* fmt, ...) {
196
169
return PyObject_CallObject (callable , NULL );
197
170
}
198
171
199
- CALL_WITH_VARARGS (args , Py_BuildValue , 2 , fmt );
172
+ CallWithPolyglotArgs (args , fmt , _PyTruffle_BuildValue , fmt );
200
173
if (strlen (fmt ) < 2 ) {
201
174
PyObject * singleArg = args ;
202
175
args = PyTuple_New (strlen (fmt ));
@@ -216,7 +189,7 @@ PyObject* _PyObject_CallFunction_SizeT(PyObject* callable, const char* fmt, ...)
216
189
return PyObject_CallObject (callable , NULL );
217
190
}
218
191
219
- CALL_WITH_VARARGS (args , Py_BuildValue , 2 , fmt );
192
+ CallWithPolyglotArgs (args , fmt , _PyTruffle_BuildValue , fmt );
220
193
if (strlen (fmt ) < 2 ) {
221
194
PyObject * singleArg = args ;
222
195
args = PyTuple_New (strlen (fmt ));
@@ -247,7 +220,7 @@ PyObject* PyObject_CallMethod(PyObject* object, const char* method, const char*
247
220
if (fmt == NULL || fmt [0 ] == '\0' ) {
248
221
args = Py_None ;
249
222
} else {
250
- CALL_WITH_VARARGS (args , Py_BuildValue , 3 , fmt );
223
+ CallWithPolyglotArgs (args , fmt , _PyTruffle_BuildValue , fmt );
251
224
}
252
225
return UPCALL_CEXT_O (_jls_PyObject_CallMethod , native_to_java (object ), polyglot_from_string (method , SRC_CS ), native_to_java (args ));
253
226
}
@@ -265,7 +238,7 @@ PyObject* _PyObject_CallMethod_SizeT(PyObject* object, const char* method, const
265
238
if (fmt == NULL || fmt [0 ] == '\0' ) {
266
239
args = Py_None ;
267
240
} else {
268
- CALL_WITH_VARARGS (args , Py_BuildValue , 3 , fmt );
241
+ CallWithPolyglotArgs (args , fmt , _PyTruffle_BuildValue , fmt );
269
242
}
270
243
return UPCALL_CEXT_O (_jls_PyObject_CallMethod , native_to_java (object ), polyglot_from_string (method , SRC_CS ), native_to_java (args ));
271
244
}
0 commit comments