1999-12-20 21:22:24 +00:00
|
|
|
#ifndef Py_IMPORTDL_H
|
|
|
|
#define Py_IMPORTDL_H
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
1995-01-02 19:04:15 +00:00
|
|
|
|
|
|
|
/* Definitions for dynamic loading of extension modules */
|
First part of package support.
This doesn't yet support "import a.b.c" or "from a.b.c import x", but
it does recognize directories. When importing a directory, it
initializes __path__ to a list containing the directory name, and
loads the __init__ module if found.
The (internal) find_module() and load_module() functions are
restructured so that they both also handle built-in and frozen modules
and Mac resources (and directories of course). The imp module's
find_module() and (new) load_module() also have this functionality.
Moreover, imp unconditionally defines constants for all module types,
and has two more new functions: find_module_in_package() and
find_module_in_directory().
There's also a new API function, PyImport_ImportModuleEx(), which
takes all four __import__ arguments (name, globals, locals, fromlist).
The last three may be NULL. This is currently the same as
PyImport_ImportModule() but in the future it will be able to do
relative dotted-path imports.
Other changes:
- bltinmodule.c: in __import__, call PyImport_ImportModuleEx().
- ceval.c: always pass the fromlist to __import__, even if it is a C
function, so PyImport_ImportModuleEx() is useful.
- getmtime.c: the function has a second argument, the FILE*, on which
it applies fstat(). According to Sjoerd this is much faster. The
first (pathname) argument is ignored, but remains for backward
compatibility (so the Mac version still works without changes).
By cleverly combining the new imp functionality, the full support for
dotted names in Python (mini.py, not checked in) is now about 7K,
lavishly commented (vs. 14K for ni plus 11K for ihooks, also lavishly
commented).
Good night!
1997-09-05 07:33:22 +00:00
|
|
|
enum filetype {
|
|
|
|
SEARCH_ERROR,
|
|
|
|
PY_SOURCE,
|
|
|
|
PY_COMPILED,
|
|
|
|
C_EXTENSION,
|
|
|
|
PY_RESOURCE, /* Mac only */
|
|
|
|
PKG_DIRECTORY,
|
|
|
|
C_BUILTIN,
|
1998-08-06 13:36:43 +00:00
|
|
|
PY_FROZEN,
|
|
|
|
PY_CODERESOURCE /* Mac only */
|
First part of package support.
This doesn't yet support "import a.b.c" or "from a.b.c import x", but
it does recognize directories. When importing a directory, it
initializes __path__ to a list containing the directory name, and
loads the __init__ module if found.
The (internal) find_module() and load_module() functions are
restructured so that they both also handle built-in and frozen modules
and Mac resources (and directories of course). The imp module's
find_module() and (new) load_module() also have this functionality.
Moreover, imp unconditionally defines constants for all module types,
and has two more new functions: find_module_in_package() and
find_module_in_directory().
There's also a new API function, PyImport_ImportModuleEx(), which
takes all four __import__ arguments (name, globals, locals, fromlist).
The last three may be NULL. This is currently the same as
PyImport_ImportModule() but in the future it will be able to do
relative dotted-path imports.
Other changes:
- bltinmodule.c: in __import__, call PyImport_ImportModuleEx().
- ceval.c: always pass the fromlist to __import__, even if it is a C
function, so PyImport_ImportModuleEx() is useful.
- getmtime.c: the function has a second argument, the FILE*, on which
it applies fstat(). According to Sjoerd this is much faster. The
first (pathname) argument is ignored, but remains for backward
compatibility (so the Mac version still works without changes).
By cleverly combining the new imp functionality, the full support for
dotted names in Python (mini.py, not checked in) is now about 7K,
lavishly commented (vs. 14K for ni plus 11K for ihooks, also lavishly
commented).
Good night!
1997-09-05 07:33:22 +00:00
|
|
|
};
|
1995-01-02 19:04:15 +00:00
|
|
|
|
1999-12-20 21:22:24 +00:00
|
|
|
struct filedescr {
|
1995-01-02 19:04:15 +00:00
|
|
|
char *suffix;
|
|
|
|
char *mode;
|
|
|
|
enum filetype type;
|
1999-12-20 21:22:24 +00:00
|
|
|
};
|
|
|
|
extern struct filedescr * _PyImport_Filetab;
|
|
|
|
extern const struct filedescr _PyImport_DynLoadFiletab[];
|
1995-01-02 19:04:15 +00:00
|
|
|
|
2000-07-09 03:09:57 +00:00
|
|
|
extern PyObject *_PyImport_LoadDynamicModule(char *name, char *pathname,
|
|
|
|
FILE *);
|
1995-01-02 19:04:15 +00:00
|
|
|
|
1997-07-21 14:54:36 +00:00
|
|
|
/* Max length of module suffix searched for -- accommodates "module.slb" */
|
|
|
|
#define MAXSUFFIXSIZE 12
|
1999-12-20 21:22:24 +00:00
|
|
|
|
|
|
|
#ifdef MS_WINDOWS
|
1999-12-20 22:55:03 +00:00
|
|
|
#include <windows.h>
|
1999-12-20 21:22:24 +00:00
|
|
|
typedef FARPROC dl_funcptr;
|
|
|
|
#else
|
|
|
|
#ifdef PYOS_OS2
|
|
|
|
typedef int (* APIENTRY dl_funcptr)();
|
|
|
|
#else
|
|
|
|
typedef void (*dl_funcptr)(void);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif /* !Py_IMPORTDL_H */
|