File indexing completed on 2025-11-19 09:50:47
0001 #ifndef Py_INTERNAL_IMPORTDL_H
0002 #define Py_INTERNAL_IMPORTDL_H
0003
0004 #include "patchlevel.h" // PY_MAJOR_VERSION
0005
0006 #ifdef __cplusplus
0007 extern "C" {
0008 #endif
0009
0010 #ifndef Py_BUILD_CORE
0011 # error "this header requires Py_BUILD_CORE define"
0012 #endif
0013
0014
0015 extern const char *_PyImport_DynLoadFiletab[];
0016
0017
0018 typedef enum ext_module_kind {
0019 _Py_ext_module_kind_UNKNOWN = 0,
0020 _Py_ext_module_kind_SINGLEPHASE = 1,
0021 _Py_ext_module_kind_MULTIPHASE = 2,
0022 _Py_ext_module_kind_INVALID = 3,
0023 } _Py_ext_module_kind;
0024
0025 typedef enum ext_module_origin {
0026 _Py_ext_module_origin_CORE = 1,
0027 _Py_ext_module_origin_BUILTIN = 2,
0028 _Py_ext_module_origin_DYNAMIC = 3,
0029 } _Py_ext_module_origin;
0030
0031
0032 struct _Py_ext_module_loader_info {
0033 PyObject *filename;
0034 #ifndef MS_WINDOWS
0035 PyObject *filename_encoded;
0036 #endif
0037 PyObject *name;
0038 PyObject *name_encoded;
0039
0040
0041 PyObject *path;
0042 _Py_ext_module_origin origin;
0043 const char *hook_prefix;
0044 const char *newcontext;
0045 };
0046 extern void _Py_ext_module_loader_info_clear(
0047 struct _Py_ext_module_loader_info *info);
0048 extern int _Py_ext_module_loader_info_init(
0049 struct _Py_ext_module_loader_info *info,
0050 PyObject *name,
0051 PyObject *filename,
0052 _Py_ext_module_origin origin);
0053 extern int _Py_ext_module_loader_info_init_for_core(
0054 struct _Py_ext_module_loader_info *p_info,
0055 PyObject *name);
0056 extern int _Py_ext_module_loader_info_init_for_builtin(
0057 struct _Py_ext_module_loader_info *p_info,
0058 PyObject *name);
0059 #ifdef HAVE_DYNAMIC_LOADING
0060 extern int _Py_ext_module_loader_info_init_from_spec(
0061 struct _Py_ext_module_loader_info *info,
0062 PyObject *spec);
0063 #endif
0064
0065
0066 struct _Py_ext_module_loader_result {
0067 PyModuleDef *def;
0068 PyObject *module;
0069 _Py_ext_module_kind kind;
0070 struct _Py_ext_module_loader_result_error *err;
0071 struct _Py_ext_module_loader_result_error {
0072 enum _Py_ext_module_loader_result_error_kind {
0073 _Py_ext_module_loader_result_EXCEPTION = 0,
0074 _Py_ext_module_loader_result_ERR_MISSING = 1,
0075 _Py_ext_module_loader_result_ERR_UNREPORTED_EXC = 2,
0076 _Py_ext_module_loader_result_ERR_UNINITIALIZED = 3,
0077 _Py_ext_module_loader_result_ERR_NONASCII_NOT_MULTIPHASE = 4,
0078 _Py_ext_module_loader_result_ERR_NOT_MODULE = 5,
0079 _Py_ext_module_loader_result_ERR_MISSING_DEF = 6,
0080 } kind;
0081 PyObject *exc;
0082 } _err;
0083 };
0084 extern void _Py_ext_module_loader_result_clear(
0085 struct _Py_ext_module_loader_result *res);
0086 extern void _Py_ext_module_loader_result_apply_error(
0087 struct _Py_ext_module_loader_result *res,
0088 const char *name);
0089
0090
0091 typedef PyObject *(*PyModInitFunction)(void);
0092 #ifdef HAVE_DYNAMIC_LOADING
0093 extern PyModInitFunction _PyImport_GetModInitFunc(
0094 struct _Py_ext_module_loader_info *info,
0095 FILE *fp);
0096 #endif
0097 extern int _PyImport_RunModInitFunc(
0098 PyModInitFunction p0,
0099 struct _Py_ext_module_loader_info *info,
0100 struct _Py_ext_module_loader_result *p_res);
0101
0102
0103
0104 #define MAXSUFFIXSIZE 12
0105
0106 #ifdef MS_WINDOWS
0107 #include <windows.h>
0108 typedef FARPROC dl_funcptr;
0109
0110 #ifdef _DEBUG
0111 # define PYD_DEBUG_SUFFIX "_d"
0112 #else
0113 # define PYD_DEBUG_SUFFIX ""
0114 #endif
0115
0116 #ifdef Py_GIL_DISABLED
0117 # define PYD_THREADING_TAG "t"
0118 #else
0119 # define PYD_THREADING_TAG ""
0120 #endif
0121
0122 #ifdef PYD_PLATFORM_TAG
0123 # define PYD_SOABI "cp" Py_STRINGIFY(PY_MAJOR_VERSION) Py_STRINGIFY(PY_MINOR_VERSION) PYD_THREADING_TAG "-" PYD_PLATFORM_TAG
0124 #else
0125 # define PYD_SOABI "cp" Py_STRINGIFY(PY_MAJOR_VERSION) Py_STRINGIFY(PY_MINOR_VERSION) PYD_THREADING_TAG
0126 #endif
0127
0128 #define PYD_TAGGED_SUFFIX PYD_DEBUG_SUFFIX "." PYD_SOABI ".pyd"
0129 #define PYD_UNTAGGED_SUFFIX PYD_DEBUG_SUFFIX ".pyd"
0130
0131 #else
0132 typedef void (*dl_funcptr)(void);
0133 #endif
0134
0135
0136 #ifdef __cplusplus
0137 }
0138 #endif
0139 #endif