4
4
#include "structmember.h" // PyMemberDef
5
5
#include <stddef.h> // offsetof
6
6
7
+ /*[clinic input]
8
+ module _testcapi
9
+ [clinic start generated code]*/
10
+ /*[clinic end generated code: output=da39a3ee5e6b4b0d input=6361033e795369fc]*/
7
11
8
12
/* Test PEP 590 - Vectorcall */
9
13
@@ -25,18 +29,22 @@ fastcall_args(PyObject *args, PyObject ***stack, Py_ssize_t *nargs)
25
29
return 0 ;
26
30
}
27
31
32
+ /*[clinic input]
33
+ _testcapi.pyobject_fastcalldict
34
+ func: object
35
+ func_args: object
36
+ kwargs: object
37
+ /
38
+ [clinic start generated code]*/
28
39
29
40
static 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]*/
31
44
{
32
- PyObject * func , * func_args , * kwargs ;
33
45
PyObject * * stack ;
34
46
Py_ssize_t nargs ;
35
47
36
- if (!PyArg_ParseTuple (args , "OOO" , & func , & func_args , & kwargs )) {
37
- return NULL ;
38
- }
39
-
40
48
if (fastcall_args (func_args , & stack , & nargs ) < 0 ) {
41
49
return NULL ;
42
50
}
@@ -52,17 +60,22 @@ test_pyobject_fastcalldict(PyObject *self, PyObject *args)
52
60
return PyObject_VectorcallDict (func , stack , nargs , kwargs );
53
61
}
54
62
63
+ /*[clinic input]
64
+ _testcapi.pyobject_vectorcall
65
+ func: object
66
+ func_args: object
67
+ kwnames: object
68
+ /
69
+ [clinic start generated code]*/
70
+
55
71
static 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]*/
57
75
{
58
- PyObject * func , * func_args , * kwnames = NULL ;
59
76
PyObject * * stack ;
60
77
Py_ssize_t nargs , nkw ;
61
78
62
- if (!PyArg_ParseTuple (args , "OOO" , & func , & func_args , & kwnames )) {
63
- return NULL ;
64
- }
65
-
66
79
if (fastcall_args (func_args , & stack , & nargs ) < 0 ) {
67
80
return NULL ;
68
81
}
@@ -103,17 +116,19 @@ function_setvectorcall(PyObject *self, PyObject *func)
103
116
Py_RETURN_NONE ;
104
117
}
105
118
119
+ /*[clinic input]
120
+ _testcapi.pyvectorcall_call
121
+ func: object
122
+ argstuple: object
123
+ kwargs: object = NULL
124
+ /
125
+ [clinic start generated code]*/
126
+
106
127
static 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]*/
108
131
{
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
-
117
132
if (!PyTuple_Check (argstuple )) {
118
133
PyErr_SetString (PyExc_TypeError , "args must be a tuple" );
119
134
return NULL ;
@@ -242,10 +257,10 @@ _testcapi_has_vectorcall_flag_impl(PyObject *module, PyTypeObject *type)
242
257
}
243
258
244
259
static 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
247
262
{"function_setvectorcall" , function_setvectorcall , METH_O },
248
- { "pyvectorcall_call" , test_pyvectorcall_call , METH_VARARGS },
263
+ _TESTCAPI_PYVECTORCALL_CALL_METHODDEF
249
264
_TESTCAPI_MAKE_VECTORCALL_CLASS_METHODDEF
250
265
_TESTCAPI_HAS_VECTORCALL_FLAG_METHODDEF
251
266
{NULL},
0 commit comments