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