0
0
mirror of https://github.com/python/cpython.git synced 2024-11-24 17:47:13 +01:00
cpython/Modules/_testcapi/clinic/float.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

85 lines
2.2 KiB
C
Generated

/*[clinic input]
preserve
[clinic start generated code]*/
#include "pycore_modsupport.h" // _PyArg_CheckPositional()
PyDoc_STRVAR(_testcapi_float_pack__doc__,
"float_pack($module, size, d, le, /)\n"
"--\n"
"\n"
"Test PyFloat_Pack2(), PyFloat_Pack4() and PyFloat_Pack8()");
#define _TESTCAPI_FLOAT_PACK_METHODDEF \
{"float_pack", _PyCFunction_CAST(_testcapi_float_pack), METH_FASTCALL, _testcapi_float_pack__doc__},
static PyObject *
_testcapi_float_pack_impl(PyObject *module, int size, double d, int le);
static PyObject *
_testcapi_float_pack(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
{
PyObject *return_value = NULL;
int size;
double d;
int le;
if (!_PyArg_CheckPositional("float_pack", nargs, 3, 3)) {
goto exit;
}
size = PyLong_AsInt(args[0]);
if (size == -1 && PyErr_Occurred()) {
goto exit;
}
if (PyFloat_CheckExact(args[1])) {
d = PyFloat_AS_DOUBLE(args[1]);
}
else
{
d = PyFloat_AsDouble(args[1]);
if (d == -1.0 && PyErr_Occurred()) {
goto exit;
}
}
le = PyLong_AsInt(args[2]);
if (le == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = _testcapi_float_pack_impl(module, size, d, le);
exit:
return return_value;
}
PyDoc_STRVAR(_testcapi_float_unpack__doc__,
"float_unpack($module, data, le, /)\n"
"--\n"
"\n"
"Test PyFloat_Unpack2(), PyFloat_Unpack4() and PyFloat_Unpack8()");
#define _TESTCAPI_FLOAT_UNPACK_METHODDEF \
{"float_unpack", _PyCFunction_CAST(_testcapi_float_unpack), METH_FASTCALL, _testcapi_float_unpack__doc__},
static PyObject *
_testcapi_float_unpack_impl(PyObject *module, const char *data,
Py_ssize_t data_length, int le);
static PyObject *
_testcapi_float_unpack(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
{
PyObject *return_value = NULL;
const char *data;
Py_ssize_t data_length;
int le;
if (!_PyArg_ParseStack(args, nargs, "y#i:float_unpack",
&data, &data_length, &le)) {
goto exit;
}
return_value = _testcapi_float_unpack_impl(module, data, data_length, le);
exit:
return return_value;
}
/*[clinic end generated code: output=b43dfd3a77fe04ba input=a9049054013a1b77]*/