blob: 7b2bf1c144ecbca4d482656efc81851e5496af34 [file] [log] [blame]
Guido van Rossumf70e43a1991-02-19 12:39:46 +00001
Guido van Rossum85a5fbb1990-10-14 12:07:46 +00002/* Module object interface */
3
Fred Drake3cf4d2b2000-07-09 00:55:06 +00004#ifndef Py_MODULEOBJECT_H
5#define Py_MODULEOBJECT_H
6#ifdef __cplusplus
7extern "C" {
8#endif
9
Mark Hammond91a681d2002-08-12 07:21:58 +000010PyAPI_DATA(PyTypeObject) PyModule_Type;
Guido van Rossum85a5fbb1990-10-14 12:07:46 +000011
Guido van Rossumb8755092001-09-10 18:21:59 +000012#define PyModule_Check(op) PyObject_TypeCheck(op, &PyModule_Type)
Christian Heimes90aa7642007-12-19 02:45:37 +000013#define PyModule_CheckExact(op) (Py_TYPE(op) == &PyModule_Type)
Guido van Rossum85a5fbb1990-10-14 12:07:46 +000014
Victor Stinnereda71c92011-02-22 23:43:57 +000015PyAPI_FUNC(PyObject *) PyModule_New(
16 const char *name /* UTF-8 encoded string */
17 );
Mark Hammond91a681d2002-08-12 07:21:58 +000018PyAPI_FUNC(PyObject *) PyModule_GetDict(PyObject *);
Neal Norwitz312e10d2007-08-26 02:21:42 +000019PyAPI_FUNC(const char *) PyModule_GetName(PyObject *);
20PyAPI_FUNC(const char *) PyModule_GetFilename(PyObject *);
Victor Stinner6c00c142010-08-17 23:37:11 +000021PyAPI_FUNC(PyObject *) PyModule_GetFilenameObject(PyObject *);
Martin v. Löwis4d0d4712010-12-03 20:14:31 +000022#ifndef Py_LIMITED_API
Mark Hammond91a681d2002-08-12 07:21:58 +000023PyAPI_FUNC(void) _PyModule_Clear(PyObject *);
Martin v. Löwis4d0d4712010-12-03 20:14:31 +000024#endif
Martin v. Löwis1a214512008-06-11 05:26:20 +000025PyAPI_FUNC(struct PyModuleDef*) PyModule_GetDef(PyObject*);
26PyAPI_FUNC(void*) PyModule_GetState(PyObject*);
27
28typedef struct PyModuleDef_Base {
29 PyObject_HEAD
30 PyObject* (*m_init)(void);
31 Py_ssize_t m_index;
32 PyObject* m_copy;
33} PyModuleDef_Base;
34
David Malcolm82e73cb2010-11-17 21:20:18 +000035#define PyModuleDef_HEAD_INIT { \
36 PyObject_HEAD_INIT(NULL) \
37 NULL, /* m_init */ \
38 0, /* m_index */ \
39 NULL, /* m_copy */ \
40 }
Martin v. Löwis1a214512008-06-11 05:26:20 +000041
42typedef struct PyModuleDef{
43 PyModuleDef_Base m_base;
44 const char* m_name;
45 const char* m_doc;
46 Py_ssize_t m_size;
47 PyMethodDef *m_methods;
48 inquiry m_reload;
49 traverseproc m_traverse;
50 inquiry m_clear;
51 freefunc m_free;
52}PyModuleDef;
53
Guido van Rossuma3309961993-07-28 09:05:47 +000054
55#ifdef __cplusplus
56}
57#endif
58#endif /* !Py_MODULEOBJECT_H */