| 1 | #ifndef Py_CPYTHON_MODSUPPORT_H |
| 2 | # error "this header file must not be included directly" |
| 3 | #endif |
| 4 | |
| 5 | /* If PY_SSIZE_T_CLEAN is defined, each functions treats #-specifier |
| 6 | to mean Py_ssize_t */ |
| 7 | #ifdef PY_SSIZE_T_CLEAN |
| 8 | #define _Py_VaBuildStack _Py_VaBuildStack_SizeT |
| 9 | #else |
| 10 | PyAPI_FUNC(PyObject *) _Py_VaBuildValue_SizeT(const char *, va_list); |
| 11 | PyAPI_FUNC(PyObject **) _Py_VaBuildStack_SizeT( |
| 12 | PyObject **small_stack, |
| 13 | Py_ssize_t small_stack_len, |
| 14 | const char *format, |
| 15 | va_list va, |
| 16 | Py_ssize_t *p_nargs); |
| 17 | #endif |
| 18 | |
| 19 | PyAPI_FUNC(int) _PyArg_UnpackStack( |
| 20 | PyObject *const *args, |
| 21 | Py_ssize_t nargs, |
| 22 | const char *name, |
| 23 | Py_ssize_t min, |
| 24 | Py_ssize_t max, |
| 25 | ...); |
| 26 | |
| 27 | PyAPI_FUNC(int) _PyArg_NoKeywords(const char *funcname, PyObject *kwargs); |
| 28 | PyAPI_FUNC(int) _PyArg_NoKwnames(const char *funcname, PyObject *kwnames); |
| 29 | PyAPI_FUNC(int) _PyArg_NoPositional(const char *funcname, PyObject *args); |
| 30 | #define _PyArg_NoKeywords(funcname, kwargs) \ |
| 31 | ((kwargs) == NULL || _PyArg_NoKeywords((funcname), (kwargs))) |
| 32 | #define _PyArg_NoKwnames(funcname, kwnames) \ |
| 33 | ((kwnames) == NULL || _PyArg_NoKwnames((funcname), (kwnames))) |
| 34 | #define _PyArg_NoPositional(funcname, args) \ |
| 35 | ((args) == NULL || _PyArg_NoPositional((funcname), (args))) |
| 36 | |
| 37 | #define _Py_ANY_VARARGS(n) ((n) == PY_SSIZE_T_MAX) |
| 38 | |
| 39 | PyAPI_FUNC(void) _PyArg_BadArgument(const char *, const char *, const char *, PyObject *); |
| 40 | PyAPI_FUNC(int) _PyArg_CheckPositional(const char *, Py_ssize_t, |
| 41 | Py_ssize_t, Py_ssize_t); |
| 42 | #define _PyArg_CheckPositional(funcname, nargs, min, max) \ |
| 43 | ((!_Py_ANY_VARARGS(max) && (min) <= (nargs) && (nargs) <= (max)) \ |
| 44 | || _PyArg_CheckPositional((funcname), (nargs), (min), (max))) |
| 45 | |
| 46 | PyAPI_FUNC(PyObject **) _Py_VaBuildStack( |
| 47 | PyObject **small_stack, |
| 48 | Py_ssize_t small_stack_len, |
| 49 | const char *format, |
| 50 | va_list va, |
| 51 | Py_ssize_t *p_nargs); |
| 52 | |
| 53 | typedef struct _PyArg_Parser { |
| 54 | int initialized; |
| 55 | const char *format; |
| 56 | const char * const *keywords; |
| 57 | const char *fname; |
| 58 | const char *custom_msg; |
| 59 | int pos; /* number of positional-only arguments */ |
| 60 | int min; /* minimal number of arguments */ |
| 61 | int max; /* maximal number of positional arguments */ |
| 62 | PyObject *kwtuple; /* tuple of keyword parameter names */ |
| 63 | struct _PyArg_Parser *next; |
| 64 | } _PyArg_Parser; |
| 65 | |
| 66 | #ifdef PY_SSIZE_T_CLEAN |
| 67 | #define _PyArg_ParseTupleAndKeywordsFast _PyArg_ParseTupleAndKeywordsFast_SizeT |
| 68 | #define _PyArg_ParseStack _PyArg_ParseStack_SizeT |
| 69 | #define _PyArg_ParseStackAndKeywords _PyArg_ParseStackAndKeywords_SizeT |
| 70 | #define _PyArg_VaParseTupleAndKeywordsFast _PyArg_VaParseTupleAndKeywordsFast_SizeT |
| 71 | #endif |
| 72 | |
| 73 | PyAPI_FUNC(int) _PyArg_ParseTupleAndKeywordsFast(PyObject *, PyObject *, |
| 74 | struct _PyArg_Parser *, ...); |
| 75 | PyAPI_FUNC(int) _PyArg_ParseStack( |
| 76 | PyObject *const *args, |
| 77 | Py_ssize_t nargs, |
| 78 | const char *format, |
| 79 | ...); |
| 80 | PyAPI_FUNC(int) _PyArg_ParseStackAndKeywords( |
| 81 | PyObject *const *args, |
| 82 | Py_ssize_t nargs, |
| 83 | PyObject *kwnames, |
| 84 | struct _PyArg_Parser *, |
| 85 | ...); |
| 86 | PyAPI_FUNC(int) _PyArg_VaParseTupleAndKeywordsFast(PyObject *, PyObject *, |
| 87 | struct _PyArg_Parser *, va_list); |
| 88 | PyAPI_FUNC(PyObject * const *) _PyArg_UnpackKeywords( |
| 89 | PyObject *const *args, Py_ssize_t nargs, |
| 90 | PyObject *kwargs, PyObject *kwnames, |
| 91 | struct _PyArg_Parser *parser, |
| 92 | int minpos, int maxpos, int minkw, |
| 93 | PyObject **buf); |
| 94 | |
| 95 | PyAPI_FUNC(PyObject * const *) _PyArg_UnpackKeywordsWithVararg( |
| 96 | PyObject *const *args, Py_ssize_t nargs, |
| 97 | PyObject *kwargs, PyObject *kwnames, |
| 98 | struct _PyArg_Parser *parser, |
| 99 | int minpos, int maxpos, int minkw, |
| 100 | int vararg, PyObject **buf); |
| 101 | |
| 102 | #define _PyArg_UnpackKeywords(args, nargs, kwargs, kwnames, parser, minpos, maxpos, minkw, buf) \ |
| 103 | (((minkw) == 0 && (kwargs) == NULL && (kwnames) == NULL && \ |
| 104 | (minpos) <= (nargs) && (nargs) <= (maxpos) && (args) != NULL) ? (args) : \ |
| 105 | _PyArg_UnpackKeywords((args), (nargs), (kwargs), (kwnames), (parser), \ |
| 106 | (minpos), (maxpos), (minkw), (buf))) |
| 107 | |
| 108 | PyAPI_FUNC(PyObject *) _PyModule_CreateInitialized(PyModuleDef*, int apiver); |
| 109 | PyAPI_FUNC(int) _PyModule_Add(PyObject *, const char *, PyObject *); |
| 110 | |