Skip to content

Commit

Permalink
Add declarations for private functions from pycore_modsupport
Browse files Browse the repository at this point in the history
python/cpython#110964
Copied from pycore_modsupport.h

remove PY_SSIZE_T_CLEAN definition
python/cpython#104922
  • Loading branch information
pmbarrett314 committed Nov 28, 2024
1 parent ff12559 commit 9402bb9
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 4 deletions.
1 change: 1 addition & 0 deletions py313/_curses_panel.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ static const char PyCursesVersion[] = "2.1";

/* Includes */


#include "Python.h"

#include "py_curses.h"
Expand Down
2 changes: 0 additions & 2 deletions py313/_cursesmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@ static const char PyCursesVersion[] = "2.2";

/* Includes */

#define PY_SSIZE_T_CLEAN

#include "Python.h"

/* This function declaration was moved from pycore_structseq.h file to adapt
Expand Down
24 changes: 23 additions & 1 deletion py313/clinic/_curses_panel.c.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,32 @@ preserve
[clinic start generated code]*/

#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
# include "pycore_modsupport.h"
# include "pycore_runtime.h" // _Py_SINGLETON()
#endif

// Export for 'math' shared extension
PyAPI_FUNC(PyObject * const *) _PyArg_UnpackKeywords(
PyObject *const *args,
Py_ssize_t nargs,
PyObject *kwargs,
PyObject *kwnames,
struct _PyArg_Parser *parser,
int minpos,
int maxpos,
int minkw,
PyObject **buf);
#define _PyArg_UnpackKeywords(args, nargs, kwargs, kwnames, parser, minpos, maxpos, minkw, buf) \
(((minkw) == 0 && (kwargs) == NULL && (kwnames) == NULL && \
(minpos) <= (nargs) && (nargs) <= (maxpos) && (args) != NULL) ? (args) : \
_PyArg_UnpackKeywords((args), (nargs), (kwargs), (kwnames), (parser), \
(minpos), (maxpos), (minkw), (buf)))

// Export for '_heapq' shared extension
PyAPI_FUNC(void) _PyArg_BadArgument(
const char *fname,
const char *displayname,
const char *expected,
PyObject *arg);

PyDoc_STRVAR(_curses_panel_panel_bottom__doc__,
"bottom($self, /)\n"
Expand Down
39 changes: 38 additions & 1 deletion py313/clinic/_cursesmodule.c.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,48 @@ preserve
[clinic start generated code]*/

#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
# include "pycore_modsupport.h"
# include "pycore_gc.h" // PyGC_Head
# include "pycore_runtime.h" // _Py_ID()
#endif

PyAPI_FUNC(int) _PyArg_CheckPositional(const char *, Py_ssize_t,
Py_ssize_t, Py_ssize_t);
#define _Py_ANY_VARARGS(n) ((n) == PY_SSIZE_T_MAX)
#define _PyArg_CheckPositional(funcname, nargs, min, max) \
((!_Py_ANY_VARARGS(max) && (min) <= (nargs) && (nargs) <= (max)) \
|| _PyArg_CheckPositional((funcname), (nargs), (min), (max)))

// Export for '_heapq' shared extension
PyAPI_FUNC(void) _PyArg_BadArgument(
const char *fname,
const char *displayname,
const char *expected,
PyObject *arg);

// Export for '_curses' shared extension
PyAPI_FUNC(int) _PyArg_ParseStack(
PyObject *const *args,
Py_ssize_t nargs,
const char *format,
...);

// Export for 'math' shared extension
PyAPI_FUNC(PyObject * const *) _PyArg_UnpackKeywords(
PyObject *const *args,
Py_ssize_t nargs,
PyObject *kwargs,
PyObject *kwnames,
struct _PyArg_Parser *parser,
int minpos,
int maxpos,
int minkw,
PyObject **buf);
#define _PyArg_UnpackKeywords(args, nargs, kwargs, kwnames, parser, minpos, maxpos, minkw, buf) \
(((minkw) == 0 && (kwargs) == NULL && (kwnames) == NULL && \
(minpos) <= (nargs) && (nargs) <= (maxpos) && (args) != NULL) ? (args) : \
_PyArg_UnpackKeywords((args), (nargs), (kwargs), (kwnames), (parser), \
(minpos), (maxpos), (minkw), (buf)))


PyDoc_STRVAR(_curses_window_addch__doc__,
"addch([y, x,] ch, [attr=_curses.A_NORMAL])\n"
Expand Down

0 comments on commit 9402bb9

Please sign in to comment.