diff options
author | Nikita Sobolev <mail@sobolevn.me> | 2023-05-15 20:59:41 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-15 20:59:41 (GMT) |
commit | 456d56698db6c6287500f591927c900a5f5221ca (patch) | |
tree | 81f2a3767f4536692e62b75f5d34749c6fdb09ee /Modules/_testcapi/clinic/watchers.c.h | |
parent | 8a3702f0c79e5a99fcef61e35724f4b9ea3453b8 (diff) | |
download | cpython-456d56698db6c6287500f591927c900a5f5221ca.zip cpython-456d56698db6c6287500f591927c900a5f5221ca.tar.gz cpython-456d56698db6c6287500f591927c900a5f5221ca.tar.bz2 |
gh-104469: Convert _testcapi/watchers.c to use Argument Clinic (#104503)
Remove boilerplate code by converting the following functions:
- _testcapi.watch_dict
- _testcapi.unwatch_dict
- _testcapi.watch_type
- _testcapi.unwatch_type
- _testcapi.set_func_defaults_via_capi
- _testcapi.set_func_kwdefaults_via_capi
Diffstat (limited to 'Modules/_testcapi/clinic/watchers.c.h')
-rw-r--r-- | Modules/_testcapi/clinic/watchers.c.h | 198 |
1 files changed, 198 insertions, 0 deletions
diff --git a/Modules/_testcapi/clinic/watchers.c.h b/Modules/_testcapi/clinic/watchers.c.h new file mode 100644 index 0000000..975244b --- /dev/null +++ b/Modules/_testcapi/clinic/watchers.c.h @@ -0,0 +1,198 @@ +/*[clinic input] +preserve +[clinic start generated code]*/ + +#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) +# include "pycore_gc.h" // PyGC_Head +# include "pycore_runtime.h" // _Py_ID() +#endif + + +PyDoc_STRVAR(_testcapi_watch_dict__doc__, +"watch_dict($module, watcher_id, dict, /)\n" +"--\n" +"\n"); + +#define _TESTCAPI_WATCH_DICT_METHODDEF \ + {"watch_dict", _PyCFunction_CAST(_testcapi_watch_dict), METH_FASTCALL, _testcapi_watch_dict__doc__}, + +static PyObject * +_testcapi_watch_dict_impl(PyObject *module, int watcher_id, PyObject *dict); + +static PyObject * +_testcapi_watch_dict(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + int watcher_id; + PyObject *dict; + + if (!_PyArg_CheckPositional("watch_dict", nargs, 2, 2)) { + goto exit; + } + watcher_id = _PyLong_AsInt(args[0]); + if (watcher_id == -1 && PyErr_Occurred()) { + goto exit; + } + dict = args[1]; + return_value = _testcapi_watch_dict_impl(module, watcher_id, dict); + +exit: + return return_value; +} + +PyDoc_STRVAR(_testcapi_unwatch_dict__doc__, +"unwatch_dict($module, watcher_id, dict, /)\n" +"--\n" +"\n"); + +#define _TESTCAPI_UNWATCH_DICT_METHODDEF \ + {"unwatch_dict", _PyCFunction_CAST(_testcapi_unwatch_dict), METH_FASTCALL, _testcapi_unwatch_dict__doc__}, + +static PyObject * +_testcapi_unwatch_dict_impl(PyObject *module, int watcher_id, PyObject *dict); + +static PyObject * +_testcapi_unwatch_dict(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + int watcher_id; + PyObject *dict; + + if (!_PyArg_CheckPositional("unwatch_dict", nargs, 2, 2)) { + goto exit; + } + watcher_id = _PyLong_AsInt(args[0]); + if (watcher_id == -1 && PyErr_Occurred()) { + goto exit; + } + dict = args[1]; + return_value = _testcapi_unwatch_dict_impl(module, watcher_id, dict); + +exit: + return return_value; +} + +PyDoc_STRVAR(_testcapi_watch_type__doc__, +"watch_type($module, watcher_id, type, /)\n" +"--\n" +"\n"); + +#define _TESTCAPI_WATCH_TYPE_METHODDEF \ + {"watch_type", _PyCFunction_CAST(_testcapi_watch_type), METH_FASTCALL, _testcapi_watch_type__doc__}, + +static PyObject * +_testcapi_watch_type_impl(PyObject *module, int watcher_id, PyObject *type); + +static PyObject * +_testcapi_watch_type(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + int watcher_id; + PyObject *type; + + if (!_PyArg_CheckPositional("watch_type", nargs, 2, 2)) { + goto exit; + } + watcher_id = _PyLong_AsInt(args[0]); + if (watcher_id == -1 && PyErr_Occurred()) { + goto exit; + } + type = args[1]; + return_value = _testcapi_watch_type_impl(module, watcher_id, type); + +exit: + return return_value; +} + +PyDoc_STRVAR(_testcapi_unwatch_type__doc__, +"unwatch_type($module, watcher_id, type, /)\n" +"--\n" +"\n"); + +#define _TESTCAPI_UNWATCH_TYPE_METHODDEF \ + {"unwatch_type", _PyCFunction_CAST(_testcapi_unwatch_type), METH_FASTCALL, _testcapi_unwatch_type__doc__}, + +static PyObject * +_testcapi_unwatch_type_impl(PyObject *module, int watcher_id, PyObject *type); + +static PyObject * +_testcapi_unwatch_type(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + int watcher_id; + PyObject *type; + + if (!_PyArg_CheckPositional("unwatch_type", nargs, 2, 2)) { + goto exit; + } + watcher_id = _PyLong_AsInt(args[0]); + if (watcher_id == -1 && PyErr_Occurred()) { + goto exit; + } + type = args[1]; + return_value = _testcapi_unwatch_type_impl(module, watcher_id, type); + +exit: + return return_value; +} + +PyDoc_STRVAR(_testcapi_set_func_defaults_via_capi__doc__, +"set_func_defaults_via_capi($module, func, defaults, /)\n" +"--\n" +"\n"); + +#define _TESTCAPI_SET_FUNC_DEFAULTS_VIA_CAPI_METHODDEF \ + {"set_func_defaults_via_capi", _PyCFunction_CAST(_testcapi_set_func_defaults_via_capi), METH_FASTCALL, _testcapi_set_func_defaults_via_capi__doc__}, + +static PyObject * +_testcapi_set_func_defaults_via_capi_impl(PyObject *module, PyObject *func, + PyObject *defaults); + +static PyObject * +_testcapi_set_func_defaults_via_capi(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + PyObject *func; + PyObject *defaults; + + if (!_PyArg_CheckPositional("set_func_defaults_via_capi", nargs, 2, 2)) { + goto exit; + } + func = args[0]; + defaults = args[1]; + return_value = _testcapi_set_func_defaults_via_capi_impl(module, func, defaults); + +exit: + return return_value; +} + +PyDoc_STRVAR(_testcapi_set_func_kwdefaults_via_capi__doc__, +"set_func_kwdefaults_via_capi($module, func, defaults, /)\n" +"--\n" +"\n"); + +#define _TESTCAPI_SET_FUNC_KWDEFAULTS_VIA_CAPI_METHODDEF \ + {"set_func_kwdefaults_via_capi", _PyCFunction_CAST(_testcapi_set_func_kwdefaults_via_capi), METH_FASTCALL, _testcapi_set_func_kwdefaults_via_capi__doc__}, + +static PyObject * +_testcapi_set_func_kwdefaults_via_capi_impl(PyObject *module, PyObject *func, + PyObject *defaults); + +static PyObject * +_testcapi_set_func_kwdefaults_via_capi(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +{ + PyObject *return_value = NULL; + PyObject *func; + PyObject *defaults; + + if (!_PyArg_CheckPositional("set_func_kwdefaults_via_capi", nargs, 2, 2)) { + goto exit; + } + func = args[0]; + defaults = args[1]; + return_value = _testcapi_set_func_kwdefaults_via_capi_impl(module, func, defaults); + +exit: + return return_value; +} +/*[clinic end generated code: output=12c375089125d165 input=a9049054013a1b77]*/ |