blob: 73c86ee400f0e3562fe2204cbddfe82bcfad6e39 [file] [log] [blame]
Guido van Rossumf70e43a1991-02-19 12:39:46 +00001
Guido van Rossum85a5fbb1990-10-14 12:07:46 +00002/* Module definition and import interface */
3
Fred Drake5eb6d4e2000-07-08 23:37:28 +00004#ifndef Py_IMPORT_H
5#define Py_IMPORT_H
6#ifdef __cplusplus
7extern "C" {
8#endif
Guido van Rossum34679b71993-01-26 13:33:44 +00009
Brett Cannonfd074152012-04-14 14:10:13 -040010PyAPI_FUNC(void) _PyImportZip_Init(void);
11
12PyMODINIT_FUNC PyInit_imp(void);
Mark Hammond8235ea12002-07-19 06:55:41 +000013PyAPI_FUNC(long) PyImport_GetMagicNumber(void);
Barry Warsaw28a691b2010-04-17 00:19:56 +000014PyAPI_FUNC(const char *) PyImport_GetMagicTag(void);
Victor Stinnerd7e76402011-02-22 23:38:34 +000015PyAPI_FUNC(PyObject *) PyImport_ExecCodeModule(
16 char *name, /* UTF-8 encoded string */
17 PyObject *co
18 );
Mark Hammond8235ea12002-07-19 06:55:41 +000019PyAPI_FUNC(PyObject *) PyImport_ExecCodeModuleEx(
Victor Stinnerd7e76402011-02-22 23:38:34 +000020 char *name, /* UTF-8 encoded string */
21 PyObject *co,
22 char *pathname /* decoded from the filesystem encoding */
23 );
Barry Warsaw28a691b2010-04-17 00:19:56 +000024PyAPI_FUNC(PyObject *) PyImport_ExecCodeModuleWithPathnames(
Victor Stinnerd7e76402011-02-22 23:38:34 +000025 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 Stinner27ee0892011-03-04 12:57:09 +000030PyAPI_FUNC(PyObject *) PyImport_ExecCodeModuleObject(
31 PyObject *name,
32 PyObject *co,
33 PyObject *pathname,
34 PyObject *cpathname
35 );
Mark Hammond8235ea12002-07-19 06:55:41 +000036PyAPI_FUNC(PyObject *) PyImport_GetModuleDict(void);
Victor Stinner27ee0892011-03-04 12:57:09 +000037PyAPI_FUNC(PyObject *) PyImport_AddModuleObject(
38 PyObject *name
39 );
Victor Stinnerd7e76402011-02-22 23:38:34 +000040PyAPI_FUNC(PyObject *) PyImport_AddModule(
41 const char *name /* UTF-8 encoded string */
42 );
43PyAPI_FUNC(PyObject *) PyImport_ImportModule(
44 const char *name /* UTF-8 encoded string */
45 );
46PyAPI_FUNC(PyObject *) PyImport_ImportModuleNoBlock(
47 const char *name /* UTF-8 encoded string */
48 );
49PyAPI_FUNC(PyObject *) PyImport_ImportModuleLevel(
Benjamin Peterson04778a82011-05-25 09:29:00 -050050 const char *name, /* UTF-8 encoded string */
Victor Stinnerd7e76402011-02-22 23:38:34 +000051 PyObject *globals,
52 PyObject *locals,
53 PyObject *fromlist,
54 int level
55 );
Victor Stinnerfe93faf2011-03-14 15:54:52 -040056PyAPI_FUNC(PyObject *) PyImport_ImportModuleLevelObject(
57 PyObject *name,
58 PyObject *globals,
59 PyObject *locals,
60 PyObject *fromlist,
61 int level
62 );
Thomas Woutersf7f438b2006-02-28 16:09:29 +000063
Thomas Woutersf7f438b2006-02-28 16:09:29 +000064#define PyImport_ImportModuleEx(n, g, l, f) \
Brett Cannon522267e2012-08-10 18:55:08 -040065 PyImport_ImportModuleLevel(n, g, l, f, 0)
Thomas Woutersf7f438b2006-02-28 16:09:29 +000066
Christian Heimes9cd17752007-11-18 19:35:23 +000067PyAPI_FUNC(PyObject *) PyImport_GetImporter(PyObject *path);
Mark Hammond8235ea12002-07-19 06:55:41 +000068PyAPI_FUNC(PyObject *) PyImport_Import(PyObject *name);
69PyAPI_FUNC(PyObject *) PyImport_ReloadModule(PyObject *m);
70PyAPI_FUNC(void) PyImport_Cleanup(void);
Victor Stinner53dc7352011-03-20 01:50:21 +010071PyAPI_FUNC(int) PyImport_ImportFrozenModuleObject(
72 PyObject *name
73 );
Victor Stinnerd7e76402011-02-22 23:38:34 +000074PyAPI_FUNC(int) PyImport_ImportFrozenModule(
75 char *name /* UTF-8 encoded string */
76 );
Fred Drake5eb6d4e2000-07-08 23:37:28 +000077
Martin v. Löwis4d0d4712010-12-03 20:14:31 +000078#ifndef Py_LIMITED_API
Benjamin Peterson0df35a92009-10-04 20:32:25 +000079#ifdef WITH_THREAD
80PyAPI_FUNC(void) _PyImport_AcquireLock(void);
81PyAPI_FUNC(int) _PyImport_ReleaseLock(void);
82#else
83#define _PyImport_AcquireLock()
84#define _PyImport_ReleaseLock() 1
85#endif
86
Guido van Rossum8ee3e5a2005-09-14 18:09:42 +000087PyAPI_FUNC(void) _PyImport_ReInitLock(void);
Raymond Hettingerdb29e0f2004-10-07 06:46:25 +000088
Victor Stinnerd860d5c2013-12-10 01:19:58 +010089PyAPI_FUNC(PyObject *) _PyImport_FindBuiltin(
Victor Stinner501c09a2011-02-23 00:02:00 +000090 const char *name /* UTF-8 encoded string */
Victor Stinnerd7e76402011-02-22 23:38:34 +000091 );
Victor Stinnerd860d5c2013-12-10 01:19:58 +010092PyAPI_FUNC(PyObject *) _PyImport_FindExtensionObject(PyObject *, PyObject *);
93PyAPI_FUNC(int) _PyImport_FixupBuiltin(
Victor Stinnerd7e76402011-02-22 23:38:34 +000094 PyObject *mod,
95 char *name /* UTF-8 encoded string */
96 );
Victor Stinnerd860d5c2013-12-10 01:19:58 +010097PyAPI_FUNC(int) _PyImport_FixupExtensionObject(PyObject*, PyObject *, PyObject *);
Guido van Rossum29e46a91997-08-02 02:56:48 +000098
Guido van Rossum39c2aae1996-05-22 17:25:28 +000099struct _inittab {
Victor Stinnerdb536af2011-03-07 18:34:59 +0100100 char *name; /* ASCII encoded string */
Martin v. Löwis1a214512008-06-11 05:26:20 +0000101 PyObject* (*initfunc)(void);
Guido van Rossum39c2aae1996-05-22 17:25:28 +0000102};
Martin v. Löwis4d0d4712010-12-03 20:14:31 +0000103PyAPI_DATA(struct _inittab *) PyImport_Inittab;
104PyAPI_FUNC(int) PyImport_ExtendInittab(struct _inittab *newtab);
105#endif /* Py_LIMITED_API */
Guido van Rossum39c2aae1996-05-22 17:25:28 +0000106
Christian Heimes9cd17752007-11-18 19:35:23 +0000107PyAPI_DATA(PyTypeObject) PyNullImporter_Type;
Guido van Rossuma3309961993-07-28 09:05:47 +0000108
Victor Stinnerd7e76402011-02-22 23:38:34 +0000109PyAPI_FUNC(int) PyImport_AppendInittab(
110 const char *name, /* ASCII encoded string */
111 PyObject* (*initfunc)(void)
112 );
Guido van Rossum16926bd1998-06-29 20:34:46 +0000113
Martin v. Löwis4d0d4712010-12-03 20:14:31 +0000114#ifndef Py_LIMITED_API
Guido van Rossum4ee68d91996-06-17 17:05:01 +0000115struct _frozen {
Victor Stinnerd7e76402011-02-22 23:38:34 +0000116 char *name; /* ASCII encoded string */
Fred Drake5eb6d4e2000-07-08 23:37:28 +0000117 unsigned char *code;
118 int size;
Guido van Rossum4ee68d91996-06-17 17:05:01 +0000119};
120
121/* Embedding apps may change this pointer to point to their favorite
122 collection of frozen modules: */
123
Mark Hammonda2905272002-07-29 13:42:14 +0000124PyAPI_DATA(struct _frozen *) PyImport_FrozenModules;
Martin v. Löwis4d0d4712010-12-03 20:14:31 +0000125#endif
Guido van Rossum4ee68d91996-06-17 17:05:01 +0000126
Guido van Rossuma3309961993-07-28 09:05:47 +0000127#ifdef __cplusplus
128}
129#endif
130#endif /* !Py_IMPORT_H */