modsupport.h 4.14 KB
Newer Older
1

2 3 4 5 6 7
#ifndef Py_MODSUPPORT_H
#define Py_MODSUPPORT_H
#ifdef __cplusplus
extern "C" {
#endif

Guido van Rossum's avatar
Guido van Rossum committed
8 9
/* Module support interface */

10
#include <stdarg.h>
11

Martin v. Löwis's avatar
Martin v. Löwis committed
12 13 14 15 16 17 18 19
/* If PY_SSIZE_T_CLEAN is defined, each functions treats #-specifier
   to mean Py_ssize_t */
#ifdef PY_SSIZE_T_CLEAN
#define PyArg_Parse			_PyArg_Parse_SizeT
#define PyArg_ParseTuple		_PyArg_ParseTuple_SizeT
#define PyArg_ParseTupleAndKeywords	_PyArg_ParseTupleAndKeywords_SizeT
#define PyArg_VaParse			_PyArg_VaParse_SizeT
#define PyArg_VaParseTupleAndKeywords	_PyArg_VaParseTupleAndKeywords_SizeT
20 21 22 23
#define Py_BuildValue			_Py_BuildValue_SizeT
#define Py_VaBuildValue			_Py_VaBuildValue_SizeT
#else
PyAPI_FUNC(PyObject *) _Py_VaBuildValue_SizeT(const char *, va_list);
Martin v. Löwis's avatar
Martin v. Löwis committed
24 25
#endif

26
PyAPI_FUNC(int) PyArg_Parse(PyObject *, const char *, ...);
27
PyAPI_FUNC(int) PyArg_ParseTuple(PyObject *, const char *, ...) Py_FORMAT_PARSETUPLE(PyArg_ParseTuple, 2, 3);
28
PyAPI_FUNC(int) PyArg_ParseTupleAndKeywords(PyObject *, PyObject *,
29
                                                  const char *, char **, ...);
30
PyAPI_FUNC(int) PyArg_ValidateKeywordArguments(PyObject *);
31
PyAPI_FUNC(int) PyArg_UnpackTuple(PyObject *, const char *, Py_ssize_t, Py_ssize_t, ...);
32
PyAPI_FUNC(PyObject *) Py_BuildValue(const char *, ...);
33
PyAPI_FUNC(PyObject *) _Py_BuildValue_SizeT(const char *, ...);
34
PyAPI_FUNC(int) _PyArg_NoKeywords(const char *funcname, PyObject *kw);
35

36
PyAPI_FUNC(int) PyArg_VaParse(PyObject *, const char *, va_list);
37
PyAPI_FUNC(int) PyArg_VaParseTupleAndKeywords(PyObject *, PyObject *,
38
                                                  const char *, char **, va_list);
39
PyAPI_FUNC(PyObject *) Py_VaBuildValue(const char *, va_list);
40

41 42 43
PyAPI_FUNC(int) PyModule_AddObject(PyObject *, const char *, PyObject *);
PyAPI_FUNC(int) PyModule_AddIntConstant(PyObject *, const char *, long);
PyAPI_FUNC(int) PyModule_AddStringConstant(PyObject *, const char *, const char *);
44 45
#define PyModule_AddIntMacro(m, c) PyModule_AddIntConstant(m, #c, c)
#define PyModule_AddStringMacro(m, c) PyModule_AddStringConstant(m, #c, c)
Martin v. Löwis's avatar
Martin v. Löwis committed
46

47 48
#define Py_CLEANUP_SUPPORTED 0x20000

49 50
#define PYTHON_API_VERSION 1013
#define PYTHON_API_STRING "1013"
Guido van Rossum's avatar
Guido van Rossum committed
51 52
/* The API version is maintained (independently from the Python version)
   so we can detect mismatches between the interpreter and dynamically
53
   loaded modules.  These are diagnosed by an error message but
54 55 56
   the module is still loaded (because the mismatch can only be tested
   after loading the module).  The error message is intended to
   explain the core dump a few seconds later.
Guido van Rossum's avatar
Guido van Rossum committed
57

58 59 60
   The symbol PYTHON_API_STRING defines the same value as a string
   literal.  *** PLEASE MAKE SURE THE DEFINITIONS MATCH. ***

Guido van Rossum's avatar
Guido van Rossum committed
61 62 63
   Please add a line or two to the top of this log for each API
   version change:

64
   22-Feb-2006  MvL	1013	PEP 353 - long indices for sequence lengths
65

66 67 68
   19-Aug-2002  GvR	1012	Changes to string object struct for
   				interning changes, saving 3 bytes.

69 70
   17-Jul-2001	GvR	1011	Descr-branch, just to be on the safe side

71 72 73
   25-Jan-2001  FLD     1010    Parameters added to PyCode_New() and
                                PyFrame_New(); Python 2.1a2

74 75
   14-Mar-2000  GvR     1009    Unicode API added

76 77 78
   3-Jan-1999	GvR	1007	Decided to change back!  (Don't reuse 1008!)

   3-Dec-1998	GvR	1008	Python 1.5.2b1
79 80

   18-Jan-1997	GvR	1007	string interning and other speedups
81

82 83
   11-Oct-1996	GvR	renamed Py_Ellipses to Py_Ellipsis :-(

84 85 86 87
   30-Jul-1996	GvR	Slice and ellipses syntax added

   23-Jul-1996	GvR	For 1.4 -- better safe than sorry this time :-)

Guido van Rossum's avatar
Guido van Rossum committed
88 89
   7-Nov-1995	GvR	Keyword arguments (should've been done at 1.3 :-( )

90 91
   10-Jan-1995	GvR	Renamed globals to new naming scheme

Guido van Rossum's avatar
Guido van Rossum committed
92 93 94
   9-Jan-1995	GvR	Initial version (incompatible with older API)
*/

95
#ifdef Py_TRACE_REFS
96
 /* When we are tracing reference counts, rename PyModule_Create2 so
Martin v. Löwis's avatar
Martin v. Löwis committed
97 98
    modules compiled with incompatible settings will generate a
    link-time error. */
99
 #define PyModule_Create2 PyModule_Create2TraceRefs
100 101
#endif

102 103
PyAPI_FUNC(PyObject *) PyModule_Create2(struct PyModuleDef*,
                                     int apiver);
104

105 106
#define PyModule_Create(module) \
	PyModule_Create2(module, PYTHON_API_VERSION)
107

108
PyAPI_DATA(char *) _Py_PackageContext;
109

110 111 112 113
#ifdef __cplusplus
}
#endif
#endif /* !Py_MODSUPPORT_H */