mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
gh-104469: Convert_testcapi/vectorcall.c to use AC (gh-106557)
This commit is contained in:
parent
8cb6f9761e
commit
d137c2cae2
2 changed files with 140 additions and 25 deletions
102
Modules/_testcapi/clinic/vectorcall.c.h
generated
102
Modules/_testcapi/clinic/vectorcall.c.h
generated
|
@ -8,6 +8,106 @@ preserve
|
|||
#endif
|
||||
|
||||
|
||||
PyDoc_STRVAR(_testcapi_pyobject_fastcalldict__doc__,
|
||||
"pyobject_fastcalldict($module, func, func_args, kwargs, /)\n"
|
||||
"--\n"
|
||||
"\n");
|
||||
|
||||
#define _TESTCAPI_PYOBJECT_FASTCALLDICT_METHODDEF \
|
||||
{"pyobject_fastcalldict", _PyCFunction_CAST(_testcapi_pyobject_fastcalldict), METH_FASTCALL, _testcapi_pyobject_fastcalldict__doc__},
|
||||
|
||||
static PyObject *
|
||||
_testcapi_pyobject_fastcalldict_impl(PyObject *module, PyObject *func,
|
||||
PyObject *func_args, PyObject *kwargs);
|
||||
|
||||
static PyObject *
|
||||
_testcapi_pyobject_fastcalldict(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
PyObject *func;
|
||||
PyObject *func_args;
|
||||
PyObject *__clinic_kwargs;
|
||||
|
||||
if (!_PyArg_CheckPositional("pyobject_fastcalldict", nargs, 3, 3)) {
|
||||
goto exit;
|
||||
}
|
||||
func = args[0];
|
||||
func_args = args[1];
|
||||
__clinic_kwargs = args[2];
|
||||
return_value = _testcapi_pyobject_fastcalldict_impl(module, func, func_args, __clinic_kwargs);
|
||||
|
||||
exit:
|
||||
return return_value;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(_testcapi_pyobject_vectorcall__doc__,
|
||||
"pyobject_vectorcall($module, func, func_args, kwnames, /)\n"
|
||||
"--\n"
|
||||
"\n");
|
||||
|
||||
#define _TESTCAPI_PYOBJECT_VECTORCALL_METHODDEF \
|
||||
{"pyobject_vectorcall", _PyCFunction_CAST(_testcapi_pyobject_vectorcall), METH_FASTCALL, _testcapi_pyobject_vectorcall__doc__},
|
||||
|
||||
static PyObject *
|
||||
_testcapi_pyobject_vectorcall_impl(PyObject *module, PyObject *func,
|
||||
PyObject *func_args, PyObject *kwnames);
|
||||
|
||||
static PyObject *
|
||||
_testcapi_pyobject_vectorcall(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
PyObject *func;
|
||||
PyObject *func_args;
|
||||
PyObject *__clinic_kwnames;
|
||||
|
||||
if (!_PyArg_CheckPositional("pyobject_vectorcall", nargs, 3, 3)) {
|
||||
goto exit;
|
||||
}
|
||||
func = args[0];
|
||||
func_args = args[1];
|
||||
__clinic_kwnames = args[2];
|
||||
return_value = _testcapi_pyobject_vectorcall_impl(module, func, func_args, __clinic_kwnames);
|
||||
|
||||
exit:
|
||||
return return_value;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(_testcapi_pyvectorcall_call__doc__,
|
||||
"pyvectorcall_call($module, func, argstuple, kwargs=<unrepresentable>, /)\n"
|
||||
"--\n"
|
||||
"\n");
|
||||
|
||||
#define _TESTCAPI_PYVECTORCALL_CALL_METHODDEF \
|
||||
{"pyvectorcall_call", _PyCFunction_CAST(_testcapi_pyvectorcall_call), METH_FASTCALL, _testcapi_pyvectorcall_call__doc__},
|
||||
|
||||
static PyObject *
|
||||
_testcapi_pyvectorcall_call_impl(PyObject *module, PyObject *func,
|
||||
PyObject *argstuple, PyObject *kwargs);
|
||||
|
||||
static PyObject *
|
||||
_testcapi_pyvectorcall_call(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
PyObject *func;
|
||||
PyObject *argstuple;
|
||||
PyObject *__clinic_kwargs = NULL;
|
||||
|
||||
if (!_PyArg_CheckPositional("pyvectorcall_call", nargs, 2, 3)) {
|
||||
goto exit;
|
||||
}
|
||||
func = args[0];
|
||||
argstuple = args[1];
|
||||
if (nargs < 3) {
|
||||
goto skip_optional;
|
||||
}
|
||||
__clinic_kwargs = args[2];
|
||||
skip_optional:
|
||||
return_value = _testcapi_pyvectorcall_call_impl(module, func, argstuple, __clinic_kwargs);
|
||||
|
||||
exit:
|
||||
return return_value;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(_testcapi_VectorCallClass_set_vectorcall__doc__,
|
||||
"set_vectorcall($self, type, /)\n"
|
||||
"--\n"
|
||||
|
@ -110,4 +210,4 @@ _testcapi_has_vectorcall_flag(PyObject *module, PyObject *arg)
|
|||
exit:
|
||||
return return_value;
|
||||
}
|
||||
/*[clinic end generated code: output=609569aa9942584f input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=beaf6beac3d13c25 input=a9049054013a1b77]*/
|
||||
|
|
|
@ -4,6 +4,10 @@
|
|||
#include "structmember.h" // PyMemberDef
|
||||
#include <stddef.h> // offsetof
|
||||
|
||||
/*[clinic input]
|
||||
module _testcapi
|
||||
[clinic start generated code]*/
|
||||
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=6361033e795369fc]*/
|
||||
|
||||
/* Test PEP 590 - Vectorcall */
|
||||
|
||||
|
@ -25,18 +29,22 @@ fastcall_args(PyObject *args, PyObject ***stack, Py_ssize_t *nargs)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/*[clinic input]
|
||||
_testcapi.pyobject_fastcalldict
|
||||
func: object
|
||||
func_args: object
|
||||
kwargs: object
|
||||
/
|
||||
[clinic start generated code]*/
|
||||
|
||||
static PyObject *
|
||||
test_pyobject_fastcalldict(PyObject *self, PyObject *args)
|
||||
_testcapi_pyobject_fastcalldict_impl(PyObject *module, PyObject *func,
|
||||
PyObject *func_args, PyObject *kwargs)
|
||||
/*[clinic end generated code: output=35902ece94de4418 input=b9c0196ca7d5f9e4]*/
|
||||
{
|
||||
PyObject *func, *func_args, *kwargs;
|
||||
PyObject **stack;
|
||||
Py_ssize_t nargs;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "OOO", &func, &func_args, &kwargs)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (fastcall_args(func_args, &stack, &nargs) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -52,17 +60,22 @@ test_pyobject_fastcalldict(PyObject *self, PyObject *args)
|
|||
return PyObject_VectorcallDict(func, stack, nargs, kwargs);
|
||||
}
|
||||
|
||||
/*[clinic input]
|
||||
_testcapi.pyobject_vectorcall
|
||||
func: object
|
||||
func_args: object
|
||||
kwnames: object
|
||||
/
|
||||
[clinic start generated code]*/
|
||||
|
||||
static PyObject *
|
||||
test_pyobject_vectorcall(PyObject *self, PyObject *args)
|
||||
_testcapi_pyobject_vectorcall_impl(PyObject *module, PyObject *func,
|
||||
PyObject *func_args, PyObject *kwnames)
|
||||
/*[clinic end generated code: output=ff77245bc6afe0d8 input=a0668dfef625764c]*/
|
||||
{
|
||||
PyObject *func, *func_args, *kwnames = NULL;
|
||||
PyObject **stack;
|
||||
Py_ssize_t nargs, nkw;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "OOO", &func, &func_args, &kwnames)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (fastcall_args(func_args, &stack, &nargs) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -103,17 +116,19 @@ function_setvectorcall(PyObject *self, PyObject *func)
|
|||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
/*[clinic input]
|
||||
_testcapi.pyvectorcall_call
|
||||
func: object
|
||||
argstuple: object
|
||||
kwargs: object = NULL
|
||||
/
|
||||
[clinic start generated code]*/
|
||||
|
||||
static PyObject *
|
||||
test_pyvectorcall_call(PyObject *self, PyObject *args)
|
||||
_testcapi_pyvectorcall_call_impl(PyObject *module, PyObject *func,
|
||||
PyObject *argstuple, PyObject *kwargs)
|
||||
/*[clinic end generated code: output=809046fe78511306 input=4376ee7cabd698ce]*/
|
||||
{
|
||||
PyObject *func;
|
||||
PyObject *argstuple;
|
||||
PyObject *kwargs = NULL;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "OO|O", &func, &argstuple, &kwargs)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!PyTuple_Check(argstuple)) {
|
||||
PyErr_SetString(PyExc_TypeError, "args must be a tuple");
|
||||
return NULL;
|
||||
|
@ -242,10 +257,10 @@ _testcapi_has_vectorcall_flag_impl(PyObject *module, PyTypeObject *type)
|
|||
}
|
||||
|
||||
static PyMethodDef TestMethods[] = {
|
||||
{"pyobject_fastcalldict", test_pyobject_fastcalldict, METH_VARARGS},
|
||||
{"pyobject_vectorcall", test_pyobject_vectorcall, METH_VARARGS},
|
||||
_TESTCAPI_PYOBJECT_FASTCALLDICT_METHODDEF
|
||||
_TESTCAPI_PYOBJECT_VECTORCALL_METHODDEF
|
||||
{"function_setvectorcall", function_setvectorcall, METH_O},
|
||||
{"pyvectorcall_call", test_pyvectorcall_call, METH_VARARGS},
|
||||
_TESTCAPI_PYVECTORCALL_CALL_METHODDEF
|
||||
_TESTCAPI_MAKE_VECTORCALL_CLASS_METHODDEF
|
||||
_TESTCAPI_HAS_VECTORCALL_FLAG_METHODDEF
|
||||
{NULL},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue