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