moduleobject.h 2.3 KB

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