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); |
Barry Warsaw | 28a691b | 2010-04-17 00:19:56 +0000 | [diff] [blame] | 11 | PyAPI_FUNC(const char *) PyImport_GetMagicTag(void); |
Victor Stinner | d7e7640 | 2011-02-22 23:38:34 +0000 | [diff] [blame] | 12 | PyAPI_FUNC(PyObject *) PyImport_ExecCodeModule( |
| 13 | char *name, /* UTF-8 encoded string */ |
| 14 | PyObject *co |
| 15 | ); |
Mark Hammond | 8235ea1 | 2002-07-19 06:55:41 +0000 | [diff] [blame] | 16 | PyAPI_FUNC(PyObject *) PyImport_ExecCodeModuleEx( |
Victor Stinner | d7e7640 | 2011-02-22 23:38:34 +0000 | [diff] [blame] | 17 | char *name, /* UTF-8 encoded string */ |
| 18 | PyObject *co, |
| 19 | char *pathname /* decoded from the filesystem encoding */ |
| 20 | ); |
Barry Warsaw | 28a691b | 2010-04-17 00:19:56 +0000 | [diff] [blame] | 21 | PyAPI_FUNC(PyObject *) PyImport_ExecCodeModuleWithPathnames( |
Victor Stinner | d7e7640 | 2011-02-22 23:38:34 +0000 | [diff] [blame] | 22 | char *name, /* UTF-8 encoded string */ |
| 23 | PyObject *co, |
| 24 | char *pathname, /* decoded from the filesystem encoding */ |
| 25 | char *cpathname /* decoded from the filesystem encoding */ |
| 26 | ); |
Victor Stinner | 27ee089 | 2011-03-04 12:57:09 +0000 | [diff] [blame] | 27 | PyAPI_FUNC(PyObject *) PyImport_ExecCodeModuleObject( |
| 28 | PyObject *name, |
| 29 | PyObject *co, |
| 30 | PyObject *pathname, |
| 31 | PyObject *cpathname |
| 32 | ); |
Mark Hammond | 8235ea1 | 2002-07-19 06:55:41 +0000 | [diff] [blame] | 33 | PyAPI_FUNC(PyObject *) PyImport_GetModuleDict(void); |
Victor Stinner | 27ee089 | 2011-03-04 12:57:09 +0000 | [diff] [blame] | 34 | PyAPI_FUNC(PyObject *) PyImport_AddModuleObject( |
| 35 | PyObject *name |
| 36 | ); |
Victor Stinner | d7e7640 | 2011-02-22 23:38:34 +0000 | [diff] [blame] | 37 | PyAPI_FUNC(PyObject *) PyImport_AddModule( |
| 38 | const char *name /* UTF-8 encoded string */ |
| 39 | ); |
| 40 | PyAPI_FUNC(PyObject *) PyImport_ImportModule( |
| 41 | const char *name /* UTF-8 encoded string */ |
| 42 | ); |
| 43 | PyAPI_FUNC(PyObject *) PyImport_ImportModuleNoBlock( |
| 44 | const char *name /* UTF-8 encoded string */ |
| 45 | ); |
| 46 | PyAPI_FUNC(PyObject *) PyImport_ImportModuleLevel( |
| 47 | char *name, /* UTF-8 encoded string */ |
| 48 | PyObject *globals, |
| 49 | PyObject *locals, |
| 50 | PyObject *fromlist, |
| 51 | int level |
| 52 | ); |
Thomas Wouters | f7f438b | 2006-02-28 16:09:29 +0000 | [diff] [blame] | 53 | |
Thomas Wouters | f7f438b | 2006-02-28 16:09:29 +0000 | [diff] [blame] | 54 | #define PyImport_ImportModuleEx(n, g, l, f) \ |
Victor Stinner | d7e7640 | 2011-02-22 23:38:34 +0000 | [diff] [blame] | 55 | PyImport_ImportModuleLevel(n, g, l, f, -1) |
Thomas Wouters | f7f438b | 2006-02-28 16:09:29 +0000 | [diff] [blame] | 56 | |
Christian Heimes | 9cd1775 | 2007-11-18 19:35:23 +0000 | [diff] [blame] | 57 | PyAPI_FUNC(PyObject *) PyImport_GetImporter(PyObject *path); |
Mark Hammond | 8235ea1 | 2002-07-19 06:55:41 +0000 | [diff] [blame] | 58 | PyAPI_FUNC(PyObject *) PyImport_Import(PyObject *name); |
| 59 | PyAPI_FUNC(PyObject *) PyImport_ReloadModule(PyObject *m); |
| 60 | PyAPI_FUNC(void) PyImport_Cleanup(void); |
Victor Stinner | 53dc735 | 2011-03-20 01:50:21 +0100 | [diff] [blame] | 61 | PyAPI_FUNC(int) PyImport_ImportFrozenModuleObject( |
| 62 | PyObject *name |
| 63 | ); |
Victor Stinner | d7e7640 | 2011-02-22 23:38:34 +0000 | [diff] [blame] | 64 | PyAPI_FUNC(int) PyImport_ImportFrozenModule( |
| 65 | char *name /* UTF-8 encoded string */ |
| 66 | ); |
Fred Drake | 5eb6d4e | 2000-07-08 23:37:28 +0000 | [diff] [blame] | 67 | |
Martin v. Löwis | 4d0d471 | 2010-12-03 20:14:31 +0000 | [diff] [blame] | 68 | #ifndef Py_LIMITED_API |
Benjamin Peterson | 0df35a9 | 2009-10-04 20:32:25 +0000 | [diff] [blame] | 69 | #ifdef WITH_THREAD |
| 70 | PyAPI_FUNC(void) _PyImport_AcquireLock(void); |
| 71 | PyAPI_FUNC(int) _PyImport_ReleaseLock(void); |
| 72 | #else |
| 73 | #define _PyImport_AcquireLock() |
| 74 | #define _PyImport_ReleaseLock() 1 |
| 75 | #endif |
| 76 | |
Guido van Rossum | 8ee3e5a | 2005-09-14 18:09:42 +0000 | [diff] [blame] | 77 | PyAPI_FUNC(void) _PyImport_ReInitLock(void); |
Raymond Hettinger | db29e0f | 2004-10-07 06:46:25 +0000 | [diff] [blame] | 78 | |
Victor Stinner | d7e7640 | 2011-02-22 23:38:34 +0000 | [diff] [blame] | 79 | PyAPI_FUNC(PyObject *)_PyImport_FindBuiltin( |
Victor Stinner | 501c09a | 2011-02-23 00:02:00 +0000 | [diff] [blame] | 80 | const char *name /* UTF-8 encoded string */ |
Victor Stinner | d7e7640 | 2011-02-22 23:38:34 +0000 | [diff] [blame] | 81 | ); |
Victor Stinner | 9587286 | 2011-03-07 18:20:56 +0100 | [diff] [blame] | 82 | PyAPI_FUNC(PyObject *)_PyImport_FindExtensionObject(PyObject *, PyObject *); |
Victor Stinner | d7e7640 | 2011-02-22 23:38:34 +0000 | [diff] [blame] | 83 | PyAPI_FUNC(int)_PyImport_FixupBuiltin( |
| 84 | PyObject *mod, |
| 85 | char *name /* UTF-8 encoded string */ |
| 86 | ); |
Victor Stinner | 9587286 | 2011-03-07 18:20:56 +0100 | [diff] [blame] | 87 | PyAPI_FUNC(int)_PyImport_FixupExtensionObject(PyObject*, PyObject *, PyObject *); |
Guido van Rossum | 29e46a9 | 1997-08-02 02:56:48 +0000 | [diff] [blame] | 88 | |
Guido van Rossum | 39c2aae | 1996-05-22 17:25:28 +0000 | [diff] [blame] | 89 | struct _inittab { |
Victor Stinner | db536af | 2011-03-07 18:34:59 +0100 | [diff] [blame^] | 90 | char *name; /* ASCII encoded string */ |
Martin v. Löwis | 1a21451 | 2008-06-11 05:26:20 +0000 | [diff] [blame] | 91 | PyObject* (*initfunc)(void); |
Guido van Rossum | 39c2aae | 1996-05-22 17:25:28 +0000 | [diff] [blame] | 92 | }; |
Martin v. Löwis | 4d0d471 | 2010-12-03 20:14:31 +0000 | [diff] [blame] | 93 | PyAPI_DATA(struct _inittab *) PyImport_Inittab; |
| 94 | PyAPI_FUNC(int) PyImport_ExtendInittab(struct _inittab *newtab); |
| 95 | #endif /* Py_LIMITED_API */ |
Guido van Rossum | 39c2aae | 1996-05-22 17:25:28 +0000 | [diff] [blame] | 96 | |
Christian Heimes | 9cd1775 | 2007-11-18 19:35:23 +0000 | [diff] [blame] | 97 | PyAPI_DATA(PyTypeObject) PyNullImporter_Type; |
Guido van Rossum | a330996 | 1993-07-28 09:05:47 +0000 | [diff] [blame] | 98 | |
Victor Stinner | d7e7640 | 2011-02-22 23:38:34 +0000 | [diff] [blame] | 99 | PyAPI_FUNC(int) PyImport_AppendInittab( |
| 100 | const char *name, /* ASCII encoded string */ |
| 101 | PyObject* (*initfunc)(void) |
| 102 | ); |
Guido van Rossum | 16926bd | 1998-06-29 20:34:46 +0000 | [diff] [blame] | 103 | |
Martin v. Löwis | 4d0d471 | 2010-12-03 20:14:31 +0000 | [diff] [blame] | 104 | #ifndef Py_LIMITED_API |
Guido van Rossum | 4ee68d9 | 1996-06-17 17:05:01 +0000 | [diff] [blame] | 105 | struct _frozen { |
Victor Stinner | d7e7640 | 2011-02-22 23:38:34 +0000 | [diff] [blame] | 106 | char *name; /* ASCII encoded string */ |
Fred Drake | 5eb6d4e | 2000-07-08 23:37:28 +0000 | [diff] [blame] | 107 | unsigned char *code; |
| 108 | int size; |
Guido van Rossum | 4ee68d9 | 1996-06-17 17:05:01 +0000 | [diff] [blame] | 109 | }; |
| 110 | |
| 111 | /* Embedding apps may change this pointer to point to their favorite |
| 112 | collection of frozen modules: */ |
| 113 | |
Mark Hammond | a290527 | 2002-07-29 13:42:14 +0000 | [diff] [blame] | 114 | PyAPI_DATA(struct _frozen *) PyImport_FrozenModules; |
Martin v. Löwis | 4d0d471 | 2010-12-03 20:14:31 +0000 | [diff] [blame] | 115 | #endif |
Guido van Rossum | 4ee68d9 | 1996-06-17 17:05:01 +0000 | [diff] [blame] | 116 | |
Guido van Rossum | a330996 | 1993-07-28 09:05:47 +0000 | [diff] [blame] | 117 | #ifdef __cplusplus |
| 118 | } |
| 119 | #endif |
| 120 | #endif /* !Py_IMPORT_H */ |