@@ -64,54 +64,36 @@ PyObject* PyTruffle_GetArg(positional_argstack* p, PyObject* kwds, char** kwdnam
64
64
return NULL ;
65
65
}
66
66
67
- #define PyTruffle_WriteOutImmediate (n , T , arg ) { \
67
+ #define PyTruffle_WriteOut (n , T , arg ) { \
68
68
T __oai = arg; \
69
69
if (PyErr_Occurred()) { \
70
70
return 0; \
71
71
} \
72
72
switch(n) { \
73
- case 0: *((T*)v0) = (T) __oai; break; \
74
- case 1: *((T*)v1) = (T) __oai; break; \
75
- case 2: *((T*)v2) = (T) __oai; break; \
76
- case 3: *((T*)v3) = (T) __oai; break; \
77
- case 4: *((T*)v4) = (T) __oai; break; \
78
- case 5: *((T*)v5) = (T) __oai; break; \
79
- case 6: *((T*)v6) = (T) __oai; break; \
80
- case 7: *((T*)v7) = (T) __oai; break; \
81
- case 8: *((T*)v8) = (T) __oai; break; \
82
- case 9: *((T*)v9) = (T) __oai; break; \
83
- case 10: *((T*)v10) = (T) __oai; break; \
84
- case 11: *((T*)v11) = (T) __oai; break; \
85
- case 12: *((T*)v12) = (T) __oai; break; \
86
- case 13: *((T*)v13) = (T) __oai; break; \
87
- case 14: *((T*)v14) = (T) __oai; break; \
88
- case 15: *((T*)v15) = (T) __oai; break; \
89
- case 16: *((T*)v16) = (T) __oai; break; \
90
- case 17: *((T*)v17) = (T) __oai; break; \
91
- case 18: *((T*)v18) = (T) __oai; break; \
92
- case 19: *((T*)v19) = (T) __oai; break; \
73
+ case 0: *((T*)v0) = __oai; break; \
74
+ case 1: *((T*)v1) = __oai; break; \
75
+ case 2: *((T*)v2) = __oai; break; \
76
+ case 3: *((T*)v3) = __oai; break; \
77
+ case 4: *((T*)v4) = __oai; break; \
78
+ case 5: *((T*)v5) = __oai; break; \
79
+ case 6: *((T*)v6) = __oai; break; \
80
+ case 7: *((T*)v7) = __oai; break; \
81
+ case 8: *((T*)v8) = __oai; break; \
82
+ case 9: *((T*)v9) = __oai; break; \
83
+ case 10: *((T*)v10) = __oai; break; \
84
+ case 11: *((T*)v11) = __oai; break; \
85
+ case 12: *((T*)v12) = __oai; break; \
86
+ case 13: *((T*)v13) = __oai; break; \
87
+ case 14: *((T*)v14) = __oai; break; \
88
+ case 15: *((T*)v15) = __oai; break; \
89
+ case 16: *((T*)v16) = __oai; break; \
90
+ case 17: *((T*)v17) = __oai; break; \
91
+ case 18: *((T*)v18) = __oai; break; \
92
+ case 19: *((T*)v19) = __oai; break; \
93
93
} \
94
94
n++; \
95
95
} while(0);
96
96
97
- #define PyTruffle_WriteOut (n , T , arg , optional ) { \
98
- T __oa = arg; \
99
- if (__oa == NULL) { \
100
- if (!optional) { \
101
- PyErr_Format(PyExc_TypeError, \
102
- "not enough arguments " \
103
- "(expected at least %d, got %d)", \
104
- n, \
105
- n - 1); \
106
- return 0; \
107
- } else { \
108
- n++; \
109
- } \
110
- } else { \
111
- PyTruffle_WriteOutImmediate(n, T, __oa); \
112
- } \
113
- } while(0);
114
-
115
97
#define PyTruffle_ArgN (n ) (((n) == 0) ? v0 : (((n) == 1) ? v1 : (((n) == 2) ? v2 : (((n) == 3) ? v3 : (((n) == 4) ? v4 : (((n) == 5) ? v5 : (((n) == 6) ? v6 : (((n) == 7) ? v7 : (((n) == 8) ? v8 : (((n) == 9) ? v9 : (((n) == 10) ? v10 : (((n) == 11) ? v11 : (((n) == 12) ? v12 : (((n) == 13) ? v13 : (((n) == 14) ? v14 : (((n) == 15) ? v15 : (((n) == 16) ? v16 : (((n) == 17) ? v17 : (((n) == 18) ? v18 : (((n) == 19) ? v19 : NULL))))))))))))))))))))
116
98
117
99
#define PyTruffle_SkipOptionalArg (n , arg , optional ) \
@@ -147,21 +129,21 @@ int PyTruffle_Arg_ParseTupleAndKeywords(PyObject *argv, PyObject *kwds, const ch
147
129
return 0 ;
148
130
} else if (arg == Py_None ) {
149
131
if (c == 'z' ) {
150
- PyTruffle_WriteOut (output_idx , const char * , NULL , rest_optional );
132
+ PyTruffle_WriteOut (output_idx , const char * , NULL );
151
133
if (format [format_idx + 1 ] == '#' ) {
152
134
format_idx ++ ; // skip over '#'
153
- PyTruffle_WriteOutImmediate (output_idx , int , 0 );
135
+ PyTruffle_WriteOut (output_idx , int , 0 );
154
136
}
155
137
} else {
156
138
PyErr_Format (PyExc_TypeError , "expected str or bytes-like, got None" );
157
139
return 0 ;
158
140
}
159
141
} else {
160
142
PyTruffle_SkipOptionalArg (output_idx , arg , rest_optional );
161
- PyTruffle_WriteOut (output_idx , const char * , as_char_pointer (arg ), rest_optional );
143
+ PyTruffle_WriteOut (output_idx , const char * , as_char_pointer (arg ));
162
144
if (format [format_idx + 1 ] == '#' ) {
163
145
format_idx ++ ;
164
- PyTruffle_WriteOutImmediate (output_idx , int , Py_SIZE (arg ));
146
+ PyTruffle_WriteOut (output_idx , int , Py_SIZE (arg ));
165
147
}
166
148
}
167
149
break ;
@@ -173,7 +155,7 @@ int PyTruffle_Arg_ParseTupleAndKeywords(PyObject *argv, PyObject *kwds, const ch
173
155
PyErr_Format (PyExc_TypeError , "expected bytes, got %R" , Py_TYPE (arg ));
174
156
return 0 ;
175
157
}
176
- PyTruffle_WriteOut (output_idx , PyObject * , arg , rest_optional );
158
+ PyTruffle_WriteOut (output_idx , PyObject * , arg );
177
159
break ;
178
160
case 'Y' :
179
161
arg = PyTruffle_GetArg (v , kwds , kwdnames , rest_keywords_only );
@@ -183,7 +165,7 @@ int PyTruffle_Arg_ParseTupleAndKeywords(PyObject *argv, PyObject *kwds, const ch
183
165
PyErr_Format (PyExc_TypeError , "expected bytearray, got %R" , Py_TYPE (arg ));
184
166
return 0 ;
185
167
}
186
- PyTruffle_WriteOut (output_idx , PyObject * , arg , rest_optional );
168
+ PyTruffle_WriteOut (output_idx , PyObject * , arg );
187
169
break ;
188
170
case 'u' :
189
171
case 'Z' :
@@ -197,7 +179,7 @@ int PyTruffle_Arg_ParseTupleAndKeywords(PyObject *argv, PyObject *kwds, const ch
197
179
PyErr_Format (PyExc_TypeError , "expected str, got %R" , Py_TYPE (arg ));
198
180
return 0 ;
199
181
}
200
- PyTruffle_WriteOut (output_idx , PyObject * , arg , rest_optional );
182
+ PyTruffle_WriteOut (output_idx , PyObject * , arg );
201
183
break ;
202
184
case 'w' :
203
185
PyErr_Format (PyExc_TypeError , "'w' format specifier in argument parsing not supported" );
@@ -221,13 +203,13 @@ int PyTruffle_Arg_ParseTupleAndKeywords(PyObject *argv, PyObject *kwds, const ch
221
203
PyErr_Format (PyExc_TypeError , "expected non-negative integer" );
222
204
return 0 ;
223
205
}
224
- PyTruffle_WriteOutImmediate (output_idx , unsigned char , as_uchar (arg ));
206
+ PyTruffle_WriteOut (output_idx , unsigned char , as_uchar (arg ));
225
207
break ;
226
208
case 'B' :
227
209
arg = PyTruffle_GetArg (v , kwds , kwdnames , rest_keywords_only );
228
210
v -> argnum ++ ;
229
211
PyTruffle_SkipOptionalArg (output_idx , arg , rest_optional );
230
- PyTruffle_WriteOutImmediate (output_idx , unsigned char , as_uchar (arg ));
212
+ PyTruffle_WriteOut (output_idx , unsigned char , as_uchar (arg ));
231
213
break ;
232
214
case 'h' :
233
215
arg = PyTruffle_GetArg (v , kwds , kwdnames , rest_keywords_only );
@@ -237,37 +219,37 @@ int PyTruffle_Arg_ParseTupleAndKeywords(PyObject *argv, PyObject *kwds, const ch
237
219
PyErr_Format (PyExc_TypeError , "expected non-negative integer" );
238
220
return 0 ;
239
221
}
240
- PyTruffle_WriteOutImmediate (output_idx , short int , as_short (arg ));
222
+ PyTruffle_WriteOut (output_idx , short int , as_short (arg ));
241
223
break ;
242
224
case 'H' :
243
225
arg = PyTruffle_GetArg (v , kwds , kwdnames , rest_keywords_only );
244
226
v -> argnum ++ ;
245
227
PyTruffle_SkipOptionalArg (output_idx , arg , rest_optional );
246
- PyTruffle_WriteOutImmediate (output_idx , short int , as_short (arg ));
228
+ PyTruffle_WriteOut (output_idx , short int , as_short (arg ));
247
229
break ;
248
230
case 'i' :
249
231
arg = PyTruffle_GetArg (v , kwds , kwdnames , rest_keywords_only );
250
232
v -> argnum ++ ;
251
233
PyTruffle_SkipOptionalArg (output_idx , arg , rest_optional );
252
- PyTruffle_WriteOutImmediate (output_idx , int , as_int (arg ));
234
+ PyTruffle_WriteOut (output_idx , int , as_int (arg ));
253
235
break ;
254
236
case 'I' :
255
237
arg = PyTruffle_GetArg (v , kwds , kwdnames , rest_keywords_only );
256
238
v -> argnum ++ ;
257
239
PyTruffle_SkipOptionalArg (output_idx , arg , rest_optional );
258
- PyTruffle_WriteOutImmediate (output_idx , unsigned int , as_int (arg ));
240
+ PyTruffle_WriteOut (output_idx , unsigned int , as_int (arg ));
259
241
break ;
260
242
case 'l' :
261
243
arg = PyTruffle_GetArg (v , kwds , kwdnames , rest_keywords_only );
262
244
v -> argnum ++ ;
263
245
PyTruffle_SkipOptionalArg (output_idx , arg , rest_optional );
264
- PyTruffle_WriteOutImmediate (output_idx , long , as_long (arg ));
246
+ PyTruffle_WriteOut (output_idx , long , as_long (arg ));
265
247
break ;
266
248
case 'k' :
267
249
arg = PyTruffle_GetArg (v , kwds , kwdnames , rest_keywords_only );
268
250
v -> argnum ++ ;
269
251
PyTruffle_SkipOptionalArg (output_idx , arg , rest_optional );
270
- PyTruffle_WriteOutImmediate (output_idx , unsigned long , as_long (arg ));
252
+ PyTruffle_WriteOut (output_idx , unsigned long , as_long (arg ));
271
253
break ;
272
254
case 'L' :
273
255
PyErr_Format (PyExc_TypeError , "long long argument parsing not yet supported" );
@@ -279,7 +261,7 @@ int PyTruffle_Arg_ParseTupleAndKeywords(PyObject *argv, PyObject *kwds, const ch
279
261
arg = PyTruffle_GetArg (v , kwds , kwdnames , rest_keywords_only );
280
262
v -> argnum ++ ;
281
263
PyTruffle_SkipOptionalArg (output_idx , arg , rest_optional );
282
- PyTruffle_WriteOutImmediate (output_idx , Py_ssize_t , as_long (arg ));
264
+ PyTruffle_WriteOut (output_idx , Py_ssize_t , as_long (arg ));
283
265
break ;
284
266
case 'c' :
285
267
arg = PyTruffle_GetArg (v , kwds , kwdnames , rest_keywords_only );
@@ -293,7 +275,7 @@ int PyTruffle_Arg_ParseTupleAndKeywords(PyObject *argv, PyObject *kwds, const ch
293
275
PyErr_Format (PyExc_TypeError , "expted bytes or bytearray of length 1, was length %d" , Py_SIZE (arg ));
294
276
return 0 ;
295
277
}
296
- PyTruffle_WriteOutImmediate (output_idx , char , as_char (polyglot_invoke (to_java (arg ), "__getitem__" , 0 )));
278
+ PyTruffle_WriteOut (output_idx , char , as_char (polyglot_invoke (to_java (arg ), "__getitem__" , 0 )));
297
279
break ;
298
280
case 'C' :
299
281
arg = PyTruffle_GetArg (v , kwds , kwdnames , rest_keywords_only );
@@ -307,19 +289,19 @@ int PyTruffle_Arg_ParseTupleAndKeywords(PyObject *argv, PyObject *kwds, const ch
307
289
PyErr_Format (PyExc_TypeError , "expted str of length 1, was length %d" , Py_SIZE (arg ));
308
290
return 0 ;
309
291
}
310
- PyTruffle_WriteOutImmediate (output_idx , int , as_int (polyglot_invoke (to_java (arg ), "__getitem__" , 0 )));
292
+ PyTruffle_WriteOut (output_idx , int , as_int (polyglot_invoke (to_java (arg ), "__getitem__" , 0 )));
311
293
break ;
312
294
case 'f' :
313
295
arg = PyTruffle_GetArg (v , kwds , kwdnames , rest_keywords_only );
314
296
v -> argnum ++ ;
315
297
PyTruffle_SkipOptionalArg (output_idx , arg , rest_optional );
316
- PyTruffle_WriteOutImmediate (output_idx , float , as_float (arg ));
298
+ PyTruffle_WriteOut (output_idx , float , as_float (arg ));
317
299
break ;
318
300
case 'd' :
319
301
arg = PyTruffle_GetArg (v , kwds , kwdnames , rest_keywords_only );
320
302
v -> argnum ++ ;
321
303
PyTruffle_SkipOptionalArg (output_idx , arg , rest_optional );
322
- PyTruffle_WriteOutImmediate (output_idx , double , as_double (arg ));
304
+ PyTruffle_WriteOut (output_idx , double , as_double (arg ));
323
305
break ;
324
306
case 'D' :
325
307
PyErr_Format (PyExc_TypeError , "converting complex arguments not implemented, yet" );
@@ -336,7 +318,7 @@ int PyTruffle_Arg_ParseTupleAndKeywords(PyObject *argv, PyObject *kwds, const ch
336
318
PyErr_Format (PyExc_TypeError , "expected object of type %R, got %R" , typeobject , Py_TYPE (arg ));
337
319
return 0 ;
338
320
}
339
- PyTruffle_WriteOut (output_idx , PyObject * , arg , rest_optional );
321
+ PyTruffle_WriteOut (output_idx , PyObject * , arg );
340
322
} else if (format [format_idx + 1 ] == '&' ) {
341
323
format_idx ++ ;
342
324
void * (* converter )(PyObject * ,void * ) = PyTruffle_ArgN (output_idx );
@@ -353,14 +335,14 @@ int PyTruffle_Arg_ParseTupleAndKeywords(PyObject *argv, PyObject *kwds, const ch
353
335
return 0 ;
354
336
}
355
337
} else {
356
- PyTruffle_WriteOut (output_idx , PyObject * , arg , rest_optional );
338
+ PyTruffle_WriteOut (output_idx , PyObject * , arg );
357
339
}
358
340
break ;
359
341
case 'p' :
360
342
arg = PyTruffle_GetArg (v , kwds , kwdnames , rest_keywords_only );
361
343
v -> argnum ++ ;
362
344
PyTruffle_SkipOptionalArg (output_idx , arg , rest_optional );
363
- PyTruffle_WriteOutImmediate (output_idx , int , as_int (truffle_invoke (to_java (arg ), "__bool__" )));
345
+ PyTruffle_WriteOut (output_idx , int , as_int (truffle_invoke (to_java (arg ), "__bool__" )));
364
346
break ;
365
347
case '(' :
366
348
arg = PyTruffle_GetArg (v , kwds , kwdnames , rest_keywords_only );
0 commit comments