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 #define PyArg_Parse _PyArg_Parse_SizeT 16 #define PyArg_ParseTuple _PyArg_ParseTuple_SizeT 17 #define PyArg_ParseTupleAndKeywords _PyArg_ParseTupleAndKeywords_SizeT 18 #define PyArg_VaParse _PyArg_VaParse_SizeT 19 #define PyArg_VaParseTupleAndKeywords _PyArg_VaParseTupleAndKeywords_SizeT 20 #define Py_BuildValue _Py_BuildValue_SizeT 21 #define Py_VaBuildValue _Py_VaBuildValue_SizeT 22 #else 23 PyAPI_FUNC(PyObject *) _Py_VaBuildValue_SizeT(const char *, va_list); 24 #endif 25 26 /* Due to a glitch in 3.2, the _SizeT versions weren't exported from the DLL. */ 27 #if !defined(PY_SSIZE_T_CLEAN) || !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000 28 PyAPI_FUNC(int) PyArg_Parse(PyObject *, const char *, ...); 29 PyAPI_FUNC(int) PyArg_ParseTuple(PyObject *, const char *, ...); 30 PyAPI_FUNC(int) PyArg_ParseTupleAndKeywords(PyObject *, PyObject *, 31 const char *, char **, ...); 32 PyAPI_FUNC(int) PyArg_ValidateKeywordArguments(PyObject *); 33 PyAPI_FUNC(int) PyArg_UnpackTuple(PyObject *, const char *, Py_ssize_t, Py_ssize_t, ...); 34 PyAPI_FUNC(PyObject *) Py_BuildValue(const char *, ...); 35 PyAPI_FUNC(PyObject *) _Py_BuildValue_SizeT(const char *, ...); 36 #endif 37 #ifndef Py_LIMITED_API 38 PyAPI_FUNC(int) _PyArg_NoKeywords(const char *funcname, PyObject *kw); 39 PyAPI_FUNC(int) _PyArg_NoPositional(const char *funcname, PyObject *args); 40 41 PyAPI_FUNC(int) PyArg_VaParse(PyObject *, const char *, va_list); 42 PyAPI_FUNC(int) PyArg_VaParseTupleAndKeywords(PyObject *, PyObject *, 43 const char *, char **, va_list); 44 #endif 45 PyAPI_FUNC(PyObject *) Py_VaBuildValue(const char *, va_list); 46 47 PyAPI_FUNC(int) PyModule_AddObject(PyObject *, const char *, PyObject *); 48 PyAPI_FUNC(int) PyModule_AddIntConstant(PyObject *, const char *, long); 49 PyAPI_FUNC(int) PyModule_AddStringConstant(PyObject *, const char *, const char *); 50 #define PyModule_AddIntMacro(m, c) PyModule_AddIntConstant(m, #c, c) 51 #define PyModule_AddStringMacro(m, c) PyModule_AddStringConstant(m, #c, c) 52 53 #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000 54 /* New in 3.5 */ 55 PyAPI_FUNC(int) PyModule_SetDocString(PyObject *, const char *); 56 PyAPI_FUNC(int) PyModule_AddFunctions(PyObject *, PyMethodDef *); 57 PyAPI_FUNC(int) PyModule_ExecDef(PyObject *module, PyModuleDef *def); 58 #endif 59 60 #define Py_CLEANUP_SUPPORTED 0x20000 61 62 #define PYTHON_API_VERSION 1013 63 #define PYTHON_API_STRING "1013" 64 /* The API version is maintained (independently from the Python version) 65 so we can detect mismatches between the interpreter and dynamically 66 loaded modules. These are diagnosed by an error message but 67 the module is still loaded (because the mismatch can only be tested 68 after loading the module). The error message is intended to 69 explain the core dump a few seconds later. 70 71 The symbol PYTHON_API_STRING defines the same value as a string 72 literal. *** PLEASE MAKE SURE THE DEFINITIONS MATCH. *** 73 74 Please add a line or two to the top of this log for each API 75 version change: 76 77 22-Feb-2006 MvL 1013 PEP 353 - long indices for sequence lengths 78 79 19-Aug-2002 GvR 1012 Changes to string object struct for 80 interning changes, saving 3 bytes. 81 82 17-Jul-2001 GvR 1011 Descr-branch, just to be on the safe side 83 84 25-Jan-2001 FLD 1010 Parameters added to PyCode_New() and 85 PyFrame_New(); Python 2.1a2 86 87 14-Mar-2000 GvR 1009 Unicode API added 88 89 3-Jan-1999 GvR 1007 Decided to change back! (Don't reuse 1008!) 90 91 3-Dec-1998 GvR 1008 Python 1.5.2b1 92 93 18-Jan-1997 GvR 1007 string interning and other speedups 94 95 11-Oct-1996 GvR renamed Py_Ellipses to Py_Ellipsis :-( 96 97 30-Jul-1996 GvR Slice and ellipses syntax added 98 99 23-Jul-1996 GvR For 1.4 -- better safe than sorry this time :-) 100 101 7-Nov-1995 GvR Keyword arguments (should've been done at 1.3 :-( ) 102 103 10-Jan-1995 GvR Renamed globals to new naming scheme 104 105 9-Jan-1995 GvR Initial version (incompatible with older API) 106 */ 107 108 /* The PYTHON_ABI_VERSION is introduced in PEP 384. For the lifetime of 109 Python 3, it will stay at the value of 3; changes to the limited API 110 must be performed in a strictly backwards-compatible manner. */ 111 #define PYTHON_ABI_VERSION 3 112 #define PYTHON_ABI_STRING "3" 113 114 #ifdef Py_TRACE_REFS 115 /* When we are tracing reference counts, rename module creation functions so 116 modules compiled with incompatible settings will generate a 117 link-time error. */ 118 #define PyModule_Create2 PyModule_Create2TraceRefs 119 #define PyModule_FromDefAndSpec2 PyModule_FromDefAndSpec2TraceRefs 120 #endif 121 122 PyAPI_FUNC(PyObject *) PyModule_Create2(struct PyModuleDef*, 123 int apiver); 124 125 #ifdef Py_LIMITED_API 126 #define PyModule_Create(module) \ 127 PyModule_Create2(module, PYTHON_ABI_VERSION) 128 #else 129 #define PyModule_Create(module) \ 130 PyModule_Create2(module, PYTHON_API_VERSION) 131 #endif 132 133 #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000 134 /* New in 3.5 */ 135 PyAPI_FUNC(PyObject *) PyModule_FromDefAndSpec2(PyModuleDef *def, 136 PyObject *spec, 137 int module_api_version); 138 139 #ifdef Py_LIMITED_API 140 #define PyModule_FromDefAndSpec(module, spec) \ 141 PyModule_FromDefAndSpec2(module, spec, PYTHON_ABI_VERSION) 142 #else 143 #define PyModule_FromDefAndSpec(module, spec) \ 144 PyModule_FromDefAndSpec2(module, spec, PYTHON_API_VERSION) 145 #endif /* Py_LIMITED_API */ 146 #endif /* New in 3.5 */ 147 148 #ifndef Py_LIMITED_API 149 PyAPI_DATA(char *) _Py_PackageContext; 150 #endif 151 152 #ifdef __cplusplus 153 } 154 #endif 155 #endif /* !Py_MODSUPPORT_H */ 156