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
28
29
30
31
32
33
34
35
36
37
use libc::{c_void, c_char, c_int};
use object::*;

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

#[inline(always)]
pub unsafe fn PyCObject_Check(op : *mut PyObject) -> c_int {
    (Py_TYPE(op) == &mut PyCObject_Type) as c_int
}

#[cfg_attr(windows, link(name="pythonXY"))] extern "C" {
    pub fn PyCObject_FromVoidPtr(cobj: *mut c_void,
                                 destruct:
                                     Option<unsafe extern "C" fn
                                                               (arg1:
                                                                    *mut c_void)>)
     -> *mut PyObject;
    pub fn PyCObject_FromVoidPtrAndDesc(cobj: *mut c_void,
                                        desc: *mut c_void,
                                        destruct:
                                            Option<unsafe extern "C" fn
                                                                      (arg1:
                                                                           *mut c_void,
                                                                       arg2:
                                                                           *mut c_void)>)
     -> *mut PyObject;
    pub fn PyCObject_AsVoidPtr(arg1: *mut PyObject) -> *mut c_void;
    pub fn PyCObject_GetDesc(arg1: *mut PyObject) -> *mut c_void;
    pub fn PyCObject_Import(module_name: *mut c_char,
                            cobject_name: *mut c_char)
     -> *mut c_void;
    pub fn PyCObject_SetVoidPtr(_self: *mut PyObject,
                                cobj: *mut c_void) -> c_int;
}