python27_sys/
cellobject.rs1use libc::c_int;
2
3use crate::object::*;
4use crate::pyport::Py_ssize_t;
5
6#[repr(C)]
7#[derive(Copy, Clone)]
8struct PyCellObject {
9 #[cfg(py_sys_config = "Py_TRACE_REFS")]
10 pub _ob_next: *mut PyObject,
11 #[cfg(py_sys_config = "Py_TRACE_REFS")]
12 pub _ob_prev: *mut PyObject,
13 pub ob_refcnt: Py_ssize_t,
14 pub ob_type: *mut PyTypeObject,
15 pub ob_ref: *mut PyObject,
16}
17
18#[cfg_attr(windows, link(name = "pythonXY"))]
19extern "C" {
20 pub static mut PyCell_Type: PyTypeObject;
21}
22
23#[inline(always)]
24pub unsafe fn PyCell_Check(op: *mut PyObject) -> c_int {
25 (Py_TYPE(op) == &mut PyCell_Type) as c_int
26}
27
28#[cfg_attr(windows, link(name = "pythonXY"))]
29extern "C" {
30 pub fn PyCell_New(obj: *mut PyObject) -> *mut PyObject;
31 pub fn PyCell_Get(op: *mut PyObject) -> *mut PyObject;
32 pub fn PyCell_Set(op: *mut PyObject, obj: *mut PyObject) -> c_int;
33}
34
35#[inline(always)]
36pub unsafe fn PyCell_GET(op: *mut PyObject) -> *mut PyObject {
37 (*(op as *mut PyCellObject)).ob_ref
38}
39
40#[inline(always)]
41pub unsafe fn PyCell_SET(op: *mut PyObject, obj: *mut PyObject) {
42 (*(op as *mut PyCellObject)).ob_ref = obj;
43}