2023-09-01 16:03:20 -03:00
|
|
|
// Module support interface
|
1991-02-19 08:39:46 -04:00
|
|
|
|
2000-07-08 14:25:55 -03:00
|
|
|
#ifndef Py_MODSUPPORT_H
|
|
|
|
#define Py_MODSUPPORT_H
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2005-12-10 14:50:16 -04:00
|
|
|
PyAPI_FUNC(int) PyArg_Parse(PyObject *, const char *, ...);
|
2013-05-13 01:08:28 -03:00
|
|
|
PyAPI_FUNC(int) PyArg_ParseTuple(PyObject *, const char *, ...);
|
2002-08-12 04:21:58 -03:00
|
|
|
PyAPI_FUNC(int) PyArg_ParseTupleAndKeywords(PyObject *, PyObject *,
|
2023-12-04 07:14:56 -04:00
|
|
|
const char *, PY_CXX_CONST char * const *, ...);
|
2017-01-24 15:27:12 -04:00
|
|
|
PyAPI_FUNC(int) PyArg_VaParse(PyObject *, const char *, va_list);
|
|
|
|
PyAPI_FUNC(int) PyArg_VaParseTupleAndKeywords(PyObject *, PyObject *,
|
2023-12-04 07:14:56 -04:00
|
|
|
const char *, PY_CXX_CONST char * const *, va_list);
|
2023-05-31 06:38:55 -03:00
|
|
|
|
2010-04-24 15:21:17 -03:00
|
|
|
PyAPI_FUNC(int) PyArg_ValidateKeywordArguments(PyObject *);
|
2006-03-01 00:06:10 -04:00
|
|
|
PyAPI_FUNC(int) PyArg_UnpackTuple(PyObject *, const char *, Py_ssize_t, Py_ssize_t, ...);
|
2005-12-10 14:50:16 -04:00
|
|
|
PyAPI_FUNC(PyObject *) Py_BuildValue(const char *, ...);
|
|
|
|
PyAPI_FUNC(PyObject *) Py_VaBuildValue(const char *, va_list);
|
2016-08-14 04:52:18 -03:00
|
|
|
|
2023-07-25 16:01:45 -03:00
|
|
|
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030a0000
|
2020-11-04 08:59:15 -04:00
|
|
|
// Add an attribute with name 'name' and value 'obj' to the module 'mod.
|
2023-07-18 03:42:05 -03:00
|
|
|
// On success, return 0.
|
2020-11-04 08:59:15 -04:00
|
|
|
// On error, raise an exception and return -1.
|
|
|
|
PyAPI_FUNC(int) PyModule_AddObjectRef(PyObject *mod, const char *name, PyObject *value);
|
2023-07-25 16:01:45 -03:00
|
|
|
#endif /* Py_LIMITED_API */
|
2020-11-04 08:59:15 -04:00
|
|
|
|
2023-07-18 03:42:05 -03:00
|
|
|
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030d0000
|
|
|
|
// Similar to PyModule_AddObjectRef() but steal a reference to 'value'.
|
|
|
|
PyAPI_FUNC(int) PyModule_Add(PyObject *mod, const char *name, PyObject *value);
|
|
|
|
#endif /* Py_LIMITED_API */
|
|
|
|
|
|
|
|
// Similar to PyModule_AddObjectRef() and PyModule_Add() but steal
|
|
|
|
// a reference to 'value' on success and only on success.
|
|
|
|
// Errorprone. Should not be used in new code.
|
2020-11-04 08:59:15 -04:00
|
|
|
PyAPI_FUNC(int) PyModule_AddObject(PyObject *mod, const char *, PyObject *value);
|
|
|
|
|
2005-12-10 14:50:16 -04:00
|
|
|
PyAPI_FUNC(int) PyModule_AddIntConstant(PyObject *, const char *, long);
|
|
|
|
PyAPI_FUNC(int) PyModule_AddStringConstant(PyObject *, const char *, const char *);
|
2022-04-21 18:00:26 -03:00
|
|
|
|
2020-03-22 13:17:34 -03:00
|
|
|
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03090000
|
|
|
|
/* New in 3.9 */
|
|
|
|
PyAPI_FUNC(int) PyModule_AddType(PyObject *module, PyTypeObject *type);
|
|
|
|
#endif /* Py_LIMITED_API */
|
2022-04-21 18:00:26 -03:00
|
|
|
|
2022-06-20 11:04:52 -03:00
|
|
|
#define PyModule_AddIntMacro(m, c) PyModule_AddIntConstant((m), #c, (c))
|
|
|
|
#define PyModule_AddStringMacro(m, c) PyModule_AddStringConstant((m), #c, (c))
|
2015-06-02 20:06:47 -03:00
|
|
|
|
|
|
|
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000
|
|
|
|
/* New in 3.5 */
|
2015-05-23 09:24:10 -03:00
|
|
|
PyAPI_FUNC(int) PyModule_SetDocString(PyObject *, const char *);
|
|
|
|
PyAPI_FUNC(int) PyModule_AddFunctions(PyObject *, PyMethodDef *);
|
|
|
|
PyAPI_FUNC(int) PyModule_ExecDef(PyObject *module, PyModuleDef *def);
|
2015-06-02 20:06:47 -03:00
|
|
|
#endif
|
2006-02-15 13:27:45 -04:00
|
|
|
|
2009-05-29 11:47:46 -03:00
|
|
|
#define Py_CLEANUP_SUPPORTED 0x20000
|
|
|
|
|
2006-02-28 15:02:24 -04:00
|
|
|
#define PYTHON_API_VERSION 1013
|
|
|
|
#define PYTHON_API_STRING "1013"
|
1995-01-09 13:47:20 -04:00
|
|
|
/* The API version is maintained (independently from the Python version)
|
|
|
|
so we can detect mismatches between the interpreter and dynamically
|
2000-07-16 09:04:32 -03:00
|
|
|
loaded modules. These are diagnosed by an error message but
|
1996-07-30 13:41:02 -03:00
|
|
|
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.
|
1995-01-09 13:47:20 -04:00
|
|
|
|
1996-08-22 19:55:47 -03:00
|
|
|
The symbol PYTHON_API_STRING defines the same value as a string
|
|
|
|
literal. *** PLEASE MAKE SURE THE DEFINITIONS MATCH. ***
|
|
|
|
|
1995-01-09 13:47:20 -04:00
|
|
|
Please add a line or two to the top of this log for each API
|
|
|
|
version change:
|
|
|
|
|
2015-05-23 09:24:10 -03:00
|
|
|
22-Feb-2006 MvL 1013 PEP 353 - long indices for sequence lengths
|
2006-02-28 15:02:24 -04:00
|
|
|
|
2015-05-23 09:24:10 -03:00
|
|
|
19-Aug-2002 GvR 1012 Changes to string object struct for
|
|
|
|
interning changes, saving 3 bytes.
|
2002-08-19 18:43:18 -03:00
|
|
|
|
2015-05-23 09:24:10 -03:00
|
|
|
17-Jul-2001 GvR 1011 Descr-branch, just to be on the safe side
|
2001-08-02 01:15:00 -03:00
|
|
|
|
2001-01-25 18:13:34 -04:00
|
|
|
25-Jan-2001 FLD 1010 Parameters added to PyCode_New() and
|
|
|
|
PyFrame_New(); Python 2.1a2
|
|
|
|
|
2000-03-28 21:46:45 -04:00
|
|
|
14-Mar-2000 GvR 1009 Unicode API added
|
|
|
|
|
2015-05-23 09:24:10 -03:00
|
|
|
3-Jan-1999 GvR 1007 Decided to change back! (Don't reuse 1008!)
|
1999-01-03 08:40:24 -04:00
|
|
|
|
2015-05-23 09:24:10 -03:00
|
|
|
3-Dec-1998 GvR 1008 Python 1.5.2b1
|
1998-12-03 14:18:12 -04:00
|
|
|
|
2015-05-23 09:24:10 -03:00
|
|
|
18-Jan-1997 GvR 1007 string interning and other speedups
|
1997-01-18 03:54:03 -04:00
|
|
|
|
2015-05-23 09:24:10 -03:00
|
|
|
11-Oct-1996 GvR renamed Py_Ellipses to Py_Ellipsis :-(
|
1996-10-11 13:25:41 -03:00
|
|
|
|
2015-05-23 09:24:10 -03:00
|
|
|
30-Jul-1996 GvR Slice and ellipses syntax added
|
1996-07-30 13:41:02 -03:00
|
|
|
|
2015-05-23 09:24:10 -03:00
|
|
|
23-Jul-1996 GvR For 1.4 -- better safe than sorry this time :-)
|
1996-07-30 13:41:02 -03:00
|
|
|
|
2015-05-23 09:24:10 -03:00
|
|
|
7-Nov-1995 GvR Keyword arguments (should've been done at 1.3 :-( )
|
1996-01-11 20:49:39 -04:00
|
|
|
|
2015-05-23 09:24:10 -03:00
|
|
|
10-Jan-1995 GvR Renamed globals to new naming scheme
|
1995-01-12 07:45:45 -04:00
|
|
|
|
2015-05-23 09:24:10 -03:00
|
|
|
9-Jan-1995 GvR Initial version (incompatible with older API)
|
1995-01-09 13:47:20 -04:00
|
|
|
*/
|
|
|
|
|
2010-12-03 16:14:31 -04:00
|
|
|
/* The PYTHON_ABI_VERSION is introduced in PEP 384. For the lifetime of
|
|
|
|
Python 3, it will stay at the value of 3; changes to the limited API
|
|
|
|
must be performed in a strictly backwards-compatible manner. */
|
|
|
|
#define PYTHON_ABI_VERSION 3
|
|
|
|
#define PYTHON_ABI_STRING "3"
|
|
|
|
|
2022-02-24 12:51:59 -04:00
|
|
|
PyAPI_FUNC(PyObject *) PyModule_Create2(PyModuleDef*, int apiver);
|
1993-07-28 06:05:47 -03:00
|
|
|
|
2010-12-03 16:14:31 -04:00
|
|
|
#ifdef Py_LIMITED_API
|
|
|
|
#define PyModule_Create(module) \
|
2022-06-20 11:04:52 -03:00
|
|
|
PyModule_Create2((module), PYTHON_ABI_VERSION)
|
2010-12-03 16:14:31 -04:00
|
|
|
#else
|
2008-06-11 02:26:20 -03:00
|
|
|
#define PyModule_Create(module) \
|
2022-06-20 11:04:52 -03:00
|
|
|
PyModule_Create2((module), PYTHON_API_VERSION)
|
2015-05-23 09:24:10 -03:00
|
|
|
#endif
|
|
|
|
|
2015-06-02 20:06:47 -03:00
|
|
|
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000
|
|
|
|
/* New in 3.5 */
|
2015-05-23 09:24:10 -03:00
|
|
|
PyAPI_FUNC(PyObject *) PyModule_FromDefAndSpec2(PyModuleDef *def,
|
|
|
|
PyObject *spec,
|
|
|
|
int module_api_version);
|
|
|
|
|
|
|
|
#ifdef Py_LIMITED_API
|
|
|
|
#define PyModule_FromDefAndSpec(module, spec) \
|
2022-06-20 11:04:52 -03:00
|
|
|
PyModule_FromDefAndSpec2((module), (spec), PYTHON_ABI_VERSION)
|
2015-05-23 09:24:10 -03:00
|
|
|
#else
|
|
|
|
#define PyModule_FromDefAndSpec(module, spec) \
|
2022-06-20 11:04:52 -03:00
|
|
|
PyModule_FromDefAndSpec2((module), (spec), PYTHON_API_VERSION)
|
2015-06-02 20:06:47 -03:00
|
|
|
#endif /* Py_LIMITED_API */
|
2022-04-21 18:00:26 -03:00
|
|
|
|
2015-06-02 20:06:47 -03:00
|
|
|
#endif /* New in 3.5 */
|
1998-06-27 15:21:59 -03:00
|
|
|
|
2024-07-03 13:36:57 -03:00
|
|
|
#ifndef Py_LIMITED_API
|
|
|
|
# define Py_CPYTHON_MODSUPPORT_H
|
|
|
|
# include "cpython/modsupport.h"
|
|
|
|
# undef Py_CPYTHON_MODSUPPORT_H
|
|
|
|
#endif
|
|
|
|
|
1993-07-28 06:05:47 -03:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif /* !Py_MODSUPPORT_H */
|