Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:06:49

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 #ifndef Py_LIMITED_API
0031 PyAPI_FUNC(void) _PyModule_Clear(PyObject *);
0032 PyAPI_FUNC(void) _PyModule_ClearDict(PyObject *);
0033 PyAPI_FUNC(int) _PyModuleSpec_IsInitializing(PyObject *);
0034 #endif
0035 PyAPI_FUNC(PyModuleDef*) PyModule_GetDef(PyObject*);
0036 PyAPI_FUNC(void*) PyModule_GetState(PyObject*);
0037 
0038 #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000
0039 /* New in 3.5 */
0040 PyAPI_FUNC(PyObject *) PyModuleDef_Init(PyModuleDef*);
0041 PyAPI_DATA(PyTypeObject) PyModuleDef_Type;
0042 #endif
0043 
0044 typedef struct PyModuleDef_Base {
0045   PyObject_HEAD
0046   /* The function used to re-initialize the module.
0047      This is only set for legacy (single-phase init) extension modules
0048      and only used for those that support multiple initializations
0049      (m_size >= 0).
0050      It is set by _PyImport_LoadDynamicModuleWithSpec()
0051      and _imp.create_builtin(). */
0052   PyObject* (*m_init)(void);
0053   /* The module's index into its interpreter's modules_by_index cache.
0054      This is set for all extension modules but only used for legacy ones.
0055      (See PyInterpreterState.modules_by_index for more info.)
0056      It is set by PyModuleDef_Init(). */
0057   Py_ssize_t m_index;
0058   /* A copy of the module's __dict__ after the first time it was loaded.
0059      This is only set/used for legacy modules that do not support
0060      multiple initializations.
0061      It is set by _PyImport_FixupExtensionObject(). */
0062   PyObject* m_copy;
0063 } PyModuleDef_Base;
0064 
0065 #define PyModuleDef_HEAD_INIT {  \
0066     PyObject_HEAD_INIT(_Py_NULL) \
0067     _Py_NULL, /* m_init */       \
0068     0,        /* m_index */      \
0069     _Py_NULL, /* m_copy */       \
0070   }
0071 
0072 #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000
0073 /* New in 3.5 */
0074 struct PyModuleDef_Slot {
0075     int slot;
0076     void *value;
0077 };
0078 
0079 #define Py_mod_create 1
0080 #define Py_mod_exec 2
0081 #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030c0000
0082 #  define Py_mod_multiple_interpreters 3
0083 #endif
0084 
0085 #ifndef Py_LIMITED_API
0086 #define _Py_mod_LAST_SLOT 3
0087 #endif
0088 
0089 #endif /* New in 3.5 */
0090 
0091 /* for Py_mod_multiple_interpreters: */
0092 #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030c0000
0093 #  define Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED ((void *)0)
0094 #  define Py_MOD_MULTIPLE_INTERPRETERS_SUPPORTED ((void *)1)
0095 #  define Py_MOD_PER_INTERPRETER_GIL_SUPPORTED ((void *)2)
0096 #endif
0097 
0098 struct PyModuleDef {
0099   PyModuleDef_Base m_base;
0100   const char* m_name;
0101   const char* m_doc;
0102   Py_ssize_t m_size;
0103   PyMethodDef *m_methods;
0104   PyModuleDef_Slot *m_slots;
0105   traverseproc m_traverse;
0106   inquiry m_clear;
0107   freefunc m_free;
0108 };
0109 
0110 
0111 // Internal C API
0112 #ifdef Py_BUILD_CORE
0113 extern int _PyModule_IsExtension(PyObject *obj);
0114 #endif
0115 
0116 #ifdef __cplusplus
0117 }
0118 #endif
0119 #endif /* !Py_MODULEOBJECT_H */