2022-01-25 13:46:27 +00:00
|
|
|
use crate::object::PyObject;
|
2018-07-30 21:01:46 +00:00
|
|
|
use std::os::raw::{c_char, c_int, c_long};
|
2015-04-26 08:32:58 +00:00
|
|
|
|
2018-07-30 21:01:46 +00:00
|
|
|
extern "C" {
|
2015-04-26 08:32:58 +00:00
|
|
|
pub fn PyImport_GetMagicNumber() -> c_long;
|
|
|
|
pub fn PyImport_GetMagicTag() -> *const c_char;
|
2019-04-23 11:18:42 +00:00
|
|
|
#[cfg_attr(PyPy, link_name = "PyPyImport_ExecCodeModule")]
|
2018-07-30 21:01:46 +00:00
|
|
|
pub fn PyImport_ExecCodeModule(name: *const c_char, co: *mut PyObject) -> *mut PyObject;
|
2019-04-23 11:18:42 +00:00
|
|
|
#[cfg_attr(PyPy, link_name = "PyPyImport_ExecCodeModuleEx")]
|
2018-07-30 21:01:46 +00:00
|
|
|
pub fn PyImport_ExecCodeModuleEx(
|
|
|
|
name: *const c_char,
|
|
|
|
co: *mut PyObject,
|
|
|
|
pathname: *const c_char,
|
|
|
|
) -> *mut PyObject;
|
|
|
|
pub fn PyImport_ExecCodeModuleWithPathnames(
|
|
|
|
name: *const c_char,
|
|
|
|
co: *mut PyObject,
|
|
|
|
pathname: *const c_char,
|
|
|
|
cpathname: *const c_char,
|
|
|
|
) -> *mut PyObject;
|
|
|
|
pub fn PyImport_ExecCodeModuleObject(
|
|
|
|
name: *mut PyObject,
|
|
|
|
co: *mut PyObject,
|
|
|
|
pathname: *mut PyObject,
|
|
|
|
cpathname: *mut PyObject,
|
|
|
|
) -> *mut PyObject;
|
2019-04-23 11:18:42 +00:00
|
|
|
#[cfg_attr(PyPy, link_name = "PyPyImport_GetModuleDict")]
|
2015-04-26 08:32:58 +00:00
|
|
|
pub fn PyImport_GetModuleDict() -> *mut PyObject;
|
2020-12-29 10:20:52 +00:00
|
|
|
// skipped Python 3.7 / ex-non-limited PyImport_GetModule
|
2015-04-26 08:32:58 +00:00
|
|
|
pub fn PyImport_AddModuleObject(name: *mut PyObject) -> *mut PyObject;
|
2019-04-23 11:18:42 +00:00
|
|
|
#[cfg_attr(PyPy, link_name = "PyPyImport_AddModule")]
|
2015-04-26 08:32:58 +00:00
|
|
|
pub fn PyImport_AddModule(name: *const c_char) -> *mut PyObject;
|
2019-04-23 11:18:42 +00:00
|
|
|
#[cfg_attr(PyPy, link_name = "PyPyImport_ImportModule")]
|
2018-07-30 21:01:46 +00:00
|
|
|
pub fn PyImport_ImportModule(name: *const c_char) -> *mut PyObject;
|
2019-04-23 11:18:42 +00:00
|
|
|
#[cfg_attr(PyPy, link_name = "PyPyImport_ImportModuleNoBlock")]
|
2018-07-30 21:01:46 +00:00
|
|
|
pub fn PyImport_ImportModuleNoBlock(name: *const c_char) -> *mut PyObject;
|
2019-04-23 11:18:42 +00:00
|
|
|
#[cfg_attr(PyPy, link_name = "PyPyImport_ImportModuleLevel")]
|
2018-07-30 21:01:46 +00:00
|
|
|
pub fn PyImport_ImportModuleLevel(
|
|
|
|
name: *const c_char,
|
|
|
|
globals: *mut PyObject,
|
|
|
|
locals: *mut PyObject,
|
|
|
|
fromlist: *mut PyObject,
|
|
|
|
level: c_int,
|
|
|
|
) -> *mut PyObject;
|
2019-04-23 11:18:42 +00:00
|
|
|
#[cfg_attr(PyPy, link_name = "PyPyImport_ImportModuleLevelObject")]
|
2018-07-30 21:01:46 +00:00
|
|
|
pub fn PyImport_ImportModuleLevelObject(
|
|
|
|
name: *mut PyObject,
|
|
|
|
globals: *mut PyObject,
|
|
|
|
locals: *mut PyObject,
|
|
|
|
fromlist: *mut PyObject,
|
|
|
|
level: c_int,
|
|
|
|
) -> *mut PyObject;
|
2015-04-26 08:32:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[inline]
|
2018-07-30 21:01:46 +00:00
|
|
|
pub unsafe fn PyImport_ImportModuleEx(
|
|
|
|
name: *const c_char,
|
|
|
|
globals: *mut PyObject,
|
|
|
|
locals: *mut PyObject,
|
|
|
|
fromlist: *mut PyObject,
|
|
|
|
) -> *mut PyObject {
|
2015-04-26 08:32:58 +00:00
|
|
|
PyImport_ImportModuleLevel(name, globals, locals, fromlist, 0)
|
|
|
|
}
|
|
|
|
|
2018-07-30 21:01:46 +00:00
|
|
|
extern "C" {
|
2015-04-26 08:32:58 +00:00
|
|
|
pub fn PyImport_GetImporter(path: *mut PyObject) -> *mut PyObject;
|
2020-09-01 06:33:48 +00:00
|
|
|
#[cfg_attr(PyPy, link_name = "PyPyImport_Import")]
|
2015-04-26 08:32:58 +00:00
|
|
|
pub fn PyImport_Import(name: *mut PyObject) -> *mut PyObject;
|
2019-04-23 11:18:42 +00:00
|
|
|
#[cfg_attr(PyPy, link_name = "PyPyImport_ReloadModule")]
|
2015-04-26 08:32:58 +00:00
|
|
|
pub fn PyImport_ReloadModule(m: *mut PyObject) -> *mut PyObject;
|
2020-12-29 10:20:52 +00:00
|
|
|
#[cfg(not(Py_3_9))]
|
2021-11-19 13:33:56 +00:00
|
|
|
#[deprecated(note = "Removed in Python 3.9 as it was \"For internal use only\".")]
|
2020-04-07 19:50:01 +00:00
|
|
|
pub fn PyImport_Cleanup();
|
2018-07-30 21:01:46 +00:00
|
|
|
pub fn PyImport_ImportFrozenModuleObject(name: *mut PyObject) -> c_int;
|
|
|
|
pub fn PyImport_ImportFrozenModule(name: *const c_char) -> c_int;
|
2015-04-26 08:32:58 +00:00
|
|
|
|
2018-07-30 21:01:46 +00:00
|
|
|
pub fn PyImport_AppendInittab(
|
|
|
|
name: *const c_char,
|
2022-05-17 02:50:51 +00:00
|
|
|
initfunc: Option<unsafe extern "C" fn() -> *mut PyObject>,
|
2018-07-30 21:01:46 +00:00
|
|
|
) -> c_int;
|
2015-04-26 08:32:58 +00:00
|
|
|
}
|