| 1 |
/*[clinic input] |
| 2 |
preserve |
| 3 |
[clinic start generated code]*/ |
| 4 |
|
| 5 |
#include "pycore_modsupport.h" // _PyArg_CheckPositional() |
| 6 |
|
| 7 |
PyDoc_STRVAR(_testcapi_pyobject_fastcalldict__doc__, |
| 8 |
"pyobject_fastcalldict($module, func, func_args, kwargs, /)\n" |
| 9 |
"--\n" |
| 10 |
"\n"); |
| 11 |
|
| 12 |
#define _TESTCAPI_PYOBJECT_FASTCALLDICT_METHODDEF \ |
| 13 |
{"pyobject_fastcalldict", _PyCFunction_CAST(_testcapi_pyobject_fastcalldict), METH_FASTCALL, _testcapi_pyobject_fastcalldict__doc__}, |
| 14 |
|
| 15 |
static PyObject * |
| 16 |
_testcapi_pyobject_fastcalldict_impl(PyObject *module, PyObject *func, |
| 17 |
PyObject *func_args, PyObject *kwargs); |
| 18 |
|
| 19 |
static PyObject * |
| 20 |
_testcapi_pyobject_fastcalldict(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
| 21 |
{ |
| 22 |
PyObject *return_value = NULL; |
| 23 |
PyObject *func; |
| 24 |
PyObject *func_args; |
| 25 |
PyObject *__clinic_kwargs; |
| 26 |
|
| 27 |
if (!_PyArg_CheckPositional("pyobject_fastcalldict", nargs, 3, 3)) { |
| 28 |
goto exit; |
| 29 |
} |
| 30 |
func = args[0]; |
| 31 |
func_args = args[1]; |
| 32 |
__clinic_kwargs = args[2]; |
| 33 |
return_value = _testcapi_pyobject_fastcalldict_impl(module, func, func_args, __clinic_kwargs); |
| 34 |
|
| 35 |
exit: |
| 36 |
return return_value; |
| 37 |
} |
| 38 |
|
| 39 |
PyDoc_STRVAR(_testcapi_pyobject_vectorcall__doc__, |
| 40 |
"pyobject_vectorcall($module, func, func_args, kwnames, /)\n" |
| 41 |
"--\n" |
| 42 |
"\n"); |
| 43 |
|
| 44 |
#define _TESTCAPI_PYOBJECT_VECTORCALL_METHODDEF \ |
| 45 |
{"pyobject_vectorcall", _PyCFunction_CAST(_testcapi_pyobject_vectorcall), METH_FASTCALL, _testcapi_pyobject_vectorcall__doc__}, |
| 46 |
|
| 47 |
static PyObject * |
| 48 |
_testcapi_pyobject_vectorcall_impl(PyObject *module, PyObject *func, |
| 49 |
PyObject *func_args, PyObject *kwnames); |
| 50 |
|
| 51 |
static PyObject * |
| 52 |
_testcapi_pyobject_vectorcall(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
| 53 |
{ |
| 54 |
PyObject *return_value = NULL; |
| 55 |
PyObject *func; |
| 56 |
PyObject *func_args; |
| 57 |
PyObject *__clinic_kwnames; |
| 58 |
|
| 59 |
if (!_PyArg_CheckPositional("pyobject_vectorcall", nargs, 3, 3)) { |
| 60 |
goto exit; |
| 61 |
} |
| 62 |
func = args[0]; |
| 63 |
func_args = args[1]; |
| 64 |
__clinic_kwnames = args[2]; |
| 65 |
return_value = _testcapi_pyobject_vectorcall_impl(module, func, func_args, __clinic_kwnames); |
| 66 |
|
| 67 |
exit: |
| 68 |
return return_value; |
| 69 |
} |
| 70 |
|
| 71 |
PyDoc_STRVAR(_testcapi_pyvectorcall_call__doc__, |
| 72 |
"pyvectorcall_call($module, func, argstuple, kwargs=<unrepresentable>, /)\n" |
| 73 |
"--\n" |
| 74 |
"\n"); |
| 75 |
|
| 76 |
#define _TESTCAPI_PYVECTORCALL_CALL_METHODDEF \ |
| 77 |
{"pyvectorcall_call", _PyCFunction_CAST(_testcapi_pyvectorcall_call), METH_FASTCALL, _testcapi_pyvectorcall_call__doc__}, |
| 78 |
|
| 79 |
static PyObject * |
| 80 |
_testcapi_pyvectorcall_call_impl(PyObject *module, PyObject *func, |
| 81 |
PyObject *argstuple, PyObject *kwargs); |
| 82 |
|
| 83 |
static PyObject * |
| 84 |
_testcapi_pyvectorcall_call(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
| 85 |
{ |
| 86 |
PyObject *return_value = NULL; |
| 87 |
PyObject *func; |
| 88 |
PyObject *argstuple; |
| 89 |
PyObject *__clinic_kwargs = NULL; |
| 90 |
|
| 91 |
if (!_PyArg_CheckPositional("pyvectorcall_call", nargs, 2, 3)) { |
| 92 |
goto exit; |
| 93 |
} |
| 94 |
func = args[0]; |
| 95 |
argstuple = args[1]; |
| 96 |
if (nargs < 3) { |
| 97 |
goto skip_optional; |
| 98 |
} |
| 99 |
__clinic_kwargs = args[2]; |
| 100 |
skip_optional: |
| 101 |
return_value = _testcapi_pyvectorcall_call_impl(module, func, argstuple, __clinic_kwargs); |
| 102 |
|
| 103 |
exit: |
| 104 |
return return_value; |
| 105 |
} |
| 106 |
|
| 107 |
PyDoc_STRVAR(_testcapi_VectorCallClass_set_vectorcall__doc__, |
| 108 |
"set_vectorcall($self, type, /)\n" |
| 109 |
"--\n" |
| 110 |
"\n" |
| 111 |
"Set self\'s vectorcall function for `type` to one that returns \"vectorcall\""); |
| 112 |
|
| 113 |
#define _TESTCAPI_VECTORCALLCLASS_SET_VECTORCALL_METHODDEF \ |
| 114 |
{"set_vectorcall", (PyCFunction)_testcapi_VectorCallClass_set_vectorcall, METH_O, _testcapi_VectorCallClass_set_vectorcall__doc__}, |
| 115 |
|
| 116 |
static PyObject * |
| 117 |
_testcapi_VectorCallClass_set_vectorcall_impl(PyObject *self, |
| 118 |
PyTypeObject *type); |
| 119 |
|
| 120 |
static PyObject * |
| 121 |
_testcapi_VectorCallClass_set_vectorcall(PyObject *self, PyObject *arg) |
| 122 |
{ |
| 123 |
PyObject *return_value = NULL; |
| 124 |
PyTypeObject *type; |
| 125 |
|
| 126 |
if (!PyObject_TypeCheck(arg, &PyType_Type)) { |
| 127 |
_PyArg_BadArgument("set_vectorcall", "argument", (&PyType_Type)->tp_name, arg); |
| 128 |
goto exit; |
| 129 |
} |
| 130 |
type = (PyTypeObject *)arg; |
| 131 |
return_value = _testcapi_VectorCallClass_set_vectorcall_impl(self, type); |
| 132 |
|
| 133 |
exit: |
| 134 |
return return_value; |
| 135 |
} |
| 136 |
|
| 137 |
PyDoc_STRVAR(_testcapi_make_vectorcall_class__doc__, |
| 138 |
"make_vectorcall_class($module, base=<unrepresentable>, /)\n" |
| 139 |
"--\n" |
| 140 |
"\n" |
| 141 |
"Create a class whose instances return \"tpcall\" when called.\n" |
| 142 |
"\n" |
| 143 |
"When the \"set_vectorcall\" method is called on an instance, a vectorcall\n" |
| 144 |
"function that returns \"vectorcall\" will be installed."); |
| 145 |
|
| 146 |
#define _TESTCAPI_MAKE_VECTORCALL_CLASS_METHODDEF \ |
| 147 |
{"make_vectorcall_class", _PyCFunction_CAST(_testcapi_make_vectorcall_class), METH_FASTCALL, _testcapi_make_vectorcall_class__doc__}, |
| 148 |
|
| 149 |
static PyObject * |
| 150 |
_testcapi_make_vectorcall_class_impl(PyObject *module, PyTypeObject *base); |
| 151 |
|
| 152 |
static PyObject * |
| 153 |
_testcapi_make_vectorcall_class(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
| 154 |
{ |
| 155 |
PyObject *return_value = NULL; |
| 156 |
PyTypeObject *base = NULL; |
| 157 |
|
| 158 |
if (!_PyArg_CheckPositional("make_vectorcall_class", nargs, 0, 1)) { |
| 159 |
goto exit; |
| 160 |
} |
| 161 |
if (nargs < 1) { |
| 162 |
goto skip_optional; |
| 163 |
} |
| 164 |
if (!PyObject_TypeCheck(args[0], &PyType_Type)) { |
| 165 |
_PyArg_BadArgument("make_vectorcall_class", "argument 1", (&PyType_Type)->tp_name, args[0]); |
| 166 |
goto exit; |
| 167 |
} |
| 168 |
base = (PyTypeObject *)args[0]; |
| 169 |
skip_optional: |
| 170 |
return_value = _testcapi_make_vectorcall_class_impl(module, base); |
| 171 |
|
| 172 |
exit: |
| 173 |
return return_value; |
| 174 |
} |
| 175 |
|
| 176 |
PyDoc_STRVAR(_testcapi_has_vectorcall_flag__doc__, |
| 177 |
"has_vectorcall_flag($module, type, /)\n" |
| 178 |
"--\n" |
| 179 |
"\n" |
| 180 |
"Return true iff Py_TPFLAGS_HAVE_VECTORCALL is set on the class."); |
| 181 |
|
| 182 |
#define _TESTCAPI_HAS_VECTORCALL_FLAG_METHODDEF \ |
| 183 |
{"has_vectorcall_flag", (PyCFunction)_testcapi_has_vectorcall_flag, METH_O, _testcapi_has_vectorcall_flag__doc__}, |
| 184 |
|
| 185 |
static int |
| 186 |
_testcapi_has_vectorcall_flag_impl(PyObject *module, PyTypeObject *type); |
| 187 |
|
| 188 |
static PyObject * |
| 189 |
_testcapi_has_vectorcall_flag(PyObject *module, PyObject *arg) |
| 190 |
{ |
| 191 |
PyObject *return_value = NULL; |
| 192 |
PyTypeObject *type; |
| 193 |
int _return_value; |
| 194 |
|
| 195 |
if (!PyObject_TypeCheck(arg, &PyType_Type)) { |
| 196 |
_PyArg_BadArgument("has_vectorcall_flag", "argument", (&PyType_Type)->tp_name, arg); |
| 197 |
goto exit; |
| 198 |
} |
| 199 |
type = (PyTypeObject *)arg; |
| 200 |
_return_value = _testcapi_has_vectorcall_flag_impl(module, type); |
| 201 |
if ((_return_value == -1) && PyErr_Occurred()) { |
| 202 |
goto exit; |
| 203 |
} |
| 204 |
return_value = PyBool_FromLong((long)_return_value); |
| 205 |
|
| 206 |
exit: |
| 207 |
return return_value; |
| 208 |
} |
| 209 |
/*[clinic end generated code: output=210ae67caab177ba input=a9049054013a1b77]*/ |