Debian Codegraph @

pypy/module/cpyext/include/modsupport.h

raw symbols SCIP
1
2 #ifndef Py_MODSUPPORT_H
3 #define Py_MODSUPPORT_H
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
7
8 /* Module support interface */
9
10 #include <stdarg.h>
11
12 /* If PY_SSIZE_T_CLEAN is defined, each functions treats #-specifier
13 to mean Py_ssize_t */
14 #ifdef PY_SSIZE_T_CLEAN
15 #undef PyArg_Parse
16 #undef PyArg_ParseTuple
17 #undef PyArg_ParseTupleAndKeywords
18 #undef PyArg_VaParse
19 #undef PyArg_VaParseTupleAndKeywords
20 #undef Py_BuildValue
21 #undef Py_VaBuildValue
22 #define PyArg_Parse _PyArg_Parse_SizeT
23 #define PyArg_ParseTuple _PyArg_ParseTuple_SizeT
24 #define PyArg_ParseTupleAndKeywords _PyArg_ParseTupleAndKeywords_SizeT
25 #define PyArg_VaParse _PyArg_VaParse_SizeT
26 #define PyArg_VaParseTupleAndKeywords _PyArg_VaParseTupleAndKeywords_SizeT
27 #define Py_BuildValue _Py_BuildValue_SizeT
28 #define Py_VaBuildValue _Py_VaBuildValue_SizeT
29 #ifndef Py_LIMITED_API
30 #define _Py_VaBuildStack _Py_VaBuildStack_SizeT
31 #endif
32 #else
33 #ifndef Py_LIMITED_API
34 PyAPI_FUNC(PyObject *) _Py_VaBuildValue_SizeT(const char *, va_list);
35 PyAPI_FUNC(PyObject **) _Py_VaBuildStack_SizeT(
36 PyObject **small_stack,
37 Py_ssize_t small_stack_len,
38 const char *format,
39 va_list va,
40 Py_ssize_t *p_nargs);
41 #endif /* !Py_LIMITED_API */
42 #endif
43
44 /* Due to a glitch in 3.2, the _SizeT versions weren't exported from the DLL. */
45 #if !defined(PY_SSIZE_T_CLEAN) || !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000
46 PyAPI_FUNC(int) PyArg_Parse(PyObject *, const char *, ...);
47 PyAPI_FUNC(int) PyArg_ParseTuple(PyObject *, const char *, ...);
48 PyAPI_FUNC(int) PyArg_ParseTupleAndKeywords(PyObject *, PyObject *,
49 const char *, char **, ...);
50 PyAPI_FUNC(int) PyArg_VaParse(PyObject *, const char *, va_list);
51 PyAPI_FUNC(int) PyArg_VaParseTupleAndKeywords(PyObject *, PyObject *,
52 const char *, char **, va_list);
53 #endif
54 PyAPI_FUNC(int) PyArg_ValidateKeywordArguments(PyObject *);
55 PyAPI_FUNC(int) PyArg_UnpackTuple(PyObject *, const char *, Py_ssize_t, Py_ssize_t, ...);
56 PyAPI_FUNC(PyObject *) Py_BuildValue(const char *, ...);
57 PyAPI_FUNC(PyObject *) _Py_BuildValue_SizeT(const char *, ...);
58
59
60 #ifndef Py_LIMITED_API
61 PyAPI_FUNC(int) _PyArg_UnpackStack(
62 PyObject *const *args,
63 Py_ssize_t nargs,
64 const char *name,
65 Py_ssize_t min,
66 Py_ssize_t max,
67 ...);
68
69 #undef _PyArg_NoKeywords
70 PyAPI_FUNC(int) _PyArg_NoKeywords(const char *funcname, PyObject *kwargs);
71 PyAPI_FUNC(int) _PyArg_NoKwnames(const char *funcname, PyObject *kwnames);
72 PyAPI_FUNC(int) _PyArg_NoPositional(const char *funcname, PyObject *args);
73 #define _PyArg_NoKeywords(funcname, kwargs) \
74 ((kwargs) == NULL || _PyArg_NoKeywords((funcname), (kwargs)))
75 #define _PyArg_NoKwnames(funcname, kwnames) \
76 ((kwnames) == NULL || _PyArg_NoKwnames((funcname), (kwnames)))
77 #define _PyArg_NoPositional(funcname, args) \
78 ((args) == NULL || _PyArg_NoPositional((funcname), (args)))
79
80 PyAPI_FUNC(void) _PyArg_BadArgument(const char *, const char *, const char *, PyObject *);
81 PyAPI_FUNC(int) _PyArg_CheckPositional(const char *, Py_ssize_t,
82 Py_ssize_t, Py_ssize_t);
83 #define _PyArg_CheckPositional(funcname, nargs, min, max) \
84 (((min) <= (nargs) && (nargs) <= (max)) \
85 || _PyArg_CheckPositional((funcname), (nargs), (min), (max)))
86
87 #endif
88
89 PyAPI_FUNC(PyObject *) Py_VaBuildValue(const char *, va_list);
90 #ifndef Py_LIMITED_API
91 PyAPI_FUNC(PyObject **) _Py_VaBuildStack(
92 PyObject **small_stack,
93 Py_ssize_t small_stack_len,
94 const char *format,
95 va_list va,
96 Py_ssize_t *p_nargs);
97 #endif
98
99 #ifndef Py_LIMITED_API
100 typedef struct _PyArg_Parser {
101 const char *format;
102 const char * const *keywords;
103 const char *fname;
104 const char *custom_msg;
105 int pos; /* number of positional-only arguments */
106 int min; /* minimal number of arguments */
107 int max; /* maximal number of positional arguments */
108 PyObject *kwtuple; /* tuple of keyword parameter names */
109 struct _PyArg_Parser *next;
110 } _PyArg_Parser;
111 #ifdef PY_SSIZE_T_CLEAN
112 #define _PyArg_ParseTupleAndKeywordsFast _PyArg_ParseTupleAndKeywordsFast_SizeT
113 #define _PyArg_ParseStack _PyArg_ParseStack_SizeT
114 #define _PyArg_ParseStackAndKeywords _PyArg_ParseStackAndKeywords_SizeT
115 #define _PyArg_VaParseTupleAndKeywordsFast _PyArg_VaParseTupleAndKeywordsFast_SizeT
116 #endif
117 PyAPI_FUNC(int) _PyArg_ParseTupleAndKeywordsFast(PyObject *, PyObject *,
118 struct _PyArg_Parser *, ...);
119 PyAPI_FUNC(int) _PyArg_ParseStack(
120 PyObject *const *args,
121 Py_ssize_t nargs,
122 const char *format,
123 ...);
124 PyAPI_FUNC(int) _PyArg_ParseStackAndKeywords(
125 PyObject *const *args,
126 Py_ssize_t nargs,
127 PyObject *kwnames,
128 struct _PyArg_Parser *,
129 ...);
130 PyAPI_FUNC(int) _PyArg_VaParseTupleAndKeywordsFast(PyObject *, PyObject *,
131 struct _PyArg_Parser *, va_list);
132 PyAPI_FUNC(PyObject * const *) _PyArg_UnpackKeywords(
133 PyObject *const *args, Py_ssize_t nargs,
134 PyObject *kwargs, PyObject *kwnames,
135 struct _PyArg_Parser *parser,
136 int minpos, int maxpos, int minkw,
137 PyObject **buf);
138 #define _PyArg_UnpackKeywords(args, nargs, kwargs, kwnames, parser, minpos, maxpos, minkw, buf) \
139 (((minkw) == 0 && (kwargs) == NULL && (kwnames) == NULL && \
140 (minpos) <= (nargs) && (nargs) <= (maxpos) && args != NULL) ? (args) : \
141 _PyArg_UnpackKeywords((args), (nargs), (kwargs), (kwnames), (parser), \
142 (minpos), (maxpos), (minkw), (buf)))
143
144 void _PyArg_Fini(void);
145 #endif /* Py_LIMITED_API */
146
147 // Add an attribute with name 'name' and value 'obj' to the module 'mod.
148 // On success, return 0 on success.
149 // On error, raise an exception and return -1.
150 PyAPI_FUNC(int) PyModule_AddObjectRef(PyObject *mod, const char *name, PyObject *value);
151
152 // Similar to PyModule_AddObjectRef() but steal a reference to 'obj'
153 // (Py_DECREF(obj)) on success (if it returns 0).
154 PyAPI_FUNC(int) PyModule_AddObject(PyObject *mod, const char *, PyObject *value);
155
156 PyAPI_FUNC(int) PyModule_AddIntConstant(PyObject *, const char *, long);
157 PyAPI_FUNC(int) PyModule_AddStringConstant(PyObject *, const char *, const char *);
158 #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03090000
159 /* New in 3.9 */
160 PyAPI_FUNC(int) PyModule_AddType(PyObject *module, PyTypeObject *type);
161 #endif /* Py_LIMITED_API */
162 #define PyModule_AddIntMacro(m, c) PyModule_AddIntConstant(m, #c, c)
163 #define PyModule_AddStringMacro(m, c) PyModule_AddStringConstant(m, #c, c)
164 #define Py_CLEANUP_SUPPORTED 0x20000
165
166 #define PYTHON_API_VERSION 1013
167 #define PYTHON_API_STRING "1013"
168 /* The PYTHON_ABI_VERSION is introduced in PEP 384. For the lifetime of
169 Python 3, it will stay at the value of 3; changes to the limited API
170 must be performed in a strictly backwards-compatible manner. */
171 #define PYTHON_ABI_VERSION 3
172 #define PYTHON_ABI_STRING "3"
173
174
175 PyAPI_FUNC(int) _PyArg_Parse_SizeT(PyObject *, const char *, ...);
176 PyAPI_FUNC(int) _PyArg_ParseTuple_SizeT(PyObject *, const char *, ...);
177 PyAPI_FUNC(int) _PyArg_VaParse_SizeT(PyObject *, const char *, va_list);
178
179 PyAPI_FUNC(int) _PyArg_ParseTupleAndKeywords_SizeT(PyObject *, PyObject *,
180 const char *, char **, ...);
181 PyAPI_FUNC(int) _PyArg_VaParseTupleAndKeywords_SizeT(PyObject *, PyObject *,
182 const char *, char **, va_list);
183
184 PyAPI_FUNC(PyObject *) PyModule_Create2(struct PyModuleDef*,
185 int apiver);
186 #ifdef Py_LIMITED_API
187 #define PyModule_Create(module) \
188 PyModule_Create2(module, PYTHON_ABI_VERSION)
189 #else
190 #define PyModule_Create(module) \
191 PyModule_Create2(module, PYTHON_API_VERSION)
192 #endif
193
194
195
196 #ifndef Py_LIMITED_API
197 PyAPI_DATA(const char *) _Py_PackageContext;
198 #endif
199
200 #ifdef __cplusplus
201 }
202 #endif
203 #endif /* !Py_MODSUPPORT_H */