1use crate::object::PyObject;
2use std::os::raw::{c_char, c_int, c_long};
3
4extern "C" {
5 pub fn PyImport_GetMagicNumber() -> c_long;
6 pub fn PyImport_GetMagicTag() -> *const c_char;
7 #[cfg_attr(PyPy, link_name = "PyPyImport_ExecCodeModule")]
8 pub fn PyImport_ExecCodeModule(name: *const c_char, co: *mut PyObject) -> *mut PyObject;
9 #[cfg_attr(PyPy, link_name = "PyPyImport_ExecCodeModuleEx")]
10 pub fn PyImport_ExecCodeModuleEx(
11 name: *const c_char,
12 co: *mut PyObject,
13 pathname: *const c_char,
14 ) -> *mut PyObject;
15 pub fn PyImport_ExecCodeModuleWithPathnames(
16 name: *const c_char,
17 co: *mut PyObject,
18 pathname: *const c_char,
19 cpathname: *const c_char,
20 ) -> *mut PyObject;
21 pub fn PyImport_ExecCodeModuleObject(
22 name: *mut PyObject,
23 co: *mut PyObject,
24 pathname: *mut PyObject,
25 cpathname: *mut PyObject,
26 ) -> *mut PyObject;
27 #[cfg_attr(PyPy, link_name = "PyPyImport_GetModuleDict")]
28 pub fn PyImport_GetModuleDict() -> *mut PyObject;
29 // skipped Python 3.7 / ex-non-limited PyImport_GetModule
30 pub fn PyImport_AddModuleObject(name: *mut PyObject) -> *mut PyObject;
31 #[cfg_attr(PyPy, link_name = "PyPyImport_AddModule")]
32 pub fn PyImport_AddModule(name: *const c_char) -> *mut PyObject;
33 #[cfg_attr(PyPy, link_name = "PyPyImport_ImportModule")]
34 pub fn PyImport_ImportModule(name: *const c_char) -> *mut PyObject;
35 #[cfg_attr(PyPy, link_name = "PyPyImport_ImportModuleNoBlock")]
36 pub fn PyImport_ImportModuleNoBlock(name: *const c_char) -> *mut PyObject;
37 #[cfg_attr(PyPy, link_name = "PyPyImport_ImportModuleLevel")]
38 pub fn PyImport_ImportModuleLevel(
39 name: *const c_char,
40 globals: *mut PyObject,
41 locals: *mut PyObject,
42 fromlist: *mut PyObject,
43 level: c_int,
44 ) -> *mut PyObject;
45 #[cfg_attr(PyPy, link_name = "PyPyImport_ImportModuleLevelObject")]
46 pub fn PyImport_ImportModuleLevelObject(
47 name: *mut PyObject,
48 globals: *mut PyObject,
49 locals: *mut PyObject,
50 fromlist: *mut PyObject,
51 level: c_int,
52 ) -> *mut PyObject;
53}
54
55#[inline]
56pub unsafe fn PyImport_ImportModuleEx(
57 name: *const c_char,
58 globals: *mut PyObject,
59 locals: *mut PyObject,
60 fromlist: *mut PyObject,
61) -> *mut PyObject {
62 PyImport_ImportModuleLevel(name, globals, locals, fromlist, level:0)
63}
64
65extern "C" {
66 pub fn PyImport_GetImporter(path: *mut PyObject) -> *mut PyObject;
67 #[cfg_attr(PyPy, link_name = "PyPyImport_Import")]
68 pub fn PyImport_Import(name: *mut PyObject) -> *mut PyObject;
69 #[cfg_attr(PyPy, link_name = "PyPyImport_ReloadModule")]
70 pub fn PyImport_ReloadModule(m: *mut PyObject) -> *mut PyObject;
71 #[cfg(not(Py_3_9))]
72 #[deprecated(note = "Removed in Python 3.9 as it was \"For internal use only\".")]
73 pub fn PyImport_Cleanup();
74 pub fn PyImport_ImportFrozenModuleObject(name: *mut PyObject) -> c_int;
75 pub fn PyImport_ImportFrozenModule(name: *const c_char) -> c_int;
76
77 pub fn PyImport_AppendInittab(
78 name: *const c_char,
79 initfunc: Option<unsafe extern "C" fn() -> *mut PyObject>,
80 ) -> c_int;
81}
82