• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef Py_INTERNAL_MODULEOBJECT_H
2 #define Py_INTERNAL_MODULEOBJECT_H
3 #ifdef __cplusplus
4 extern "C" {
5 #endif
6 
7 #ifndef Py_BUILD_CORE
8 #  error "this header requires Py_BUILD_CORE define"
9 #endif
10 
11 typedef struct {
12     PyObject_HEAD
13     PyObject *md_dict;
14     struct PyModuleDef *md_def;
15     void *md_state;
16     PyObject *md_weaklist;
17     // for logging purposes after md_dict is cleared
18     PyObject *md_name;
19 } PyModuleObject;
20 
_PyModule_GetDef(PyObject * mod)21 static inline PyModuleDef* _PyModule_GetDef(PyObject *mod) {
22     assert(PyModule_Check(mod));
23     return ((PyModuleObject *)mod)->md_def;
24 }
25 
_PyModule_GetState(PyObject * mod)26 static inline void* _PyModule_GetState(PyObject* mod) {
27     assert(PyModule_Check(mod));
28     return ((PyModuleObject *)mod)->md_state;
29 }
30 
_PyModule_GetDict(PyObject * mod)31 static inline PyObject* _PyModule_GetDict(PyObject *mod) {
32     assert(PyModule_Check(mod));
33     PyObject *dict = ((PyModuleObject *)mod) -> md_dict;
34     // _PyModule_GetDict(mod) must not be used after calling module_clear(mod)
35     assert(dict != NULL);
36     return dict;
37 }
38 
39 #ifdef __cplusplus
40 }
41 #endif
42 #endif /* !Py_INTERNAL_MODULEOBJECT_H */
43