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_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 PyAPI_FUNC(const char *) PyModule_GetFilename(PyObject *) Py_DEPRECATED(3.2);
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 #endif
34 PyAPI_FUNC(struct PyModuleDef*) PyModule_GetDef(PyObject*);
35 PyAPI_FUNC(void*) PyModule_GetState(PyObject*);
36 
37 #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000
38 /* New in 3.5 */
39 PyAPI_FUNC(PyObject *) PyModuleDef_Init(struct PyModuleDef*);
40 PyAPI_DATA(PyTypeObject) PyModuleDef_Type;
41 #endif
42 
43 typedef struct PyModuleDef_Base {
44   PyObject_HEAD
45   PyObject* (*m_init)(void);
46   Py_ssize_t m_index;
47   PyObject* m_copy;
48 } PyModuleDef_Base;
49 
50 #define PyModuleDef_HEAD_INIT { \
51     PyObject_HEAD_INIT(NULL)    \
52     NULL, /* m_init */          \
53     0,    /* m_index */         \
54     NULL, /* m_copy */          \
55   }
56 
57 struct PyModuleDef_Slot;
58 #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000
59 /* New in 3.5 */
60 typedef struct PyModuleDef_Slot{
61     int slot;
62     void *value;
63 } PyModuleDef_Slot;
64 
65 #define Py_mod_create 1
66 #define Py_mod_exec 2
67 
68 #ifndef Py_LIMITED_API
69 #define _Py_mod_LAST_SLOT 2
70 #endif
71 
72 #endif /* New in 3.5 */
73 
74 typedef struct PyModuleDef{
75   PyModuleDef_Base m_base;
76   const char* m_name;
77   const char* m_doc;
78   Py_ssize_t m_size;
79   PyMethodDef *m_methods;
80   struct PyModuleDef_Slot* m_slots;
81   traverseproc m_traverse;
82   inquiry m_clear;
83   freefunc m_free;
84 } PyModuleDef;
85 
86 #ifdef __cplusplus
87 }
88 #endif
89 #endif /* !Py_MODULEOBJECT_H */
90