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 693520e commit c45e94c
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 10 deletions.
4 changes: 0 additions & 4 deletions py313/_curses_panel.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ static const char PyCursesVersion[] = "2.1";

/* Includes */

// clinic/_curses_panel.c.h uses internal pycore_modsupport.h API
#ifndef Py_BUILD_CORE_BUILTIN
# define Py_BUILD_CORE_MODULE 1
#endif

#include "Python.h"

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

/* Includes */

#ifndef Py_BUILD_CORE_BUILTIN
# define Py_BUILD_CORE_MODULE 1
#endif

#include "Python.h"

/* This function declaration was moved from pycore_structseq.h file to adapt
Expand Down
25 changes: 24 additions & 1 deletion py313/clinic/_curses_panel.c.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,30 @@ preserve
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
# include "pycore_runtime.h" // _Py_SINGLETON()
#endif
#include "pycore_modsupport.h" // _PyArg_UnpackKeywords()

// 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
40 changes: 39 additions & 1 deletion py313/clinic/_cursesmodule.c.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,45 @@ preserve
# include "pycore_gc.h" // PyGC_Head
# include "pycore_runtime.h" // _Py_ID()
#endif
#include "pycore_modsupport.h" // _PyArg_CheckPositional()

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 c45e94c

Please sign in to comment.