1 2 /* Module object interface */ 3 4 #ifndef Py_MODULEOBJECT_H 5 #define Py_MODULEOBJECT_H 6 #ifdef __cplusplus 7 extern "C" { 8 #endif 9 10 PyAPI_DATA(PyTypeObject) PyModule_Type; 11 12 #define PyModule_Check(op) PyObject_TypeCheck(op, &PyModule_Type) 13 #define PyModule_CheckExact(op) Py_IS_TYPE(op, &PyModule_Type) 14 15 #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000 16 PyAPI_FUNC(PyObject *) PyModule_NewObject( 17 PyObject *name 18 ); 19 #endif 20 PyAPI_FUNC(PyObject *) PyModule_New( 21 const char *name /* UTF-8 encoded string */ 22 ); 23 PyAPI_FUNC(PyObject *) PyModule_GetDict(PyObject *); 24 #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000 25 PyAPI_FUNC(PyObject *) PyModule_GetNameObject(PyObject *); 26 #endif 27 PyAPI_FUNC(const char *) PyModule_GetName(PyObject *); 28 Py_DEPRECATED(3.2) PyAPI_FUNC(const char *) PyModule_GetFilename(PyObject *); 29 PyAPI_FUNC(PyObject *) PyModule_GetFilenameObject(PyObject *); 30 #ifndef Py_LIMITED_API 31 PyAPI_FUNC(void) _PyModule_Clear(PyObject *); 32 PyAPI_FUNC(void) _PyModule_ClearDict(PyObject *); 33 PyAPI_FUNC(int) _PyModuleSpec_IsInitializing(PyObject *); 34 #endif 35 PyAPI_FUNC(struct PyModuleDef*) PyModule_GetDef(PyObject*); 36 PyAPI_FUNC(void*) PyModule_GetState(PyObject*); 37 38 #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000 39 /* New in 3.5 */ 40 PyAPI_FUNC(PyObject *) PyModuleDef_Init(struct PyModuleDef*); 41 PyAPI_DATA(PyTypeObject) PyModuleDef_Type; 42 #endif 43 44 typedef struct PyModuleDef_Base { 45 PyObject_HEAD 46 PyObject* (*m_init)(void); 47 Py_ssize_t m_index; 48 PyObject* m_copy; 49 } PyModuleDef_Base; 50 51 #define PyModuleDef_HEAD_INIT { \ 52 PyObject_HEAD_INIT(NULL) \ 53 NULL, /* m_init */ \ 54 0, /* m_index */ \ 55 NULL, /* m_copy */ \ 56 } 57 58 struct PyModuleDef_Slot; 59 #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000 60 /* New in 3.5 */ 61 typedef struct PyModuleDef_Slot{ 62 int slot; 63 void *value; 64 } PyModuleDef_Slot; 65 66 #define Py_mod_create 1 67 #define Py_mod_exec 2 68 69 #ifndef Py_LIMITED_API 70 #define _Py_mod_LAST_SLOT 2 71 #endif 72 73 #endif /* New in 3.5 */ 74 75 typedef struct PyModuleDef{ 76 PyModuleDef_Base m_base; 77 const char* m_name; 78 const char* m_doc; 79 Py_ssize_t m_size; 80 PyMethodDef *m_methods; 81 struct PyModuleDef_Slot* m_slots; 82 traverseproc m_traverse; 83 inquiry m_clear; 84 freefunc m_free; 85 } PyModuleDef; 86 87 #ifdef __cplusplus 88 } 89 #endif 90 #endif /* !Py_MODULEOBJECT_H */ 91