Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-104469 Convert_testcapi/vectorcall.c to use AC #106557

Merged
merged 6 commits into from
Jul 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 101 additions & 1 deletion Modules/_testcapi/clinic/vectorcall.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

63 changes: 39 additions & 24 deletions Modules/_testcapi/vectorcall.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand All @@ -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;
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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},
Expand Down
Loading