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 definition and import interface */ |
| 3 | |
Fred Drake | 5eb6d4e | 2000-07-08 23:37:28 +0000 | [diff] [blame] | 4 | #ifndef Py_IMPORT_H |
| 5 | #define Py_IMPORT_H |
| 6 | #ifdef __cplusplus |
| 7 | extern "C" { |
| 8 | #endif |
Guido van Rossum | 34679b7 | 1993-01-26 13:33:44 +0000 | [diff] [blame] | 9 | |
Mark Hammond | 8235ea1 | 2002-07-19 06:55:41 +0000 | [diff] [blame] | 10 | PyAPI_FUNC(long) PyImport_GetMagicNumber(void); |
| 11 | PyAPI_FUNC(PyObject *) PyImport_ExecCodeModule(char *name, PyObject *co); |
| 12 | PyAPI_FUNC(PyObject *) PyImport_ExecCodeModuleEx( |
Fred Drake | 5eb6d4e | 2000-07-08 23:37:28 +0000 | [diff] [blame] | 13 | char *name, PyObject *co, char *pathname); |
Mark Hammond | 8235ea1 | 2002-07-19 06:55:41 +0000 | [diff] [blame] | 14 | PyAPI_FUNC(PyObject *) PyImport_GetModuleDict(void); |
Jeremy Hylton | af68c87 | 2005-12-10 18:50:16 +0000 | [diff] [blame] | 15 | PyAPI_FUNC(PyObject *) PyImport_AddModule(const char *name); |
| 16 | PyAPI_FUNC(PyObject *) PyImport_ImportModule(const char *name); |
Christian Heimes | 000a074 | 2008-01-03 22:16:32 +0000 | [diff] [blame] | 17 | PyAPI_FUNC(PyObject *) PyImport_ImportModuleNoBlock(const char *); |
Thomas Wouters | f7f438b | 2006-02-28 16:09:29 +0000 | [diff] [blame] | 18 | PyAPI_FUNC(PyObject *) PyImport_ImportModuleLevel(char *name, |
| 19 | PyObject *globals, PyObject *locals, PyObject *fromlist, int level); |
| 20 | |
Thomas Wouters | f7f438b | 2006-02-28 16:09:29 +0000 | [diff] [blame] | 21 | #define PyImport_ImportModuleEx(n, g, l, f) \ |
Neal Norwitz | 8a26706 | 2006-08-19 04:25:29 +0000 | [diff] [blame] | 22 | PyImport_ImportModuleLevel(n, g, l, f, -1) |
Thomas Wouters | f7f438b | 2006-02-28 16:09:29 +0000 | [diff] [blame] | 23 | |
Nick Coghlan | 327a39b | 2007-11-18 11:56:28 +0000 | [diff] [blame] | 24 | PyAPI_FUNC(PyObject *) PyImport_GetImporter(PyObject *path); |
Mark Hammond | 8235ea1 | 2002-07-19 06:55:41 +0000 | [diff] [blame] | 25 | PyAPI_FUNC(PyObject *) PyImport_Import(PyObject *name); |
| 26 | PyAPI_FUNC(PyObject *) PyImport_ReloadModule(PyObject *m); |
| 27 | PyAPI_FUNC(void) PyImport_Cleanup(void); |
| 28 | PyAPI_FUNC(int) PyImport_ImportFrozenModule(char *); |
Fred Drake | 5eb6d4e | 2000-07-08 23:37:28 +0000 | [diff] [blame] | 29 | |
Thomas Wouters | c4dcb38 | 2009-09-16 19:55:54 +0000 | [diff] [blame] | 30 | #ifdef WITH_THREAD |
| 31 | PyAPI_FUNC(void) _PyImport_AcquireLock(void); |
| 32 | PyAPI_FUNC(int) _PyImport_ReleaseLock(void); |
| 33 | #else |
| 34 | #define _PyImport_AcquireLock() |
| 35 | #define _PyImport_ReleaseLock() 1 |
| 36 | #endif |
| 37 | |
Raymond Hettinger | db29e0f | 2004-10-07 06:46:25 +0000 | [diff] [blame] | 38 | PyAPI_FUNC(struct filedescr *) _PyImport_FindModule( |
| 39 | const char *, PyObject *, char *, size_t, FILE **, PyObject **); |
| 40 | PyAPI_FUNC(int) _PyImport_IsScript(struct filedescr *); |
Guido van Rossum | 8ee3e5a | 2005-09-14 18:09:42 +0000 | [diff] [blame] | 41 | PyAPI_FUNC(void) _PyImport_ReInitLock(void); |
Raymond Hettinger | db29e0f | 2004-10-07 06:46:25 +0000 | [diff] [blame] | 42 | |
Mark Hammond | a290527 | 2002-07-29 13:42:14 +0000 | [diff] [blame] | 43 | PyAPI_FUNC(PyObject *)_PyImport_FindExtension(char *, char *); |
| 44 | PyAPI_FUNC(PyObject *)_PyImport_FixupExtension(char *, char *); |
Guido van Rossum | 29e46a9 | 1997-08-02 02:56:48 +0000 | [diff] [blame] | 45 | |
Guido van Rossum | 39c2aae | 1996-05-22 17:25:28 +0000 | [diff] [blame] | 46 | struct _inittab { |
Fred Drake | 5eb6d4e | 2000-07-08 23:37:28 +0000 | [diff] [blame] | 47 | char *name; |
Thomas Wouters | 5f37591 | 2000-07-22 23:30:03 +0000 | [diff] [blame] | 48 | void (*initfunc)(void); |
Guido van Rossum | 39c2aae | 1996-05-22 17:25:28 +0000 | [diff] [blame] | 49 | }; |
| 50 | |
Nick Coghlan | 327a39b | 2007-11-18 11:56:28 +0000 | [diff] [blame] | 51 | PyAPI_DATA(PyTypeObject) PyNullImporter_Type; |
Mark Hammond | a290527 | 2002-07-29 13:42:14 +0000 | [diff] [blame] | 52 | PyAPI_DATA(struct _inittab *) PyImport_Inittab; |
Guido van Rossum | a330996 | 1993-07-28 09:05:47 +0000 | [diff] [blame] | 53 | |
Brett Cannon | 238cedc | 2009-04-02 03:34:53 +0000 | [diff] [blame] | 54 | PyAPI_FUNC(int) PyImport_AppendInittab(const char *name, void (*initfunc)(void)); |
Mark Hammond | a290527 | 2002-07-29 13:42:14 +0000 | [diff] [blame] | 55 | PyAPI_FUNC(int) PyImport_ExtendInittab(struct _inittab *newtab); |
Guido van Rossum | 16926bd | 1998-06-29 20:34:46 +0000 | [diff] [blame] | 56 | |
Guido van Rossum | 4ee68d9 | 1996-06-17 17:05:01 +0000 | [diff] [blame] | 57 | struct _frozen { |
Fred Drake | 5eb6d4e | 2000-07-08 23:37:28 +0000 | [diff] [blame] | 58 | char *name; |
| 59 | unsigned char *code; |
| 60 | int size; |
Guido van Rossum | 4ee68d9 | 1996-06-17 17:05:01 +0000 | [diff] [blame] | 61 | }; |
| 62 | |
| 63 | /* Embedding apps may change this pointer to point to their favorite |
| 64 | collection of frozen modules: */ |
| 65 | |
Mark Hammond | a290527 | 2002-07-29 13:42:14 +0000 | [diff] [blame] | 66 | PyAPI_DATA(struct _frozen *) PyImport_FrozenModules; |
Guido van Rossum | 4ee68d9 | 1996-06-17 17:05:01 +0000 | [diff] [blame] | 67 | |
Guido van Rossum | a330996 | 1993-07-28 09:05:47 +0000 | [diff] [blame] | 68 | #ifdef __cplusplus |
| 69 | } |
| 70 | #endif |
| 71 | #endif /* !Py_IMPORT_H */ |