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