Guido van Rossum | f70e43a | 1991-02-19 12:39:46 +0000 | [diff] [blame] | 1 | |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 2 | /* Module object interface */ |
| 3 | |
Fred Drake | 3cf4d2b | 2000-07-09 00:55:06 +0000 | [diff] [blame] | 4 | #ifndef Py_MODULEOBJECT_H |
| 5 | #define Py_MODULEOBJECT_H |
| 6 | #ifdef __cplusplus |
| 7 | extern "C" { |
| 8 | #endif |
| 9 | |
Mark Hammond | 91a681d | 2002-08-12 07:21:58 +0000 | [diff] [blame] | 10 | PyAPI_DATA(PyTypeObject) PyModule_Type; |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 11 | |
Guido van Rossum | b875509 | 2001-09-10 18:21:59 +0000 | [diff] [blame] | 12 | #define PyModule_Check(op) PyObject_TypeCheck(op, &PyModule_Type) |
Christian Heimes | 90aa764 | 2007-12-19 02:45:37 +0000 | [diff] [blame] | 13 | #define PyModule_CheckExact(op) (Py_TYPE(op) == &PyModule_Type) |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 14 | |
Victor Stinner | eda71c9 | 2011-02-22 23:43:57 +0000 | [diff] [blame] | 15 | PyAPI_FUNC(PyObject *) PyModule_New( |
| 16 | const char *name /* UTF-8 encoded string */ |
| 17 | ); |
Mark Hammond | 91a681d | 2002-08-12 07:21:58 +0000 | [diff] [blame] | 18 | PyAPI_FUNC(PyObject *) PyModule_GetDict(PyObject *); |
Neal Norwitz | 312e10d | 2007-08-26 02:21:42 +0000 | [diff] [blame] | 19 | PyAPI_FUNC(const char *) PyModule_GetName(PyObject *); |
| 20 | PyAPI_FUNC(const char *) PyModule_GetFilename(PyObject *); |
Victor Stinner | 6c00c14 | 2010-08-17 23:37:11 +0000 | [diff] [blame] | 21 | PyAPI_FUNC(PyObject *) PyModule_GetFilenameObject(PyObject *); |
Martin v. Löwis | 4d0d471 | 2010-12-03 20:14:31 +0000 | [diff] [blame] | 22 | #ifndef Py_LIMITED_API |
Mark Hammond | 91a681d | 2002-08-12 07:21:58 +0000 | [diff] [blame] | 23 | PyAPI_FUNC(void) _PyModule_Clear(PyObject *); |
Martin v. Löwis | 4d0d471 | 2010-12-03 20:14:31 +0000 | [diff] [blame] | 24 | #endif |
Martin v. Löwis | 1a21451 | 2008-06-11 05:26:20 +0000 | [diff] [blame] | 25 | PyAPI_FUNC(struct PyModuleDef*) PyModule_GetDef(PyObject*); |
| 26 | PyAPI_FUNC(void*) PyModule_GetState(PyObject*); |
| 27 | |
| 28 | typedef 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 Malcolm | 82e73cb | 2010-11-17 21:20:18 +0000 | [diff] [blame] | 35 | #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öwis | 1a21451 | 2008-06-11 05:26:20 +0000 | [diff] [blame] | 41 | |
| 42 | typedef 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 Rossum | a330996 | 1993-07-28 09:05:47 +0000 | [diff] [blame] | 54 | |
| 55 | #ifdef __cplusplus |
| 56 | } |
| 57 | #endif |
| 58 | #endif /* !Py_MODULEOBJECT_H */ |