44#include "structmember.h" // PyMemberDef
55#include <stddef.h> // offsetof
66
7+ /*[clinic input]
8+ module _testcapi
9+ [clinic start generated code]*/
10+ /*[clinic end generated code: output=da39a3ee5e6b4b0d input=6361033e795369fc]*/
711
812/* Test PEP 590 - Vectorcall */
913
@@ -25,18 +29,22 @@ fastcall_args(PyObject *args, PyObject ***stack, Py_ssize_t *nargs)
2529 return 0 ;
2630}
2731
32+ /*[clinic input]
33+ _testcapi.pyobject_fastcalldict
34+ func: object
35+ func_args: object
36+ kwargs: object
37+ /
38+ [clinic start generated code]*/
2839
2940static PyObject *
30- test_pyobject_fastcalldict (PyObject * self , PyObject * args )
41+ _testcapi_pyobject_fastcalldict_impl (PyObject * module , PyObject * func ,
42+ PyObject * func_args , PyObject * kwargs )
43+ /*[clinic end generated code: output=35902ece94de4418 input=b9c0196ca7d5f9e4]*/
3144{
32- PyObject * func , * func_args , * kwargs ;
3345 PyObject * * stack ;
3446 Py_ssize_t nargs ;
3547
36- if (!PyArg_ParseTuple (args , "OOO" , & func , & func_args , & kwargs )) {
37- return NULL ;
38- }
39-
4048 if (fastcall_args (func_args , & stack , & nargs ) < 0 ) {
4149 return NULL ;
4250 }
@@ -52,17 +60,22 @@ test_pyobject_fastcalldict(PyObject *self, PyObject *args)
5260 return PyObject_VectorcallDict (func , stack , nargs , kwargs );
5361}
5462
63+ /*[clinic input]
64+ _testcapi.pyobject_vectorcall
65+ func: object
66+ func_args: object
67+ kwnames: object
68+ /
69+ [clinic start generated code]*/
70+
5571static PyObject *
56- test_pyobject_vectorcall (PyObject * self , PyObject * args )
72+ _testcapi_pyobject_vectorcall_impl (PyObject * module , PyObject * func ,
73+ PyObject * func_args , PyObject * kwnames )
74+ /*[clinic end generated code: output=ff77245bc6afe0d8 input=a0668dfef625764c]*/
5775{
58- PyObject * func , * func_args , * kwnames = NULL ;
5976 PyObject * * stack ;
6077 Py_ssize_t nargs , nkw ;
6178
62- if (!PyArg_ParseTuple (args , "OOO" , & func , & func_args , & kwnames )) {
63- return NULL ;
64- }
65-
6679 if (fastcall_args (func_args , & stack , & nargs ) < 0 ) {
6780 return NULL ;
6881 }
@@ -103,17 +116,19 @@ function_setvectorcall(PyObject *self, PyObject *func)
103116 Py_RETURN_NONE ;
104117}
105118
119+ /*[clinic input]
120+ _testcapi.pyvectorcall_call
121+ func: object
122+ argstuple: object
123+ kwargs: object = NULL
124+ /
125+ [clinic start generated code]*/
126+
106127static PyObject *
107- test_pyvectorcall_call (PyObject * self , PyObject * args )
128+ _testcapi_pyvectorcall_call_impl (PyObject * module , PyObject * func ,
129+ PyObject * argstuple , PyObject * kwargs )
130+ /*[clinic end generated code: output=809046fe78511306 input=4376ee7cabd698ce]*/
108131{
109- PyObject * func ;
110- PyObject * argstuple ;
111- PyObject * kwargs = NULL ;
112-
113- if (!PyArg_ParseTuple (args , "OO|O" , & func , & argstuple , & kwargs )) {
114- return NULL ;
115- }
116-
117132 if (!PyTuple_Check (argstuple )) {
118133 PyErr_SetString (PyExc_TypeError , "args must be a tuple" );
119134 return NULL ;
@@ -242,10 +257,10 @@ _testcapi_has_vectorcall_flag_impl(PyObject *module, PyTypeObject *type)
242257}
243258
244259static PyMethodDef TestMethods [] = {
245- { "pyobject_fastcalldict" , test_pyobject_fastcalldict , METH_VARARGS },
246- { "pyobject_vectorcall" , test_pyobject_vectorcall , METH_VARARGS },
260+ _TESTCAPI_PYOBJECT_FASTCALLDICT_METHODDEF
261+ _TESTCAPI_PYOBJECT_VECTORCALL_METHODDEF
247262 {"function_setvectorcall" , function_setvectorcall , METH_O },
248- { "pyvectorcall_call" , test_pyvectorcall_call , METH_VARARGS },
263+ _TESTCAPI_PYVECTORCALL_CALL_METHODDEF
249264 _TESTCAPI_MAKE_VECTORCALL_CLASS_METHODDEF
250265 _TESTCAPI_HAS_VECTORCALL_FLAG_METHODDEF
251266 {NULL},
0 commit comments