1 // Module support interface 2 3 #ifndef Py_MODSUPPORT_H 4 #define Py_MODSUPPORT_H 5 #ifdef __cplusplus 6 extern "C" { 7 #endif 8 9 PyAPI_FUNC(int) PyArg_Parse(PyObject *, const char *, ...); 10 PyAPI_FUNC(int) PyArg_ParseTuple(PyObject *, const char *, ...); 11 PyAPI_FUNC(int) PyArg_ParseTupleAndKeywords(PyObject *, PyObject *, 12 const char *, PY_CXX_CONST char * const *, ...); 13 PyAPI_FUNC(int) PyArg_VaParse(PyObject *, const char *, va_list); 14 PyAPI_FUNC(int) PyArg_VaParseTupleAndKeywords(PyObject *, PyObject *, 15 const char *, PY_CXX_CONST char * const *, va_list); 16 17 PyAPI_FUNC(int) PyArg_ValidateKeywordArguments(PyObject *); 18 PyAPI_FUNC(int) PyArg_UnpackTuple(PyObject *, const char *, Py_ssize_t, Py_ssize_t, ...); 19 PyAPI_FUNC(PyObject *) Py_BuildValue(const char *, ...); 20 PyAPI_FUNC(PyObject *) Py_VaBuildValue(const char *, va_list); 21 22 #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030a0000 23 // Add an attribute with name 'name' and value 'obj' to the module 'mod. 24 // On success, return 0. 25 // On error, raise an exception and return -1. 26 PyAPI_FUNC(int) PyModule_AddObjectRef(PyObject *mod, const char *name, PyObject *value); 27 #endif /* Py_LIMITED_API */ 28 29 #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030d0000 30 // Similar to PyModule_AddObjectRef() but steal a reference to 'value'. 31 PyAPI_FUNC(int) PyModule_Add(PyObject *mod, const char *name, PyObject *value); 32 #endif /* Py_LIMITED_API */ 33 34 // Similar to PyModule_AddObjectRef() and PyModule_Add() but steal 35 // a reference to 'value' on success and only on success. 36 // Errorprone. Should not be used in new code. 37 PyAPI_FUNC(int) PyModule_AddObject(PyObject *mod, const char *, PyObject *value); 38 39 PyAPI_FUNC(int) PyModule_AddIntConstant(PyObject *, const char *, long); 40 PyAPI_FUNC(int) PyModule_AddStringConstant(PyObject *, const char *, const char *); 41 42 #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03090000 43 /* New in 3.9 */ 44 PyAPI_FUNC(int) PyModule_AddType(PyObject *module, PyTypeObject *type); 45 #endif /* Py_LIMITED_API */ 46 47 #define PyModule_AddIntMacro(m, c) PyModule_AddIntConstant((m), #c, (c)) 48 #define PyModule_AddStringMacro(m, c) PyModule_AddStringConstant((m), #c, (c)) 49 50 #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000 51 /* New in 3.5 */ 52 PyAPI_FUNC(int) PyModule_SetDocString(PyObject *, const char *); 53 PyAPI_FUNC(int) PyModule_AddFunctions(PyObject *, PyMethodDef *); 54 PyAPI_FUNC(int) PyModule_ExecDef(PyObject *module, PyModuleDef *def); 55 #endif 56 57 #define Py_CLEANUP_SUPPORTED 0x20000 58 59 #define PYTHON_API_VERSION 1013 60 #define PYTHON_API_STRING "1013" 61 /* The API version is maintained (independently from the Python version) 62 so we can detect mismatches between the interpreter and dynamically 63 loaded modules. These are diagnosed by an error message but 64 the module is still loaded (because the mismatch can only be tested 65 after loading the module). The error message is intended to 66 explain the core dump a few seconds later. 67 68 The symbol PYTHON_API_STRING defines the same value as a string 69 literal. *** PLEASE MAKE SURE THE DEFINITIONS MATCH. *** 70 71 Please add a line or two to the top of this log for each API 72 version change: 73 74 22-Feb-2006 MvL 1013 PEP 353 - long indices for sequence lengths 75 76 19-Aug-2002 GvR 1012 Changes to string object struct for 77 interning changes, saving 3 bytes. 78 79 17-Jul-2001 GvR 1011 Descr-branch, just to be on the safe side 80 81 25-Jan-2001 FLD 1010 Parameters added to PyCode_New() and 82 PyFrame_New(); Python 2.1a2 83 84 14-Mar-2000 GvR 1009 Unicode API added 85 86 3-Jan-1999 GvR 1007 Decided to change back! (Don't reuse 1008!) 87 88 3-Dec-1998 GvR 1008 Python 1.5.2b1 89 90 18-Jan-1997 GvR 1007 string interning and other speedups 91 92 11-Oct-1996 GvR renamed Py_Ellipses to Py_Ellipsis :-( 93 94 30-Jul-1996 GvR Slice and ellipses syntax added 95 96 23-Jul-1996 GvR For 1.4 -- better safe than sorry this time :-) 97 98 7-Nov-1995 GvR Keyword arguments (should've been done at 1.3 :-( ) 99 100 10-Jan-1995 GvR Renamed globals to new naming scheme 101 102 9-Jan-1995 GvR Initial version (incompatible with older API) 103 */ 104 105 /* The PYTHON_ABI_VERSION is introduced in PEP 384. For the lifetime of 106 Python 3, it will stay at the value of 3; changes to the limited API 107 must be performed in a strictly backwards-compatible manner. */ 108 #define PYTHON_ABI_VERSION 3 109 #define PYTHON_ABI_STRING "3" 110 111 PyAPI_FUNC(PyObject *) PyModule_Create2(PyModuleDef*, int apiver); 112 113 #ifdef Py_LIMITED_API 114 #define PyModule_Create(module) \ 115 PyModule_Create2((module), PYTHON_ABI_VERSION) 116 #else 117 #define PyModule_Create(module) \ 118 PyModule_Create2((module), PYTHON_API_VERSION) 119 #endif 120 121 #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000 122 /* New in 3.5 */ 123 PyAPI_FUNC(PyObject *) PyModule_FromDefAndSpec2(PyModuleDef *def, 124 PyObject *spec, 125 int module_api_version); 126 127 #ifdef Py_LIMITED_API 128 #define PyModule_FromDefAndSpec(module, spec) \ 129 PyModule_FromDefAndSpec2((module), (spec), PYTHON_ABI_VERSION) 130 #else 131 #define PyModule_FromDefAndSpec(module, spec) \ 132 PyModule_FromDefAndSpec2((module), (spec), PYTHON_API_VERSION) 133 #endif /* Py_LIMITED_API */ 134 135 #endif /* New in 3.5 */ 136 137 #ifndef Py_LIMITED_API 138 # define Py_CPYTHON_MODSUPPORT_H 139 # include "cpython/modsupport.h" 140 # undef Py_CPYTHON_MODSUPPORT_H 141 #endif 142 143 #ifdef __cplusplus 144 } 145 #endif 146 #endif /* !Py_MODSUPPORT_H */ 147