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_IS_TYPE(op, &PyModule_Type)
14
15#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000
16PyAPI_FUNC(PyObject *) PyModule_NewObject(
17 PyObject *name
18 );
19#endif
20PyAPI_FUNC(PyObject *) PyModule_New(
21 const char *name /* UTF-8 encoded string */
22 );
23PyAPI_FUNC(PyObject *) PyModule_GetDict(PyObject *);
24#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000
25PyAPI_FUNC(PyObject *) PyModule_GetNameObject(PyObject *);
26#endif
27PyAPI_FUNC(const char *) PyModule_GetName(PyObject *);
28Py_DEPRECATED(3.2) PyAPI_FUNC(const char *) PyModule_GetFilename(PyObject *);
29PyAPI_FUNC(PyObject *) PyModule_GetFilenameObject(PyObject *);
30#ifndef Py_LIMITED_API
31PyAPI_FUNC(void) _PyModule_Clear(PyObject *);
32PyAPI_FUNC(void) _PyModule_ClearDict(PyObject *);
33PyAPI_FUNC(int) _PyModuleSpec_IsInitializing(PyObject *);
34#endif
35PyAPI_FUNC(struct PyModuleDef*) PyModule_GetDef(PyObject*);
36PyAPI_FUNC(void*) PyModule_GetState(PyObject*);
37
38#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000
39/* New in 3.5 */
40PyAPI_FUNC(PyObject *) PyModuleDef_Init(struct PyModuleDef*);
41PyAPI_DATA(PyTypeObject) PyModuleDef_Type;
42#endif
43
44typedef 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
58struct PyModuleDef_Slot;
59#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000
60/* New in 3.5 */
61typedef 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
75typedef 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
88// Internal C API
89#ifdef Py_BUILD_CORE
90extern int _PyModule_IsExtension(PyObject *obj);
91#endif
92
93#ifdef __cplusplus
94}
95#endif
96#endif /* !Py_MODULEOBJECT_H */
97

source code of include/python3.10/moduleobject.h