Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions newsfragments/5978.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add non-limited API version of `PyCellObject` and associated functions.
24 changes: 24 additions & 0 deletions pyo3-ffi/src/cpython/cellobject.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
use crate::object::*;
use std::ffi::c_int;

#[cfg(not(any(PyPy, GraalPy)))]
#[repr(C)]
pub struct PyCellObject {
pub ob_base: PyObject,
pub ob_ref: *mut PyObject,
}

extern_libpython! {
pub fn PyCell_New(o: *mut PyObject) -> *mut PyObject;
pub fn PyCell_Get(o: *mut PyObject) -> *mut PyObject;
pub fn PyCell_Set(o: *mut PyObject, val: *mut PyObject) -> *mut PyObject;
pub static mut PyCell_Type: PyTypeObject;
}

#[inline]
pub unsafe fn PyCell_Check(op: *mut PyObject) -> c_int {
Py_IS_TYPE(op, &raw mut PyCell_Type)
}

// skipped PyCell_SET
// skipped PyCell_GET
2 changes: 2 additions & 0 deletions pyo3-ffi/src/cpython/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
pub(crate) mod abstract_;
pub(crate) mod bytearrayobject;
pub(crate) mod bytesobject;
pub(crate) mod cellobject;
#[cfg(not(PyPy))]
pub(crate) mod ceval;
pub(crate) mod code;
Expand Down Expand Up @@ -47,6 +48,7 @@ pub(crate) mod weakrefobject;
pub use self::abstract_::*;
pub use self::bytearrayobject::*;
pub use self::bytesobject::*;
pub use self::cellobject::*;
#[cfg(not(PyPy))]
pub use self::ceval::*;
pub use self::code::*;
Expand Down
Loading