Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-11-19 09:50:53

0001 
0002 /* Module object interface */
0003 
0004 #ifndef Py_MODULEOBJECT_H
0005 #define Py_MODULEOBJECT_H
0006 #ifdef __cplusplus
0007 extern "C" {
0008 #endif
0009 
0010 PyAPI_DATA(PyTypeObject) PyModule_Type;
0011 
0012 #define PyModule_Check(op) PyObject_TypeCheck((op), &PyModule_Type)
0013 #define PyModule_CheckExact(op) Py_IS_TYPE((op), &PyModule_Type)
0014 
0015 #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000
0016 PyAPI_FUNC(PyObject *) PyModule_NewObject(
0017     PyObject *name
0018     );
0019 #endif
0020 PyAPI_FUNC(PyObject *) PyModule_New(
0021     const char *name            /* UTF-8 encoded string */
0022     );
0023 PyAPI_FUNC(PyObject *) PyModule_GetDict(PyObject *);
0024 #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000
0025 PyAPI_FUNC(PyObject *) PyModule_GetNameObject(PyObject *);
0026 #endif
0027 PyAPI_FUNC(const char *) PyModule_GetName(PyObject *);
0028 Py_DEPRECATED(3.2) PyAPI_FUNC(const char *) PyModule_GetFilename(PyObject *);
0029 PyAPI_FUNC(PyObject *) PyModule_GetFilenameObject(PyObject *);
0030 PyAPI_FUNC(PyModuleDef*) PyModule_GetDef(PyObject*);
0031 PyAPI_FUNC(void*) PyModule_GetState(PyObject*);
0032 
0033 #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000
0034 /* New in 3.5 */
0035 PyAPI_FUNC(PyObject *) PyModuleDef_Init(PyModuleDef*);
0036 PyAPI_DATA(PyTypeObject) PyModuleDef_Type;
0037 #endif
0038 
0039 typedef struct PyModuleDef_Base {
0040   PyObject_HEAD
0041   /* The function used to re-initialize the module.
0042      This is only set for legacy (single-phase init) extension modules
0043      and only used for those that support multiple initializations
0044      (m_size >= 0).
0045      It is set by _PyImport_LoadDynamicModuleWithSpec()
0046      and _imp.create_builtin(). */
0047   PyObject* (*m_init)(void);
0048   /* The module's index into its interpreter's modules_by_index cache.
0049      This is set for all extension modules but only used for legacy ones.
0050      (See PyInterpreterState.modules_by_index for more info.)
0051      It is set by PyModuleDef_Init(). */
0052   Py_ssize_t m_index;
0053   /* A copy of the module's __dict__ after the first time it was loaded.
0054      This is only set/used for legacy modules that do not support
0055      multiple initializations.
0056      It is set by fix_up_extension() in import.c. */
0057   PyObject* m_copy;
0058 } PyModuleDef_Base;
0059 
0060 #define PyModuleDef_HEAD_INIT {  \
0061     PyObject_HEAD_INIT(_Py_NULL) \
0062     _Py_NULL, /* m_init */       \
0063     0,        /* m_index */      \
0064     _Py_NULL, /* m_copy */       \
0065   }
0066 
0067 #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000
0068 /* New in 3.5 */
0069 struct PyModuleDef_Slot {
0070     int slot;
0071     void *value;
0072 };
0073 
0074 #define Py_mod_create 1
0075 #define Py_mod_exec 2
0076 #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030c0000
0077 #  define Py_mod_multiple_interpreters 3
0078 #endif
0079 #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030d0000
0080 #  define Py_mod_gil 4
0081 #endif
0082 
0083 
0084 #ifndef Py_LIMITED_API
0085 #define _Py_mod_LAST_SLOT 4
0086 #endif
0087 
0088 #endif /* New in 3.5 */
0089 
0090 /* for Py_mod_multiple_interpreters: */
0091 #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030c0000
0092 #  define Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED ((void *)0)
0093 #  define Py_MOD_MULTIPLE_INTERPRETERS_SUPPORTED ((void *)1)
0094 #  define Py_MOD_PER_INTERPRETER_GIL_SUPPORTED ((void *)2)
0095 #endif
0096 
0097 /* for Py_mod_gil: */
0098 #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030d0000
0099 #  define Py_MOD_GIL_USED ((void *)0)
0100 #  define Py_MOD_GIL_NOT_USED ((void *)1)
0101 #endif
0102 
0103 #if !defined(Py_LIMITED_API) && defined(Py_GIL_DISABLED)
0104 PyAPI_FUNC(int) PyUnstable_Module_SetGIL(PyObject *module, void *gil);
0105 #endif
0106 
0107 struct PyModuleDef {
0108   PyModuleDef_Base m_base;
0109   const char* m_name;
0110   const char* m_doc;
0111   Py_ssize_t m_size;
0112   PyMethodDef *m_methods;
0113   PyModuleDef_Slot *m_slots;
0114   traverseproc m_traverse;
0115   inquiry m_clear;
0116   freefunc m_free;
0117 };
0118 
0119 #ifdef __cplusplus
0120 }
0121 #endif
0122 #endif /* !Py_MODULEOBJECT_H */