jpayne@69: jpayne@69: #ifndef Py_MODSUPPORT_H jpayne@69: #define Py_MODSUPPORT_H jpayne@69: #ifdef __cplusplus jpayne@69: extern "C" { jpayne@69: #endif jpayne@69: jpayne@69: /* Module support interface */ jpayne@69: jpayne@69: #include jpayne@69: jpayne@69: /* If PY_SSIZE_T_CLEAN is defined, each functions treats #-specifier jpayne@69: to mean Py_ssize_t */ jpayne@69: #ifdef PY_SSIZE_T_CLEAN jpayne@69: #define PyArg_Parse _PyArg_Parse_SizeT jpayne@69: #define PyArg_ParseTuple _PyArg_ParseTuple_SizeT jpayne@69: #define PyArg_ParseTupleAndKeywords _PyArg_ParseTupleAndKeywords_SizeT jpayne@69: #define PyArg_VaParse _PyArg_VaParse_SizeT jpayne@69: #define PyArg_VaParseTupleAndKeywords _PyArg_VaParseTupleAndKeywords_SizeT jpayne@69: #define Py_BuildValue _Py_BuildValue_SizeT jpayne@69: #define Py_VaBuildValue _Py_VaBuildValue_SizeT jpayne@69: #ifndef Py_LIMITED_API jpayne@69: #define _Py_VaBuildStack _Py_VaBuildStack_SizeT jpayne@69: #endif jpayne@69: #else jpayne@69: #ifndef Py_LIMITED_API jpayne@69: PyAPI_FUNC(PyObject *) _Py_VaBuildValue_SizeT(const char *, va_list); jpayne@69: PyAPI_FUNC(PyObject **) _Py_VaBuildStack_SizeT( jpayne@69: PyObject **small_stack, jpayne@69: Py_ssize_t small_stack_len, jpayne@69: const char *format, jpayne@69: va_list va, jpayne@69: Py_ssize_t *p_nargs); jpayne@69: #endif /* !Py_LIMITED_API */ jpayne@69: #endif jpayne@69: jpayne@69: /* Due to a glitch in 3.2, the _SizeT versions weren't exported from the DLL. */ jpayne@69: #if !defined(PY_SSIZE_T_CLEAN) || !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000 jpayne@69: PyAPI_FUNC(int) PyArg_Parse(PyObject *, const char *, ...); jpayne@69: PyAPI_FUNC(int) PyArg_ParseTuple(PyObject *, const char *, ...); jpayne@69: PyAPI_FUNC(int) PyArg_ParseTupleAndKeywords(PyObject *, PyObject *, jpayne@69: const char *, char **, ...); jpayne@69: PyAPI_FUNC(int) PyArg_VaParse(PyObject *, const char *, va_list); jpayne@69: PyAPI_FUNC(int) PyArg_VaParseTupleAndKeywords(PyObject *, PyObject *, jpayne@69: const char *, char **, va_list); jpayne@69: #endif jpayne@69: PyAPI_FUNC(int) PyArg_ValidateKeywordArguments(PyObject *); jpayne@69: PyAPI_FUNC(int) PyArg_UnpackTuple(PyObject *, const char *, Py_ssize_t, Py_ssize_t, ...); jpayne@69: PyAPI_FUNC(PyObject *) Py_BuildValue(const char *, ...); jpayne@69: PyAPI_FUNC(PyObject *) _Py_BuildValue_SizeT(const char *, ...); jpayne@69: jpayne@69: jpayne@69: #ifndef Py_LIMITED_API jpayne@69: PyAPI_FUNC(int) _PyArg_UnpackStack( jpayne@69: PyObject *const *args, jpayne@69: Py_ssize_t nargs, jpayne@69: const char *name, jpayne@69: Py_ssize_t min, jpayne@69: Py_ssize_t max, jpayne@69: ...); jpayne@69: jpayne@69: PyAPI_FUNC(int) _PyArg_NoKeywords(const char *funcname, PyObject *kwargs); jpayne@69: PyAPI_FUNC(int) _PyArg_NoPositional(const char *funcname, PyObject *args); jpayne@69: #define _PyArg_NoKeywords(funcname, kwargs) \ jpayne@69: ((kwargs) == NULL || _PyArg_NoKeywords((funcname), (kwargs))) jpayne@69: #define _PyArg_NoPositional(funcname, args) \ jpayne@69: ((args) == NULL || _PyArg_NoPositional((funcname), (args))) jpayne@69: jpayne@69: PyAPI_FUNC(void) _PyArg_BadArgument(const char *, const char *, const char *, PyObject *); jpayne@69: PyAPI_FUNC(int) _PyArg_CheckPositional(const char *, Py_ssize_t, jpayne@69: Py_ssize_t, Py_ssize_t); jpayne@69: #define _PyArg_CheckPositional(funcname, nargs, min, max) \ jpayne@69: (((min) <= (nargs) && (nargs) <= (max)) \ jpayne@69: || _PyArg_CheckPositional((funcname), (nargs), (min), (max))) jpayne@69: jpayne@69: #endif jpayne@69: jpayne@69: PyAPI_FUNC(PyObject *) Py_VaBuildValue(const char *, va_list); jpayne@69: #ifndef Py_LIMITED_API jpayne@69: PyAPI_FUNC(PyObject **) _Py_VaBuildStack( jpayne@69: PyObject **small_stack, jpayne@69: Py_ssize_t small_stack_len, jpayne@69: const char *format, jpayne@69: va_list va, jpayne@69: Py_ssize_t *p_nargs); jpayne@69: #endif jpayne@69: jpayne@69: #ifndef Py_LIMITED_API jpayne@69: typedef struct _PyArg_Parser { jpayne@69: const char *format; jpayne@69: const char * const *keywords; jpayne@69: const char *fname; jpayne@69: const char *custom_msg; jpayne@69: int pos; /* number of positional-only arguments */ jpayne@69: int min; /* minimal number of arguments */ jpayne@69: int max; /* maximal number of positional arguments */ jpayne@69: PyObject *kwtuple; /* tuple of keyword parameter names */ jpayne@69: struct _PyArg_Parser *next; jpayne@69: } _PyArg_Parser; jpayne@69: #ifdef PY_SSIZE_T_CLEAN jpayne@69: #define _PyArg_ParseTupleAndKeywordsFast _PyArg_ParseTupleAndKeywordsFast_SizeT jpayne@69: #define _PyArg_ParseStack _PyArg_ParseStack_SizeT jpayne@69: #define _PyArg_ParseStackAndKeywords _PyArg_ParseStackAndKeywords_SizeT jpayne@69: #define _PyArg_VaParseTupleAndKeywordsFast _PyArg_VaParseTupleAndKeywordsFast_SizeT jpayne@69: #endif jpayne@69: PyAPI_FUNC(int) _PyArg_ParseTupleAndKeywordsFast(PyObject *, PyObject *, jpayne@69: struct _PyArg_Parser *, ...); jpayne@69: PyAPI_FUNC(int) _PyArg_ParseStack( jpayne@69: PyObject *const *args, jpayne@69: Py_ssize_t nargs, jpayne@69: const char *format, jpayne@69: ...); jpayne@69: PyAPI_FUNC(int) _PyArg_ParseStackAndKeywords( jpayne@69: PyObject *const *args, jpayne@69: Py_ssize_t nargs, jpayne@69: PyObject *kwnames, jpayne@69: struct _PyArg_Parser *, jpayne@69: ...); jpayne@69: PyAPI_FUNC(int) _PyArg_VaParseTupleAndKeywordsFast(PyObject *, PyObject *, jpayne@69: struct _PyArg_Parser *, va_list); jpayne@69: PyAPI_FUNC(PyObject * const *) _PyArg_UnpackKeywords( jpayne@69: PyObject *const *args, Py_ssize_t nargs, jpayne@69: PyObject *kwargs, PyObject *kwnames, jpayne@69: struct _PyArg_Parser *parser, jpayne@69: int minpos, int maxpos, int minkw, jpayne@69: PyObject **buf); jpayne@69: #define _PyArg_UnpackKeywords(args, nargs, kwargs, kwnames, parser, minpos, maxpos, minkw, buf) \ jpayne@69: (((minkw) == 0 && (kwargs) == NULL && (kwnames) == NULL && \ jpayne@69: (minpos) <= (nargs) && (nargs) <= (maxpos) && args != NULL) ? (args) : \ jpayne@69: _PyArg_UnpackKeywords((args), (nargs), (kwargs), (kwnames), (parser), \ jpayne@69: (minpos), (maxpos), (minkw), (buf))) jpayne@69: jpayne@69: void _PyArg_Fini(void); jpayne@69: #endif /* Py_LIMITED_API */ jpayne@69: jpayne@69: PyAPI_FUNC(int) PyModule_AddObject(PyObject *, const char *, PyObject *); jpayne@69: PyAPI_FUNC(int) PyModule_AddIntConstant(PyObject *, const char *, long); jpayne@69: PyAPI_FUNC(int) PyModule_AddStringConstant(PyObject *, const char *, const char *); jpayne@69: #define PyModule_AddIntMacro(m, c) PyModule_AddIntConstant(m, #c, c) jpayne@69: #define PyModule_AddStringMacro(m, c) PyModule_AddStringConstant(m, #c, c) jpayne@69: jpayne@69: #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000 jpayne@69: /* New in 3.5 */ jpayne@69: PyAPI_FUNC(int) PyModule_SetDocString(PyObject *, const char *); jpayne@69: PyAPI_FUNC(int) PyModule_AddFunctions(PyObject *, PyMethodDef *); jpayne@69: PyAPI_FUNC(int) PyModule_ExecDef(PyObject *module, PyModuleDef *def); jpayne@69: #endif jpayne@69: jpayne@69: #define Py_CLEANUP_SUPPORTED 0x20000 jpayne@69: jpayne@69: #define PYTHON_API_VERSION 1013 jpayne@69: #define PYTHON_API_STRING "1013" jpayne@69: /* The API version is maintained (independently from the Python version) jpayne@69: so we can detect mismatches between the interpreter and dynamically jpayne@69: loaded modules. These are diagnosed by an error message but jpayne@69: the module is still loaded (because the mismatch can only be tested jpayne@69: after loading the module). The error message is intended to jpayne@69: explain the core dump a few seconds later. jpayne@69: jpayne@69: The symbol PYTHON_API_STRING defines the same value as a string jpayne@69: literal. *** PLEASE MAKE SURE THE DEFINITIONS MATCH. *** jpayne@69: jpayne@69: Please add a line or two to the top of this log for each API jpayne@69: version change: jpayne@69: jpayne@69: 22-Feb-2006 MvL 1013 PEP 353 - long indices for sequence lengths jpayne@69: jpayne@69: 19-Aug-2002 GvR 1012 Changes to string object struct for jpayne@69: interning changes, saving 3 bytes. jpayne@69: jpayne@69: 17-Jul-2001 GvR 1011 Descr-branch, just to be on the safe side jpayne@69: jpayne@69: 25-Jan-2001 FLD 1010 Parameters added to PyCode_New() and jpayne@69: PyFrame_New(); Python 2.1a2 jpayne@69: jpayne@69: 14-Mar-2000 GvR 1009 Unicode API added jpayne@69: jpayne@69: 3-Jan-1999 GvR 1007 Decided to change back! (Don't reuse 1008!) jpayne@69: jpayne@69: 3-Dec-1998 GvR 1008 Python 1.5.2b1 jpayne@69: jpayne@69: 18-Jan-1997 GvR 1007 string interning and other speedups jpayne@69: jpayne@69: 11-Oct-1996 GvR renamed Py_Ellipses to Py_Ellipsis :-( jpayne@69: jpayne@69: 30-Jul-1996 GvR Slice and ellipses syntax added jpayne@69: jpayne@69: 23-Jul-1996 GvR For 1.4 -- better safe than sorry this time :-) jpayne@69: jpayne@69: 7-Nov-1995 GvR Keyword arguments (should've been done at 1.3 :-( ) jpayne@69: jpayne@69: 10-Jan-1995 GvR Renamed globals to new naming scheme jpayne@69: jpayne@69: 9-Jan-1995 GvR Initial version (incompatible with older API) jpayne@69: */ jpayne@69: jpayne@69: /* The PYTHON_ABI_VERSION is introduced in PEP 384. For the lifetime of jpayne@69: Python 3, it will stay at the value of 3; changes to the limited API jpayne@69: must be performed in a strictly backwards-compatible manner. */ jpayne@69: #define PYTHON_ABI_VERSION 3 jpayne@69: #define PYTHON_ABI_STRING "3" jpayne@69: jpayne@69: #ifdef Py_TRACE_REFS jpayne@69: /* When we are tracing reference counts, rename module creation functions so jpayne@69: modules compiled with incompatible settings will generate a jpayne@69: link-time error. */ jpayne@69: #define PyModule_Create2 PyModule_Create2TraceRefs jpayne@69: #define PyModule_FromDefAndSpec2 PyModule_FromDefAndSpec2TraceRefs jpayne@69: #endif jpayne@69: jpayne@69: PyAPI_FUNC(PyObject *) PyModule_Create2(struct PyModuleDef*, jpayne@69: int apiver); jpayne@69: #ifndef Py_LIMITED_API jpayne@69: PyAPI_FUNC(PyObject *) _PyModule_CreateInitialized(struct PyModuleDef*, jpayne@69: int apiver); jpayne@69: #endif jpayne@69: jpayne@69: #ifdef Py_LIMITED_API jpayne@69: #define PyModule_Create(module) \ jpayne@69: PyModule_Create2(module, PYTHON_ABI_VERSION) jpayne@69: #else jpayne@69: #define PyModule_Create(module) \ jpayne@69: PyModule_Create2(module, PYTHON_API_VERSION) jpayne@69: #endif jpayne@69: jpayne@69: #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000 jpayne@69: /* New in 3.5 */ jpayne@69: PyAPI_FUNC(PyObject *) PyModule_FromDefAndSpec2(PyModuleDef *def, jpayne@69: PyObject *spec, jpayne@69: int module_api_version); jpayne@69: jpayne@69: #ifdef Py_LIMITED_API jpayne@69: #define PyModule_FromDefAndSpec(module, spec) \ jpayne@69: PyModule_FromDefAndSpec2(module, spec, PYTHON_ABI_VERSION) jpayne@69: #else jpayne@69: #define PyModule_FromDefAndSpec(module, spec) \ jpayne@69: PyModule_FromDefAndSpec2(module, spec, PYTHON_API_VERSION) jpayne@69: #endif /* Py_LIMITED_API */ jpayne@69: #endif /* New in 3.5 */ jpayne@69: jpayne@69: #ifndef Py_LIMITED_API jpayne@69: PyAPI_DATA(const char *) _Py_PackageContext; jpayne@69: #endif jpayne@69: jpayne@69: #ifdef __cplusplus jpayne@69: } jpayne@69: #endif jpayne@69: #endif /* !Py_MODSUPPORT_H */