python27_sys/
moduleobject.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
use libc::{c_char, c_int};

use crate::object::*;

#[cfg_attr(windows, link(name = "pythonXY"))]
extern "C" {
    pub static mut PyModule_Type: PyTypeObject;

    pub fn PyModule_New(name: *const c_char) -> *mut PyObject;
    pub fn PyModule_GetDict(module: *mut PyObject) -> *mut PyObject;
    pub fn PyModule_GetName(module: *mut PyObject) -> *mut c_char;
    pub fn PyModule_GetFilename(module: *mut PyObject) -> *mut c_char;
    ignore! {
        fn _PyModule_Clear(arg1: *mut PyObject);
    }
}

#[inline(always)]
pub unsafe fn PyModule_Check(op: *mut PyObject) -> c_int {
    PyObject_TypeCheck(op, &mut PyModule_Type)
}

#[inline(always)]
pub unsafe fn PyModule_CheckExact(op: *mut PyObject) -> c_int {
    let u: *mut PyTypeObject = &mut PyModule_Type;
    (Py_TYPE(op) == u) as c_int
}