Use addr_of_mut where possible
This commit is contained in:
parent
e5000e470a
commit
c40bd98825
|
@ -100,9 +100,29 @@ fn configure_pyo3() -> Result<()> {
|
|||
println!("{}", line);
|
||||
}
|
||||
|
||||
let rustc_minor_version = rustc_minor_version().unwrap_or(0);
|
||||
|
||||
// Enable use of std::ptr::addr_of! on Rust 1.51 and greater
|
||||
if rustc_minor_version >= 51 {
|
||||
println!("cargo:rustc-cfg=addr_of");
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn rustc_minor_version() -> Option<u32> {
|
||||
use std::{env, process::Command};
|
||||
|
||||
let rustc = env::var_os("RUSTC")?;
|
||||
let output = Command::new(rustc).arg("--version").output().ok()?;
|
||||
let version = core::str::from_utf8(&output.stdout).ok()?;
|
||||
let mut pieces = version.split('.');
|
||||
if pieces.next() != Some("rustc 1") {
|
||||
return None;
|
||||
}
|
||||
pieces.next()?.parse().ok()
|
||||
}
|
||||
|
||||
fn print_config_and_exit(config: &InterpreterConfig) {
|
||||
println!("\n-- PYO3_PRINT_CONFIG=1 is set, printing configuration and halting compile --");
|
||||
config
|
||||
|
|
|
@ -10,7 +10,7 @@ extern "C" {
|
|||
|
||||
#[inline]
|
||||
pub unsafe fn PyBool_Check(op: *mut PyObject) -> c_int {
|
||||
(Py_TYPE(op) == &mut PyBool_Type) as c_int
|
||||
(Py_TYPE(op) == addr_of_mut_shim!(PyBool_Type)) as c_int
|
||||
}
|
||||
|
||||
#[cfg_attr(windows, link(name = "pythonXY"))]
|
||||
|
@ -23,12 +23,12 @@ extern "C" {
|
|||
|
||||
#[inline]
|
||||
pub unsafe fn Py_False() -> *mut PyObject {
|
||||
&mut _Py_FalseStruct as *mut PyLongObject as *mut PyObject
|
||||
addr_of_mut_shim!(_Py_FalseStruct) as *mut PyLongObject as *mut PyObject
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub unsafe fn Py_True() -> *mut PyObject {
|
||||
&mut _Py_TrueStruct as *mut PyLongObject as *mut PyObject
|
||||
addr_of_mut_shim!(_Py_TrueStruct) as *mut PyLongObject as *mut PyObject
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
|
@ -12,12 +12,12 @@ extern "C" {
|
|||
|
||||
#[inline]
|
||||
pub unsafe fn PyByteArray_Check(op: *mut PyObject) -> c_int {
|
||||
PyObject_TypeCheck(op, &mut PyByteArray_Type)
|
||||
PyObject_TypeCheck(op, addr_of_mut_shim!(PyByteArray_Type))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub unsafe fn PyByteArray_CheckExact(op: *mut PyObject) -> c_int {
|
||||
(Py_TYPE(op) == &mut PyByteArray_Type) as c_int
|
||||
(Py_TYPE(op) == addr_of_mut_shim!(PyByteArray_Type)) as c_int
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
|
|
@ -16,7 +16,7 @@ pub unsafe fn PyBytes_Check(op: *mut PyObject) -> c_int {
|
|||
|
||||
#[inline]
|
||||
pub unsafe fn PyBytes_CheckExact(op: *mut PyObject) -> c_int {
|
||||
(Py_TYPE(op) == &mut PyBytes_Type) as c_int
|
||||
(Py_TYPE(op) == addr_of_mut_shim!(PyBytes_Type)) as c_int
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
|
|
@ -40,12 +40,12 @@ extern "C" {
|
|||
|
||||
#[inline]
|
||||
pub unsafe fn PyComplex_Check(op: *mut PyObject) -> c_int {
|
||||
PyObject_TypeCheck(op, &mut PyComplex_Type)
|
||||
PyObject_TypeCheck(op, addr_of_mut_shim!(PyComplex_Type))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub unsafe fn PyComplex_CheckExact(op: *mut PyObject) -> c_int {
|
||||
(Py_TYPE(op) == &mut PyComplex_Type) as c_int
|
||||
(Py_TYPE(op) == addr_of_mut_shim!(PyComplex_Type)) as c_int
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
|
|
@ -12,17 +12,17 @@ extern "C" {
|
|||
|
||||
#[inline]
|
||||
pub unsafe fn PyContext_CheckExact(op: *mut PyObject) -> c_int {
|
||||
(Py_TYPE(op) == &mut PyContext_Type) as c_int
|
||||
(Py_TYPE(op) == addr_of_mut_shim!(PyContext_Type)) as c_int
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub unsafe fn PyContextVar_CheckExact(op: *mut PyObject) -> c_int {
|
||||
(Py_TYPE(op) == &mut PyContextVar_Type) as c_int
|
||||
(Py_TYPE(op) == addr_of_mut_shim!(PyContextVar_Type)) as c_int
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub unsafe fn PyContextToken_CheckExact(op: *mut PyObject) -> c_int {
|
||||
(Py_TYPE(op) == &mut PyContextToken_Type) as c_int
|
||||
(Py_TYPE(op) == addr_of_mut_shim!(PyContextToken_Type)) as c_int
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
|
|
@ -84,7 +84,7 @@ extern "C" {
|
|||
#[inline]
|
||||
#[cfg(not(PyPy))]
|
||||
pub unsafe fn PyCode_Check(op: *mut PyObject) -> c_int {
|
||||
(Py_TYPE(op) == &mut PyCode_Type) as c_int
|
||||
(Py_TYPE(op) == addr_of_mut_shim!(PyCode_Type)) as c_int
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
|
@ -60,7 +60,7 @@ extern "C" {
|
|||
|
||||
#[inline]
|
||||
pub unsafe fn PyFrame_Check(op: *mut PyObject) -> c_int {
|
||||
(Py_TYPE(op) == &mut PyFrame_Type) as c_int
|
||||
(Py_TYPE(op) == addr_of_mut_shim!(PyFrame_Type)) as c_int
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
|
|
@ -15,7 +15,7 @@ pub unsafe fn PyDict_Check(op: *mut PyObject) -> c_int {
|
|||
|
||||
#[inline]
|
||||
pub unsafe fn PyDict_CheckExact(op: *mut PyObject) -> c_int {
|
||||
(Py_TYPE(op) == &mut PyDict_Type) as c_int
|
||||
(Py_TYPE(op) == addr_of_mut_shim!(PyDict_Type)) as c_int
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
@ -76,17 +76,17 @@ extern "C" {
|
|||
|
||||
#[inline]
|
||||
pub unsafe fn PyDictKeys_Check(op: *mut PyObject) -> c_int {
|
||||
(Py_TYPE(op) == &mut PyDictKeys_Type) as c_int
|
||||
(Py_TYPE(op) == addr_of_mut_shim!(PyDictKeys_Type)) as c_int
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub unsafe fn PyDictValues_Check(op: *mut PyObject) -> c_int {
|
||||
(Py_TYPE(op) == &mut PyDictValues_Type) as c_int
|
||||
(Py_TYPE(op) == addr_of_mut_shim!(PyDictValues_Type)) as c_int
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub unsafe fn PyDictItems_Check(op: *mut PyObject) -> c_int {
|
||||
(Py_TYPE(op) == &mut PyDictItems_Type) as c_int
|
||||
(Py_TYPE(op) == addr_of_mut_shim!(PyDictItems_Type)) as c_int
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
|
@ -20,12 +20,12 @@ extern "C" {
|
|||
|
||||
#[inline]
|
||||
pub unsafe fn PyFloat_Check(op: *mut PyObject) -> c_int {
|
||||
PyObject_TypeCheck(op, &mut PyFloat_Type)
|
||||
PyObject_TypeCheck(op, addr_of_mut_shim!(PyFloat_Type))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub unsafe fn PyFloat_CheckExact(op: *mut PyObject) -> c_int {
|
||||
(Py_TYPE(op) == &mut PyFloat_Type) as c_int
|
||||
(Py_TYPE(op) == addr_of_mut_shim!(PyFloat_Type)) as c_int
|
||||
}
|
||||
|
||||
// skipped Py_RETURN_NAN
|
||||
|
|
|
@ -12,7 +12,7 @@ extern "C" {
|
|||
|
||||
#[inline]
|
||||
pub unsafe fn PyFunction_Check(op: *mut PyObject) -> c_int {
|
||||
(Py_TYPE(op) == &mut PyFunction_Type) as c_int
|
||||
(Py_TYPE(op) == addr_of_mut_shim!(PyFunction_Type)) as c_int
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
|
|
@ -25,12 +25,12 @@ extern "C" {
|
|||
|
||||
#[inline]
|
||||
pub unsafe fn PyGen_Check(op: *mut PyObject) -> c_int {
|
||||
PyObject_TypeCheck(op, &mut PyGen_Type)
|
||||
PyObject_TypeCheck(op, addr_of_mut_shim!(PyGen_Type))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub unsafe fn PyGen_CheckExact(op: *mut PyObject) -> c_int {
|
||||
(Py_TYPE(op) == &mut PyGen_Type) as c_int
|
||||
(Py_TYPE(op) == addr_of_mut_shim!(PyGen_Type)) as c_int
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
@ -55,7 +55,7 @@ extern "C" {
|
|||
|
||||
#[inline]
|
||||
pub unsafe fn PyCoro_CheckExact(op: *mut PyObject) -> c_int {
|
||||
PyObject_TypeCheck(op, &mut PyCoro_Type)
|
||||
PyObject_TypeCheck(op, addr_of_mut_shim!(PyCoro_Type))
|
||||
}
|
||||
|
||||
// skipped _PyCoro_GetAwaitableIter
|
||||
|
@ -75,7 +75,7 @@ extern "C" {
|
|||
|
||||
#[inline]
|
||||
pub unsafe fn PyAsyncGen_CheckExact(op: *mut PyObject) -> c_int {
|
||||
PyObject_TypeCheck(op, &mut PyAsyncGen_Type)
|
||||
PyObject_TypeCheck(op, addr_of_mut_shim!(PyAsyncGen_Type))
|
||||
}
|
||||
|
||||
// skipped _PyAsyncGenValueWrapperNew
|
||||
|
|
|
@ -9,7 +9,7 @@ extern "C" {
|
|||
|
||||
#[inline]
|
||||
pub unsafe fn PySeqIter_Check(op: *mut PyObject) -> c_int {
|
||||
(Py_TYPE(op) == &mut PySeqIter_Type) as c_int
|
||||
(Py_TYPE(op) == addr_of_mut_shim!(PySeqIter_Type)) as c_int
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
@ -19,7 +19,7 @@ extern "C" {
|
|||
|
||||
#[inline]
|
||||
pub unsafe fn PyCallIter_Check(op: *mut PyObject) -> c_int {
|
||||
(Py_TYPE(op) == &mut PyCallIter_Type) as c_int
|
||||
(Py_TYPE(op) == addr_of_mut_shim!(PyCallIter_Type)) as c_int
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
|
|
@ -265,6 +265,19 @@ macro_rules! opaque_struct {
|
|||
};
|
||||
}
|
||||
|
||||
macro_rules! addr_of_mut_shim {
|
||||
($place:expr) => {{
|
||||
#[cfg(addr_of)]
|
||||
{
|
||||
::std::ptr::addr_of_mut!($place)
|
||||
}
|
||||
#[cfg(not(addr_of))]
|
||||
{
|
||||
&mut $place as *mut _
|
||||
}
|
||||
}};
|
||||
}
|
||||
|
||||
pub use self::abstract_::*;
|
||||
pub use self::bltinmodule::*;
|
||||
pub use self::boolobject::*;
|
||||
|
|
|
@ -17,7 +17,7 @@ pub unsafe fn PyList_Check(op: *mut PyObject) -> c_int {
|
|||
|
||||
#[inline]
|
||||
pub unsafe fn PyList_CheckExact(op: *mut PyObject) -> c_int {
|
||||
(Py_TYPE(op) == &mut PyList_Type) as c_int
|
||||
(Py_TYPE(op) == addr_of_mut_shim!(PyList_Type)) as c_int
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
|
|
@ -20,7 +20,7 @@ pub unsafe fn PyLong_Check(op: *mut PyObject) -> c_int {
|
|||
|
||||
#[inline]
|
||||
pub unsafe fn PyLong_CheckExact(op: *mut PyObject) -> c_int {
|
||||
(Py_TYPE(op) == &mut PyLong_Type) as c_int
|
||||
(Py_TYPE(op) == addr_of_mut_shim!(PyLong_Type)) as c_int
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
|
|
@ -12,7 +12,7 @@ extern "C" {
|
|||
|
||||
#[inline]
|
||||
pub unsafe fn PyMemoryView_Check(op: *mut PyObject) -> c_int {
|
||||
(Py_TYPE(op) == &mut PyMemoryView_Type) as c_int
|
||||
(Py_TYPE(op) == addr_of_mut_shim!(PyMemoryView_Type)) as c_int
|
||||
}
|
||||
|
||||
// skipped non-limited PyMemoryView_GET_BUFFER
|
||||
|
|
|
@ -13,19 +13,19 @@ extern "C" {
|
|||
#[cfg(Py_3_9)]
|
||||
#[inline]
|
||||
pub unsafe fn PyCFunction_CheckExact(op: *mut PyObject) -> c_int {
|
||||
(Py_TYPE(op) == &mut PyCFunction_Type) as c_int
|
||||
(Py_TYPE(op) == addr_of_mut_shim!(PyCFunction_Type)) as c_int
|
||||
}
|
||||
|
||||
#[cfg(Py_3_9)]
|
||||
#[inline]
|
||||
pub unsafe fn PyCFunction_Check(op: *mut PyObject) -> c_int {
|
||||
PyObject_TypeCheck(op, &mut PyCFunction_Type)
|
||||
PyObject_TypeCheck(op, addr_of_mut_shim!(PyCFunction_Type))
|
||||
}
|
||||
|
||||
#[cfg(not(Py_3_9))]
|
||||
#[inline]
|
||||
pub unsafe fn PyCFunction_Check(op: *mut PyObject) -> c_int {
|
||||
(Py_TYPE(op) == &mut PyCFunction_Type) as c_int
|
||||
(Py_TYPE(op) == addr_of_mut_shim!(PyCFunction_Type)) as c_int
|
||||
}
|
||||
|
||||
pub type PyCFunction =
|
||||
|
|
|
@ -11,12 +11,12 @@ extern "C" {
|
|||
|
||||
#[inline]
|
||||
pub unsafe fn PyModule_Check(op: *mut PyObject) -> c_int {
|
||||
PyObject_TypeCheck(op, &mut PyModule_Type)
|
||||
PyObject_TypeCheck(op, addr_of_mut_shim!(PyModule_Type))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub unsafe fn PyModule_CheckExact(op: *mut PyObject) -> c_int {
|
||||
(Py_TYPE(op) == &mut PyModule_Type) as c_int
|
||||
(Py_TYPE(op) == addr_of_mut_shim!(PyModule_Type)) as c_int
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
|
|
@ -412,7 +412,7 @@ pub unsafe fn Py_DECREF(op: *mut PyObject) {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
pub unsafe fn Py_CLEAR(op: &mut *mut PyObject) {
|
||||
pub unsafe fn Py_CLEAR(op: *mut *mut PyObject) {
|
||||
let tmp = *op;
|
||||
if !tmp.is_null() {
|
||||
*op = ptr::null_mut();
|
||||
|
@ -470,7 +470,7 @@ extern "C" {
|
|||
|
||||
#[inline]
|
||||
pub unsafe fn Py_None() -> *mut PyObject {
|
||||
&mut _Py_NoneStruct
|
||||
addr_of_mut_shim!(_Py_NoneStruct)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
@ -488,7 +488,7 @@ extern "C" {
|
|||
|
||||
#[inline]
|
||||
pub unsafe fn Py_NotImplemented() -> *mut PyObject {
|
||||
&mut _Py_NotImplementedStruct
|
||||
addr_of_mut_shim!(_Py_NotImplementedStruct)
|
||||
}
|
||||
|
||||
// skipped Py_RETURN_NOTIMPLEMENTED
|
||||
|
@ -536,5 +536,5 @@ pub unsafe fn PyType_Check(op: *mut PyObject) -> c_int {
|
|||
|
||||
#[inline]
|
||||
pub unsafe fn PyType_CheckExact(op: *mut PyObject) -> c_int {
|
||||
(Py_TYPE(op) == &mut PyType_Type) as c_int
|
||||
(Py_TYPE(op) == addr_of_mut_shim!(PyType_Type)) as c_int
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ pub type PyCapsule_Destructor = unsafe extern "C" fn(o: *mut PyObject);
|
|||
|
||||
#[inline]
|
||||
pub unsafe fn PyCapsule_CheckExact(ob: *mut PyObject) -> c_int {
|
||||
(Py_TYPE(ob) == &mut PyCapsule_Type) as c_int
|
||||
(Py_TYPE(ob) == addr_of_mut_shim!(PyCapsule_Type)) as c_int
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
|
|
@ -11,5 +11,5 @@ extern "C" {
|
|||
|
||||
#[inline]
|
||||
pub unsafe fn PyRange_Check(op: *mut PyObject) -> c_int {
|
||||
(Py_TYPE(op) == &mut PyRange_Type) as c_int
|
||||
(Py_TYPE(op) == addr_of_mut_shim!(PyRange_Type)) as c_int
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ extern "C" {
|
|||
#[inline]
|
||||
#[cfg(not(PyPy))]
|
||||
pub unsafe fn PyFrozenSet_CheckExact(ob: *mut PyObject) -> c_int {
|
||||
(Py_TYPE(ob) == &mut PyFrozenSet_Type) as c_int
|
||||
(Py_TYPE(ob) == addr_of_mut_shim!(PyFrozenSet_Type)) as c_int
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
@ -94,8 +94,8 @@ extern "C" {
|
|||
#[inline]
|
||||
#[cfg(not(PyPy))]
|
||||
pub unsafe fn PyFrozenSet_Check(ob: *mut PyObject) -> c_int {
|
||||
(Py_TYPE(ob) == &mut PyFrozenSet_Type
|
||||
|| PyType_IsSubtype(Py_TYPE(ob), &mut PyFrozenSet_Type) != 0) as c_int
|
||||
(Py_TYPE(ob) == addr_of_mut_shim!(PyFrozenSet_Type)
|
||||
|| PyType_IsSubtype(Py_TYPE(ob), addr_of_mut_shim!(PyFrozenSet_Type)) != 0) as c_int
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
@ -107,20 +107,21 @@ extern "C" {
|
|||
#[inline]
|
||||
#[cfg(not(PyPy))]
|
||||
pub unsafe fn PyAnySet_CheckExact(ob: *mut PyObject) -> c_int {
|
||||
(Py_TYPE(ob) == &mut PySet_Type || Py_TYPE(ob) == &mut PyFrozenSet_Type) as c_int
|
||||
(Py_TYPE(ob) == addr_of_mut_shim!(PySet_Type)
|
||||
|| Py_TYPE(ob) == addr_of_mut_shim!(PyFrozenSet_Type)) as c_int
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub unsafe fn PyAnySet_Check(ob: *mut PyObject) -> c_int {
|
||||
(PyAnySet_CheckExact(ob) != 0
|
||||
|| PyType_IsSubtype(Py_TYPE(ob), &mut PySet_Type) != 0
|
||||
|| PyType_IsSubtype(Py_TYPE(ob), &mut PyFrozenSet_Type) != 0) as c_int
|
||||
|| PyType_IsSubtype(Py_TYPE(ob), addr_of_mut_shim!(PySet_Type)) != 0
|
||||
|| PyType_IsSubtype(Py_TYPE(ob), addr_of_mut_shim!(PyFrozenSet_Type)) != 0) as c_int
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[cfg(Py_3_10)]
|
||||
pub unsafe fn PySet_CheckExact(op: *mut PyObject) -> c_int {
|
||||
crate::Py_IS_TYPE(op, &mut PySet_Type)
|
||||
crate::Py_IS_TYPE(op, addr_of_mut_shim!(PySet_Type))
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
@ -132,5 +133,6 @@ extern "C" {
|
|||
#[inline]
|
||||
#[cfg(not(PyPy))]
|
||||
pub unsafe fn PySet_Check(ob: *mut PyObject) -> c_int {
|
||||
(Py_TYPE(ob) == &mut PySet_Type || PyType_IsSubtype(Py_TYPE(ob), &mut PySet_Type) != 0) as c_int
|
||||
(Py_TYPE(ob) == addr_of_mut_shim!(PySet_Type)
|
||||
|| PyType_IsSubtype(Py_TYPE(ob), addr_of_mut_shim!(PySet_Type)) != 0) as c_int
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ extern "C" {
|
|||
|
||||
#[inline]
|
||||
pub unsafe fn Py_Ellipsis() -> *mut PyObject {
|
||||
&mut _Py_EllipsisObject
|
||||
addr_of_mut_shim!(_Py_EllipsisObject)
|
||||
}
|
||||
|
||||
#[cfg(not(Py_LIMITED_API))]
|
||||
|
@ -30,7 +30,7 @@ extern "C" {
|
|||
|
||||
#[inline]
|
||||
pub unsafe fn PySlice_Check(op: *mut PyObject) -> c_int {
|
||||
(Py_TYPE(op) == &mut PySlice_Type) as c_int
|
||||
(Py_TYPE(op) == addr_of_mut_shim!(PySlice_Type)) as c_int
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
|
|
@ -21,5 +21,5 @@ extern "C" {
|
|||
#[inline]
|
||||
#[cfg(not(PyPy))]
|
||||
pub unsafe fn PyTraceBack_Check(op: *mut PyObject) -> c_int {
|
||||
(Py_TYPE(op) == &mut PyTraceBack_Type) as c_int
|
||||
(Py_TYPE(op) == addr_of_mut_shim!(PyTraceBack_Type)) as c_int
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ pub unsafe fn PyTuple_Check(op: *mut PyObject) -> c_int {
|
|||
|
||||
#[inline]
|
||||
pub unsafe fn PyTuple_CheckExact(op: *mut PyObject) -> c_int {
|
||||
(Py_TYPE(op) == &mut PyTuple_Type) as c_int
|
||||
(Py_TYPE(op) == addr_of_mut_shim!(PyTuple_Type)) as c_int
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
|
|
@ -34,7 +34,7 @@ pub unsafe fn PyUnicode_Check(op: *mut PyObject) -> c_int {
|
|||
#[inline]
|
||||
#[cfg(not(PyPy))]
|
||||
pub unsafe fn PyUnicode_CheckExact(op: *mut PyObject) -> c_int {
|
||||
(Py_TYPE(op) == &mut PyUnicode_Type) as c_int
|
||||
(Py_TYPE(op) == addr_of_mut_shim!(PyUnicode_Type)) as c_int
|
||||
}
|
||||
|
||||
pub const Py_UNICODE_REPLACEMENT_CHARACTER: Py_UCS4 = 0xFFFD;
|
||||
|
|
|
@ -24,20 +24,20 @@ extern "C" {
|
|||
#[inline]
|
||||
#[cfg(not(PyPy))]
|
||||
pub unsafe fn PyWeakref_CheckRef(op: *mut PyObject) -> c_int {
|
||||
PyObject_TypeCheck(op, &mut _PyWeakref_RefType)
|
||||
PyObject_TypeCheck(op, addr_of_mut_shim!(_PyWeakref_RefType))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[cfg(not(PyPy))]
|
||||
pub unsafe fn PyWeakref_CheckRefExact(op: *mut PyObject) -> c_int {
|
||||
(Py_TYPE(op) == &mut _PyWeakref_RefType) as c_int
|
||||
(Py_TYPE(op) == addr_of_mut_shim!(_PyWeakref_RefType)) as c_int
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[cfg(not(PyPy))]
|
||||
pub unsafe fn PyWeakref_CheckProxy(op: *mut PyObject) -> c_int {
|
||||
((Py_TYPE(op) == &mut _PyWeakref_ProxyType)
|
||||
|| (Py_TYPE(op) == &mut _PyWeakref_CallableProxyType)) as c_int
|
||||
((Py_TYPE(op) == addr_of_mut_shim!(_PyWeakref_ProxyType))
|
||||
|| (Py_TYPE(op) == addr_of_mut_shim!(_PyWeakref_CallableProxyType))) as c_int
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
Loading…
Reference in New Issue