2018-10-31 10:43:21 +00:00
|
|
|
use crate::ffi3::object::*;
|
2018-07-30 21:01:46 +00:00
|
|
|
use std::os::raw::c_int;
|
2015-04-26 08:32:58 +00:00
|
|
|
|
|
|
|
pub enum PyWeakReference {}
|
|
|
|
|
2018-07-30 21:01:46 +00:00
|
|
|
#[cfg_attr(windows, link(name = "pythonXY"))]
|
|
|
|
extern "C" {
|
2015-04-26 08:32:58 +00:00
|
|
|
static mut _PyWeakref_RefType: PyTypeObject;
|
|
|
|
static mut _PyWeakref_ProxyType: PyTypeObject;
|
|
|
|
static mut _PyWeakref_CallableProxyType: PyTypeObject;
|
|
|
|
}
|
|
|
|
|
2018-08-21 19:07:07 +00:00
|
|
|
#[inline]
|
2015-04-26 08:32:58 +00:00
|
|
|
pub unsafe fn PyWeakref_CheckRef(op: *mut PyObject) -> c_int {
|
|
|
|
PyObject_TypeCheck(op, &mut _PyWeakref_RefType)
|
|
|
|
}
|
|
|
|
|
2018-08-21 19:07:07 +00:00
|
|
|
#[inline]
|
2015-04-26 08:32:58 +00:00
|
|
|
pub unsafe fn PyWeakref_CheckRefExact(op: *mut PyObject) -> c_int {
|
|
|
|
(Py_TYPE(op) == &mut _PyWeakref_RefType) as c_int
|
|
|
|
}
|
|
|
|
|
2018-08-21 19:07:07 +00:00
|
|
|
#[inline]
|
2015-04-26 08:32:58 +00:00
|
|
|
pub unsafe fn PyWeakref_CheckProxy(op: *mut PyObject) -> c_int {
|
2018-07-30 21:01:46 +00:00
|
|
|
((Py_TYPE(op) == &mut _PyWeakref_ProxyType)
|
|
|
|
|| (Py_TYPE(op) == &mut _PyWeakref_CallableProxyType)) as c_int
|
2015-04-26 08:32:58 +00:00
|
|
|
}
|
|
|
|
|
2018-08-21 19:07:07 +00:00
|
|
|
#[inline]
|
2015-04-26 08:32:58 +00:00
|
|
|
pub unsafe fn PyWeakref_Check(op: *mut PyObject) -> c_int {
|
|
|
|
(PyWeakref_CheckRef(op) != 0 || PyWeakref_CheckProxy(op) != 0) as c_int
|
|
|
|
}
|
|
|
|
|
2018-07-30 21:01:46 +00:00
|
|
|
#[cfg_attr(windows, link(name = "pythonXY"))]
|
|
|
|
extern "C" {
|
|
|
|
pub fn PyWeakref_NewRef(ob: *mut PyObject, callback: *mut PyObject) -> *mut PyObject;
|
|
|
|
pub fn PyWeakref_NewProxy(ob: *mut PyObject, callback: *mut PyObject) -> *mut PyObject;
|
2015-04-26 08:32:58 +00:00
|
|
|
pub fn PyWeakref_GetObject(_ref: *mut PyObject) -> *mut PyObject;
|
|
|
|
}
|