moduleobject.h 2.1 KB

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