Skip to main content

pyforge_ffi/cpython/
import.rs

1use crate::PyObject;
2use std::ffi::c_char;
3use std::ffi::{c_int, c_uchar};
4
5#[repr(C)]
6#[derive(Copy, Clone)]
7pub struct _inittab {
8    pub name: *const c_char,
9    pub initfunc: Option<unsafe extern "C" fn() -> *mut PyObject>,
10}
11
12extern_libpython! {
13    pub static mut PyImport_Inittab: *mut _inittab;
14
15    pub fn PyImport_ExtendInittab(newtab: *mut _inittab) -> c_int;
16}
17
18#[repr(C)]
19#[derive(Copy, Clone)]
20pub struct _frozen {
21    pub name: *const c_char,
22    pub code: *const c_uchar,
23    pub size: c_int,
24    #[cfg(Py_3_11)]
25    pub is_package: c_int,
26    #[cfg(all(Py_3_11, not(Py_3_13)))]
27    pub get_code: Option<unsafe extern "C" fn() -> *mut PyObject>,
28}
29
30extern_libpython! {
31    pub static mut PyImport_FrozenModules: *const _frozen;
32
33    #[cfg(Py_3_14)]
34    pub fn PyImport_ImportModuleAttr(
35        mod_name: *mut PyObject,
36        attr_name: *mut PyObject,
37    ) -> *mut PyObject;
38    #[cfg(Py_3_14)]
39    pub fn PyImport_ImportModuleAttrString(
40        mod_name: *const c_char,
41        attr_name: *const c_char,
42    ) -> *mut PyObject;
43}