0
0
mirror of https://github.com/python/cpython.git synced 2024-11-27 23:47:29 +01:00
cpython/Modules/_testcapi/clinic/vectorcall.c.h
Victor Stinner be5e8a0103
gh-110964: Remove private _PyArg functions (#110966)
Move the following private functions and structures to
pycore_modsupport.h internal C API:

* _PyArg_BadArgument()
* _PyArg_CheckPositional()
* _PyArg_NoKeywords()
* _PyArg_NoPositional()
* _PyArg_ParseStack()
* _PyArg_ParseStackAndKeywords()
* _PyArg_Parser structure
* _PyArg_UnpackKeywords()
* _PyArg_UnpackKeywordsWithVararg()
* _PyArg_UnpackStack()
* _Py_ANY_VARARGS()

Changes:

* Python/getargs.h now includes pycore_modsupport.h to export
  functions.
* clinic.py now adds pycore_modsupport.h when one of these functions
  is used.
* Add pycore_modsupport.h includes when a C extension uses one of
  these functions.
* Define Py_BUILD_CORE_MODULE in C extensions which now include
  directly or indirectly (via code generated by Argument Clinic)
  pycore_modsupport.h:

  * _csv
  * _curses_panel
  * _dbm
  * _gdbm
  * _multiprocessing.posixshmem
  * _sqlite.row
  * _statistics
  * grp
  * resource
  * syslog

* _testcapi: bad_get() no longer uses METH_FASTCALL calling
  convention but METH_VARARGS. Replace _PyArg_UnpackStack() with
  PyArg_ParseTuple().
* _testcapi: add PYTESTCAPI_NEED_INTERNAL_API macro which is defined
  by _testcapi sub-modules which need the internal C API
  (pycore_modsupport.h): exceptions.c, float.c, vectorcall.c,
  watchers.c.
* Remove Include/cpython/modsupport.h header file.
  Include/modsupport.h no longer includes the removed header file.
* Fix mypy clinic.py
2023-10-17 14:30:31 +02:00

210 lines
6.5 KiB
C
Generated

/*[clinic input]
preserve
[clinic start generated code]*/
#include "pycore_modsupport.h" // _PyArg_CheckPositional()
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"
"\n"
"Set self\'s vectorcall function for `type` to one that returns \"vectorcall\"");
#define _TESTCAPI_VECTORCALLCLASS_SET_VECTORCALL_METHODDEF \
{"set_vectorcall", (PyCFunction)_testcapi_VectorCallClass_set_vectorcall, METH_O, _testcapi_VectorCallClass_set_vectorcall__doc__},
static PyObject *
_testcapi_VectorCallClass_set_vectorcall_impl(PyObject *self,
PyTypeObject *type);
static PyObject *
_testcapi_VectorCallClass_set_vectorcall(PyObject *self, PyObject *arg)
{
PyObject *return_value = NULL;
PyTypeObject *type;
if (!PyObject_TypeCheck(arg, &PyType_Type)) {
_PyArg_BadArgument("set_vectorcall", "argument", (&PyType_Type)->tp_name, arg);
goto exit;
}
type = (PyTypeObject *)arg;
return_value = _testcapi_VectorCallClass_set_vectorcall_impl(self, type);
exit:
return return_value;
}
PyDoc_STRVAR(_testcapi_make_vectorcall_class__doc__,
"make_vectorcall_class($module, base=<unrepresentable>, /)\n"
"--\n"
"\n"
"Create a class whose instances return \"tpcall\" when called.\n"
"\n"
"When the \"set_vectorcall\" method is called on an instance, a vectorcall\n"
"function that returns \"vectorcall\" will be installed.");
#define _TESTCAPI_MAKE_VECTORCALL_CLASS_METHODDEF \
{"make_vectorcall_class", _PyCFunction_CAST(_testcapi_make_vectorcall_class), METH_FASTCALL, _testcapi_make_vectorcall_class__doc__},
static PyObject *
_testcapi_make_vectorcall_class_impl(PyObject *module, PyTypeObject *base);
static PyObject *
_testcapi_make_vectorcall_class(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
{
PyObject *return_value = NULL;
PyTypeObject *base = NULL;
if (!_PyArg_CheckPositional("make_vectorcall_class", nargs, 0, 1)) {
goto exit;
}
if (nargs < 1) {
goto skip_optional;
}
if (!PyObject_TypeCheck(args[0], &PyType_Type)) {
_PyArg_BadArgument("make_vectorcall_class", "argument 1", (&PyType_Type)->tp_name, args[0]);
goto exit;
}
base = (PyTypeObject *)args[0];
skip_optional:
return_value = _testcapi_make_vectorcall_class_impl(module, base);
exit:
return return_value;
}
PyDoc_STRVAR(_testcapi_has_vectorcall_flag__doc__,
"has_vectorcall_flag($module, type, /)\n"
"--\n"
"\n"
"Return true iff Py_TPFLAGS_HAVE_VECTORCALL is set on the class.");
#define _TESTCAPI_HAS_VECTORCALL_FLAG_METHODDEF \
{"has_vectorcall_flag", (PyCFunction)_testcapi_has_vectorcall_flag, METH_O, _testcapi_has_vectorcall_flag__doc__},
static int
_testcapi_has_vectorcall_flag_impl(PyObject *module, PyTypeObject *type);
static PyObject *
_testcapi_has_vectorcall_flag(PyObject *module, PyObject *arg)
{
PyObject *return_value = NULL;
PyTypeObject *type;
int _return_value;
if (!PyObject_TypeCheck(arg, &PyType_Type)) {
_PyArg_BadArgument("has_vectorcall_flag", "argument", (&PyType_Type)->tp_name, arg);
goto exit;
}
type = (PyTypeObject *)arg;
_return_value = _testcapi_has_vectorcall_flag_impl(module, type);
if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
}
return_value = PyBool_FromLong((long)_return_value);
exit:
return return_value;
}
/*[clinic end generated code: output=210ae67caab177ba input=a9049054013a1b77]*/