blob: 4554411156fd2f268e7f7613551631c2bcfb88c3 [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
Mark Hammond8235ea12002-07-19 06:55:41 +000010PyAPI_FUNC(long) PyImport_GetMagicNumber(void);
Barry Warsaw28a691b2010-04-17 00:19:56 +000011PyAPI_FUNC(const char *) PyImport_GetMagicTag(void);
Victor Stinnerd7e76402011-02-22 23:38:34 +000012PyAPI_FUNC(PyObject *) PyImport_ExecCodeModule(
13 char *name, /* UTF-8 encoded string */
14 PyObject *co
15 );
Mark Hammond8235ea12002-07-19 06:55:41 +000016PyAPI_FUNC(PyObject *) PyImport_ExecCodeModuleEx(
Victor Stinnerd7e76402011-02-22 23:38:34 +000017 char *name, /* UTF-8 encoded string */
18 PyObject *co,
19 char *pathname /* decoded from the filesystem encoding */
20 );
Barry Warsaw28a691b2010-04-17 00:19:56 +000021PyAPI_FUNC(PyObject *) PyImport_ExecCodeModuleWithPathnames(
Victor Stinnerd7e76402011-02-22 23:38:34 +000022 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 Stinner27ee0892011-03-04 12:57:09 +000027PyAPI_FUNC(PyObject *) PyImport_ExecCodeModuleObject(
28 PyObject *name,
29 PyObject *co,
30 PyObject *pathname,
31 PyObject *cpathname
32 );
Mark Hammond8235ea12002-07-19 06:55:41 +000033PyAPI_FUNC(PyObject *) PyImport_GetModuleDict(void);
Victor Stinner27ee0892011-03-04 12:57:09 +000034PyAPI_FUNC(PyObject *) PyImport_AddModuleObject(
35 PyObject *name
36 );
Victor Stinnerd7e76402011-02-22 23:38:34 +000037PyAPI_FUNC(PyObject *) PyImport_AddModule(
38 const char *name /* UTF-8 encoded string */
39 );
40PyAPI_FUNC(PyObject *) PyImport_ImportModule(
41 const char *name /* UTF-8 encoded string */
42 );
43PyAPI_FUNC(PyObject *) PyImport_ImportModuleNoBlock(
44 const char *name /* UTF-8 encoded string */
45 );
46PyAPI_FUNC(PyObject *) PyImport_ImportModuleLevel(
Benjamin Peterson04778a82011-05-25 09:29:00 -050047 const char *name, /* UTF-8 encoded string */
Victor Stinnerd7e76402011-02-22 23:38:34 +000048 PyObject *globals,
49 PyObject *locals,
50 PyObject *fromlist,
51 int level
52 );
Victor Stinnerfe93faf2011-03-14 15:54:52 -040053PyAPI_FUNC(PyObject *) PyImport_ImportModuleLevelObject(
54 PyObject *name,
55 PyObject *globals,
56 PyObject *locals,
57 PyObject *fromlist,
58 int level
59 );
Thomas Woutersf7f438b2006-02-28 16:09:29 +000060
Thomas Woutersf7f438b2006-02-28 16:09:29 +000061#define PyImport_ImportModuleEx(n, g, l, f) \
Victor Stinnerd7e76402011-02-22 23:38:34 +000062 PyImport_ImportModuleLevel(n, g, l, f, -1)
Thomas Woutersf7f438b2006-02-28 16:09:29 +000063
Christian Heimes9cd17752007-11-18 19:35:23 +000064PyAPI_FUNC(PyObject *) PyImport_GetImporter(PyObject *path);
Mark Hammond8235ea12002-07-19 06:55:41 +000065PyAPI_FUNC(PyObject *) PyImport_Import(PyObject *name);
66PyAPI_FUNC(PyObject *) PyImport_ReloadModule(PyObject *m);
67PyAPI_FUNC(void) PyImport_Cleanup(void);
Victor Stinner53dc7352011-03-20 01:50:21 +010068PyAPI_FUNC(int) PyImport_ImportFrozenModuleObject(
69 PyObject *name
70 );
Victor Stinnerd7e76402011-02-22 23:38:34 +000071PyAPI_FUNC(int) PyImport_ImportFrozenModule(
72 char *name /* UTF-8 encoded string */
73 );
Fred Drake5eb6d4e2000-07-08 23:37:28 +000074
Martin v. Löwis4d0d4712010-12-03 20:14:31 +000075#ifndef Py_LIMITED_API
Benjamin Peterson0df35a92009-10-04 20:32:25 +000076#ifdef WITH_THREAD
77PyAPI_FUNC(void) _PyImport_AcquireLock(void);
78PyAPI_FUNC(int) _PyImport_ReleaseLock(void);
79#else
80#define _PyImport_AcquireLock()
81#define _PyImport_ReleaseLock() 1
82#endif
83
Guido van Rossum8ee3e5a2005-09-14 18:09:42 +000084PyAPI_FUNC(void) _PyImport_ReInitLock(void);
Raymond Hettingerdb29e0f2004-10-07 06:46:25 +000085
Victor Stinnerd7e76402011-02-22 23:38:34 +000086PyAPI_FUNC(PyObject *)_PyImport_FindBuiltin(
Victor Stinner501c09a2011-02-23 00:02:00 +000087 const char *name /* UTF-8 encoded string */
Victor Stinnerd7e76402011-02-22 23:38:34 +000088 );
Victor Stinner95872862011-03-07 18:20:56 +010089PyAPI_FUNC(PyObject *)_PyImport_FindExtensionObject(PyObject *, PyObject *);
Victor Stinnerd7e76402011-02-22 23:38:34 +000090PyAPI_FUNC(int)_PyImport_FixupBuiltin(
91 PyObject *mod,
92 char *name /* UTF-8 encoded string */
93 );
Victor Stinner95872862011-03-07 18:20:56 +010094PyAPI_FUNC(int)_PyImport_FixupExtensionObject(PyObject*, PyObject *, PyObject *);
Guido van Rossum29e46a91997-08-02 02:56:48 +000095
Guido van Rossum39c2aae1996-05-22 17:25:28 +000096struct _inittab {
Victor Stinnerdb536af2011-03-07 18:34:59 +010097 char *name; /* ASCII encoded string */
Martin v. Löwis1a214512008-06-11 05:26:20 +000098 PyObject* (*initfunc)(void);
Guido van Rossum39c2aae1996-05-22 17:25:28 +000099};
Martin v. Löwis4d0d4712010-12-03 20:14:31 +0000100PyAPI_DATA(struct _inittab *) PyImport_Inittab;
101PyAPI_FUNC(int) PyImport_ExtendInittab(struct _inittab *newtab);
102#endif /* Py_LIMITED_API */
Guido van Rossum39c2aae1996-05-22 17:25:28 +0000103
Christian Heimes9cd17752007-11-18 19:35:23 +0000104PyAPI_DATA(PyTypeObject) PyNullImporter_Type;
Guido van Rossuma3309961993-07-28 09:05:47 +0000105
Victor Stinnerd7e76402011-02-22 23:38:34 +0000106PyAPI_FUNC(int) PyImport_AppendInittab(
107 const char *name, /* ASCII encoded string */
108 PyObject* (*initfunc)(void)
109 );
Guido van Rossum16926bd1998-06-29 20:34:46 +0000110
Martin v. Löwis4d0d4712010-12-03 20:14:31 +0000111#ifndef Py_LIMITED_API
Guido van Rossum4ee68d91996-06-17 17:05:01 +0000112struct _frozen {
Victor Stinnerd7e76402011-02-22 23:38:34 +0000113 char *name; /* ASCII encoded string */
Fred Drake5eb6d4e2000-07-08 23:37:28 +0000114 unsigned char *code;
115 int size;
Guido van Rossum4ee68d91996-06-17 17:05:01 +0000116};
117
118/* Embedding apps may change this pointer to point to their favorite
119 collection of frozen modules: */
120
Mark Hammonda2905272002-07-29 13:42:14 +0000121PyAPI_DATA(struct _frozen *) PyImport_FrozenModules;
Martin v. Löwis4d0d4712010-12-03 20:14:31 +0000122#endif
Guido van Rossum4ee68d91996-06-17 17:05:01 +0000123
Guido van Rossuma3309961993-07-28 09:05:47 +0000124#ifdef __cplusplus
125}
126#endif
127#endif /* !Py_IMPORT_H */