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