1991-02-19 12:39:46 +00:00
|
|
|
|
1990-10-14 12:07:46 +00:00
|
|
|
/* Module object interface */
|
|
|
|
|
2000-07-09 00:55:06 +00:00
|
|
|
#ifndef Py_MODULEOBJECT_H
|
|
|
|
#define Py_MODULEOBJECT_H
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2002-08-12 07:21:58 +00:00
|
|
|
PyAPI_DATA(PyTypeObject) PyModule_Type;
|
1990-10-14 12:07:46 +00:00
|
|
|
|
2022-06-16 13:49:43 +02:00
|
|
|
#define PyModule_Check(op) PyObject_TypeCheck((op), &PyModule_Type)
|
|
|
|
#define PyModule_CheckExact(op) Py_IS_TYPE((op), &PyModule_Type)
|
1990-10-14 12:07:46 +00:00
|
|
|
|
2016-12-27 14:57:39 +02:00
|
|
|
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000
|
2011-03-04 12:57:07 +00:00
|
|
|
PyAPI_FUNC(PyObject *) PyModule_NewObject(
|
|
|
|
PyObject *name
|
|
|
|
);
|
2016-12-27 14:57:39 +02:00
|
|
|
#endif
|
2011-02-22 23:38:34 +00:00
|
|
|
PyAPI_FUNC(PyObject *) PyModule_New(
|
|
|
|
const char *name /* UTF-8 encoded string */
|
|
|
|
);
|
2002-08-12 07:21:58 +00:00
|
|
|
PyAPI_FUNC(PyObject *) PyModule_GetDict(PyObject *);
|
2016-12-27 14:57:39 +02:00
|
|
|
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000
|
2011-02-23 00:21:43 +00:00
|
|
|
PyAPI_FUNC(PyObject *) PyModule_GetNameObject(PyObject *);
|
2016-12-27 14:57:39 +02:00
|
|
|
#endif
|
2007-08-26 02:21:42 +00:00
|
|
|
PyAPI_FUNC(const char *) PyModule_GetName(PyObject *);
|
2019-05-28 09:16:33 -06:00
|
|
|
Py_DEPRECATED(3.2) PyAPI_FUNC(const char *) PyModule_GetFilename(PyObject *);
|
2010-08-17 23:37:11 +00:00
|
|
|
PyAPI_FUNC(PyObject *) PyModule_GetFilenameObject(PyObject *);
|
2022-02-24 17:51:59 +01:00
|
|
|
PyAPI_FUNC(PyModuleDef*) PyModule_GetDef(PyObject*);
|
2008-06-11 05:26:20 +00:00
|
|
|
PyAPI_FUNC(void*) PyModule_GetState(PyObject*);
|
|
|
|
|
2015-06-02 19:06:47 -04:00
|
|
|
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000
|
|
|
|
/* New in 3.5 */
|
2022-02-24 17:51:59 +01:00
|
|
|
PyAPI_FUNC(PyObject *) PyModuleDef_Init(PyModuleDef*);
|
2015-05-23 14:44:37 -07:00
|
|
|
PyAPI_DATA(PyTypeObject) PyModuleDef_Type;
|
2015-06-02 19:06:47 -04:00
|
|
|
#endif
|
2015-05-23 22:24:10 +10:00
|
|
|
|
2008-06-11 05:26:20 +00:00
|
|
|
typedef struct PyModuleDef_Base {
|
|
|
|
PyObject_HEAD
|
2022-11-11 14:16:28 -07:00
|
|
|
/* The function used to re-initialize the module.
|
|
|
|
This is only set for legacy (single-phase init) extension modules
|
|
|
|
and only used for those that support multiple initializations
|
|
|
|
(m_size >= 0).
|
|
|
|
It is set by _PyImport_LoadDynamicModuleWithSpec()
|
|
|
|
and _imp.create_builtin(). */
|
2008-06-11 05:26:20 +00:00
|
|
|
PyObject* (*m_init)(void);
|
2022-11-11 14:16:28 -07:00
|
|
|
/* The module's index into its interpreter's modules_by_index cache.
|
|
|
|
This is set for all extension modules but only used for legacy ones.
|
|
|
|
(See PyInterpreterState.modules_by_index for more info.)
|
|
|
|
It is set by PyModuleDef_Init(). */
|
2008-06-11 05:26:20 +00:00
|
|
|
Py_ssize_t m_index;
|
2022-11-11 14:16:28 -07:00
|
|
|
/* A copy of the module's __dict__ after the first time it was loaded.
|
|
|
|
This is only set/used for legacy modules that do not support
|
|
|
|
multiple initializations.
|
2024-04-29 09:29:07 -06:00
|
|
|
It is set by fix_up_extension() in import.c. */
|
2008-06-11 05:26:20 +00:00
|
|
|
PyObject* m_copy;
|
|
|
|
} PyModuleDef_Base;
|
|
|
|
|
2022-05-03 22:40:20 +02:00
|
|
|
#define PyModuleDef_HEAD_INIT { \
|
|
|
|
PyObject_HEAD_INIT(_Py_NULL) \
|
|
|
|
_Py_NULL, /* m_init */ \
|
|
|
|
0, /* m_index */ \
|
|
|
|
_Py_NULL, /* m_copy */ \
|
2010-11-17 21:20:18 +00:00
|
|
|
}
|
2008-06-11 05:26:20 +00:00
|
|
|
|
2015-06-02 19:06:47 -04:00
|
|
|
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000
|
|
|
|
/* New in 3.5 */
|
2022-03-03 23:06:55 +01:00
|
|
|
struct PyModuleDef_Slot {
|
2015-05-23 22:24:10 +10:00
|
|
|
int slot;
|
|
|
|
void *value;
|
2022-03-03 23:06:55 +01:00
|
|
|
};
|
2015-05-23 22:24:10 +10:00
|
|
|
|
2015-06-02 19:06:47 -04:00
|
|
|
#define Py_mod_create 1
|
|
|
|
#define Py_mod_exec 2
|
2023-11-06 09:34:57 -07:00
|
|
|
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030c0000
|
|
|
|
# define Py_mod_multiple_interpreters 3
|
|
|
|
#endif
|
2024-05-03 08:30:55 -07:00
|
|
|
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030d0000
|
|
|
|
# define Py_mod_gil 4
|
|
|
|
#endif
|
|
|
|
|
2015-06-02 19:06:47 -04:00
|
|
|
|
|
|
|
#ifndef Py_LIMITED_API
|
2024-05-03 08:30:55 -07:00
|
|
|
#define _Py_mod_LAST_SLOT 4
|
2015-06-02 19:06:47 -04:00
|
|
|
#endif
|
|
|
|
|
2023-10-17 12:27:16 +02:00
|
|
|
#endif /* New in 3.5 */
|
|
|
|
|
2023-05-05 14:04:55 -06:00
|
|
|
/* for Py_mod_multiple_interpreters: */
|
2023-11-01 04:24:33 +01:00
|
|
|
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030c0000
|
|
|
|
# define Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED ((void *)0)
|
|
|
|
# define Py_MOD_MULTIPLE_INTERPRETERS_SUPPORTED ((void *)1)
|
|
|
|
# define Py_MOD_PER_INTERPRETER_GIL_SUPPORTED ((void *)2)
|
2023-10-17 12:27:16 +02:00
|
|
|
#endif
|
2015-06-02 19:06:47 -04:00
|
|
|
|
2024-05-03 08:30:55 -07:00
|
|
|
/* for Py_mod_gil: */
|
|
|
|
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030d0000
|
|
|
|
# define Py_MOD_GIL_USED ((void *)0)
|
|
|
|
# define Py_MOD_GIL_NOT_USED ((void *)1)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if !defined(Py_LIMITED_API) && defined(Py_GIL_DISABLED)
|
2024-05-06 18:59:36 +02:00
|
|
|
PyAPI_FUNC(int) PyUnstable_Module_SetGIL(PyObject *module, void *gil);
|
2024-05-03 08:30:55 -07:00
|
|
|
#endif
|
|
|
|
|
2022-02-24 17:07:12 +01:00
|
|
|
struct PyModuleDef {
|
2008-06-11 05:26:20 +00:00
|
|
|
PyModuleDef_Base m_base;
|
|
|
|
const char* m_name;
|
|
|
|
const char* m_doc;
|
|
|
|
Py_ssize_t m_size;
|
|
|
|
PyMethodDef *m_methods;
|
2022-02-24 17:51:59 +01:00
|
|
|
PyModuleDef_Slot *m_slots;
|
2008-06-11 05:26:20 +00:00
|
|
|
traverseproc m_traverse;
|
|
|
|
inquiry m_clear;
|
|
|
|
freefunc m_free;
|
2022-02-24 17:07:12 +01:00
|
|
|
};
|
2008-06-11 05:26:20 +00:00
|
|
|
|
1993-07-28 09:05:47 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif /* !Py_MODULEOBJECT_H */
|