Remove cfg addr_of made unnecessary by MSRV bump.

This commit is contained in:
Adam Reichold 2023-06-05 09:51:50 +02:00
parent eb04f54683
commit 6f987263c1
29 changed files with 90 additions and 78 deletions

View file

@ -142,11 +142,6 @@ pub fn print_feature_cfgs() {
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");
}
// Enable use of const initializer for thread_local! on Rust 1.59 and greater
if rustc_minor_version >= 59 {
println!("cargo:rustc-cfg=thread_local_const_init");

View file

@ -1,6 +1,7 @@
use crate::longobject::PyLongObject;
use crate::object::*;
use std::os::raw::{c_int, c_long};
use std::ptr::addr_of_mut;
#[cfg_attr(windows, link(name = "pythonXY"))]
extern "C" {
@ -10,7 +11,7 @@ extern "C" {
#[inline]
pub unsafe fn PyBool_Check(op: *mut PyObject) -> c_int {
(Py_TYPE(op) == addr_of_mut_shim!(PyBool_Type)) as c_int
(Py_TYPE(op) == addr_of_mut!(PyBool_Type)) as c_int
}
#[cfg_attr(windows, link(name = "pythonXY"))]
@ -23,12 +24,12 @@ extern "C" {
#[inline]
pub unsafe fn Py_False() -> *mut PyObject {
addr_of_mut_shim!(_Py_FalseStruct) as *mut PyLongObject as *mut PyObject
addr_of_mut!(_Py_FalseStruct) as *mut PyLongObject as *mut PyObject
}
#[inline]
pub unsafe fn Py_True() -> *mut PyObject {
addr_of_mut_shim!(_Py_TrueStruct) as *mut PyLongObject as *mut PyObject
addr_of_mut!(_Py_TrueStruct) as *mut PyLongObject as *mut PyObject
}
#[inline]

View file

@ -1,6 +1,7 @@
use crate::object::*;
use crate::pyport::Py_ssize_t;
use std::os::raw::{c_char, c_int};
use std::ptr::addr_of_mut;
#[cfg(not(any(PyPy, Py_LIMITED_API)))]
#[repr(C)]
@ -29,12 +30,12 @@ extern "C" {
#[inline]
pub unsafe fn PyByteArray_Check(op: *mut PyObject) -> c_int {
PyObject_TypeCheck(op, addr_of_mut_shim!(PyByteArray_Type))
PyObject_TypeCheck(op, addr_of_mut!(PyByteArray_Type))
}
#[inline]
pub unsafe fn PyByteArray_CheckExact(op: *mut PyObject) -> c_int {
(Py_TYPE(op) == addr_of_mut_shim!(PyByteArray_Type)) as c_int
(Py_TYPE(op) == addr_of_mut!(PyByteArray_Type)) as c_int
}
extern "C" {

View file

@ -1,6 +1,7 @@
use crate::object::*;
use crate::pyport::Py_ssize_t;
use std::os::raw::{c_char, c_int};
use std::ptr::addr_of_mut;
#[cfg_attr(windows, link(name = "pythonXY"))]
extern "C" {
@ -16,7 +17,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) == addr_of_mut_shim!(PyBytes_Type)) as c_int
(Py_TYPE(op) == addr_of_mut!(PyBytes_Type)) as c_int
}
extern "C" {

View file

@ -1,5 +1,6 @@
use crate::object::*;
use std::os::raw::{c_double, c_int};
use std::ptr::addr_of_mut;
#[repr(C)]
#[derive(Copy, Clone)]
@ -40,12 +41,12 @@ extern "C" {
#[inline]
pub unsafe fn PyComplex_Check(op: *mut PyObject) -> c_int {
PyObject_TypeCheck(op, addr_of_mut_shim!(PyComplex_Type))
PyObject_TypeCheck(op, addr_of_mut!(PyComplex_Type))
}
#[inline]
pub unsafe fn PyComplex_CheckExact(op: *mut PyObject) -> c_int {
(Py_TYPE(op) == addr_of_mut_shim!(PyComplex_Type)) as c_int
(Py_TYPE(op) == addr_of_mut!(PyComplex_Type)) as c_int
}
extern "C" {

View file

@ -1,5 +1,6 @@
use crate::object::{PyObject, PyTypeObject, Py_TYPE};
use std::os::raw::{c_char, c_int};
use std::ptr::addr_of_mut;
extern "C" {
pub static mut PyContext_Type: PyTypeObject;
@ -12,17 +13,17 @@ extern "C" {
#[inline]
pub unsafe fn PyContext_CheckExact(op: *mut PyObject) -> c_int {
(Py_TYPE(op) == addr_of_mut_shim!(PyContext_Type)) as c_int
(Py_TYPE(op) == addr_of_mut!(PyContext_Type)) as c_int
}
#[inline]
pub unsafe fn PyContextVar_CheckExact(op: *mut PyObject) -> c_int {
(Py_TYPE(op) == addr_of_mut_shim!(PyContextVar_Type)) as c_int
(Py_TYPE(op) == addr_of_mut!(PyContextVar_Type)) as c_int
}
#[inline]
pub unsafe fn PyContextToken_CheckExact(op: *mut PyObject) -> c_int {
(Py_TYPE(op) == addr_of_mut_shim!(PyContextToken_Type)) as c_int
(Py_TYPE(op) == addr_of_mut!(PyContextToken_Type)) as c_int
}
extern "C" {

View file

@ -3,6 +3,8 @@ use crate::pyport::Py_ssize_t;
#[allow(unused_imports)]
use std::os::raw::{c_char, c_int, c_uchar, c_void};
#[cfg(not(PyPy))]
use std::ptr::addr_of_mut;
// skipped _Py_CODEUNIT
// skipped _Py_OPCODE
@ -159,7 +161,7 @@ extern "C" {
#[inline]
#[cfg(not(PyPy))]
pub unsafe fn PyCode_Check(op: *mut PyObject) -> c_int {
(Py_TYPE(op) == addr_of_mut_shim!(PyCode_Type)) as c_int
(Py_TYPE(op) == addr_of_mut!(PyCode_Type)) as c_int
}
#[inline]

View file

@ -4,6 +4,7 @@ use crate::pystate::PyThreadState;
#[cfg(not(any(PyPy, Py_3_11)))]
use std::os::raw::c_char;
use std::os::raw::c_int;
use std::ptr::addr_of_mut;
#[cfg(not(any(PyPy, Py_3_11)))]
pub type PyFrameState = c_char;
@ -64,7 +65,7 @@ extern "C" {
#[inline]
pub unsafe fn PyFrame_Check(op: *mut PyObject) -> c_int {
(Py_TYPE(op) == addr_of_mut_shim!(PyFrame_Type)) as c_int
(Py_TYPE(op) == addr_of_mut!(PyFrame_Type)) as c_int
}
extern "C" {

View file

@ -1,4 +1,6 @@
use std::os::raw::c_int;
#[cfg(not(all(PyPy, not(Py_3_8))))]
use std::ptr::addr_of_mut;
use crate::PyObject;
@ -61,7 +63,7 @@ extern "C" {
#[cfg(not(all(PyPy, not(Py_3_8))))]
#[inline]
pub unsafe fn PyFunction_Check(op: *mut PyObject) -> c_int {
(crate::Py_TYPE(op) == addr_of_mut_shim!(PyFunction_Type)) as c_int
(crate::Py_TYPE(op) == addr_of_mut!(PyFunction_Type)) as c_int
}
extern "C" {

View file

@ -5,6 +5,7 @@ use crate::_PyErr_StackItem;
#[cfg(Py_3_11)]
use std::os::raw::c_char;
use std::os::raw::c_int;
use std::ptr::addr_of_mut;
#[cfg(not(PyPy))]
#[repr(C)]
@ -41,12 +42,12 @@ extern "C" {
#[inline]
pub unsafe fn PyGen_Check(op: *mut PyObject) -> c_int {
PyObject_TypeCheck(op, addr_of_mut_shim!(PyGen_Type))
PyObject_TypeCheck(op, addr_of_mut!(PyGen_Type))
}
#[inline]
pub unsafe fn PyGen_CheckExact(op: *mut PyObject) -> c_int {
(Py_TYPE(op) == addr_of_mut_shim!(PyGen_Type)) as c_int
(Py_TYPE(op) == addr_of_mut!(PyGen_Type)) as c_int
}
extern "C" {
@ -71,7 +72,7 @@ extern "C" {
#[inline]
pub unsafe fn PyCoro_CheckExact(op: *mut PyObject) -> c_int {
PyObject_TypeCheck(op, addr_of_mut_shim!(PyCoro_Type))
PyObject_TypeCheck(op, addr_of_mut!(PyCoro_Type))
}
// skipped _PyCoro_GetAwaitableIter
@ -91,7 +92,7 @@ extern "C" {
#[inline]
pub unsafe fn PyAsyncGen_CheckExact(op: *mut PyObject) -> c_int {
PyObject_TypeCheck(op, addr_of_mut_shim!(PyAsyncGen_Type))
PyObject_TypeCheck(op, addr_of_mut!(PyAsyncGen_Type))
}
// skipped _PyAsyncGenValueWrapperNew

View file

@ -1,6 +1,7 @@
use crate::object::*;
use crate::{PyCFunctionObject, PyMethodDefPointer, METH_METHOD, METH_STATIC};
use std::os::raw::c_int;
use std::ptr::addr_of_mut;
pub struct PyCMethodObject {
pub func: PyCFunctionObject,
@ -14,12 +15,12 @@ extern "C" {
#[inline]
pub unsafe fn PyCMethod_CheckExact(op: *mut PyObject) -> c_int {
(Py_TYPE(op) == addr_of_mut_shim!(PyCMethod_Type)) as c_int
(Py_TYPE(op) == addr_of_mut!(PyCMethod_Type)) as c_int
}
#[inline]
pub unsafe fn PyCMethod_Check(op: *mut PyObject) -> c_int {
PyObject_TypeCheck(op, addr_of_mut_shim!(PyCMethod_Type))
PyObject_TypeCheck(op, addr_of_mut!(PyCMethod_Type))
}
#[inline]

View file

@ -1,6 +1,7 @@
use crate::object::*;
use crate::pyport::Py_ssize_t;
use std::os::raw::{c_char, c_int};
use std::ptr::addr_of_mut;
#[cfg_attr(windows, link(name = "pythonXY"))]
extern "C" {
@ -15,7 +16,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) == addr_of_mut_shim!(PyDict_Type)) as c_int
(Py_TYPE(op) == addr_of_mut!(PyDict_Type)) as c_int
}
extern "C" {
@ -76,17 +77,17 @@ extern "C" {
#[inline]
pub unsafe fn PyDictKeys_Check(op: *mut PyObject) -> c_int {
(Py_TYPE(op) == addr_of_mut_shim!(PyDictKeys_Type)) as c_int
(Py_TYPE(op) == addr_of_mut!(PyDictKeys_Type)) as c_int
}
#[inline]
pub unsafe fn PyDictValues_Check(op: *mut PyObject) -> c_int {
(Py_TYPE(op) == addr_of_mut_shim!(PyDictValues_Type)) as c_int
(Py_TYPE(op) == addr_of_mut!(PyDictValues_Type)) as c_int
}
#[inline]
pub unsafe fn PyDictItems_Check(op: *mut PyObject) -> c_int {
(Py_TYPE(op) == addr_of_mut_shim!(PyDictItems_Type)) as c_int
(Py_TYPE(op) == addr_of_mut!(PyDictItems_Type)) as c_int
}
#[inline]

View file

@ -1,5 +1,6 @@
use crate::object::*;
use std::os::raw::{c_double, c_int};
use std::ptr::addr_of_mut;
#[cfg(Py_LIMITED_API)]
// TODO: remove (see https://github.com/PyO3/pyo3/pull/1341#issuecomment-751515985)
@ -20,12 +21,12 @@ extern "C" {
#[inline]
pub unsafe fn PyFloat_Check(op: *mut PyObject) -> c_int {
PyObject_TypeCheck(op, addr_of_mut_shim!(PyFloat_Type))
PyObject_TypeCheck(op, addr_of_mut!(PyFloat_Type))
}
#[inline]
pub unsafe fn PyFloat_CheckExact(op: *mut PyObject) -> c_int {
(Py_TYPE(op) == addr_of_mut_shim!(PyFloat_Type)) as c_int
(Py_TYPE(op) == addr_of_mut!(PyFloat_Type)) as c_int
}
// skipped Py_RETURN_NAN

View file

@ -1,5 +1,6 @@
use crate::object::*;
use std::os::raw::c_int;
use std::ptr::addr_of_mut;
#[cfg_attr(windows, link(name = "pythonXY"))]
extern "C" {
@ -9,7 +10,7 @@ extern "C" {
#[inline]
pub unsafe fn PySeqIter_Check(op: *mut PyObject) -> c_int {
(Py_TYPE(op) == addr_of_mut_shim!(PySeqIter_Type)) as c_int
(Py_TYPE(op) == addr_of_mut!(PySeqIter_Type)) as c_int
}
extern "C" {
@ -19,7 +20,7 @@ extern "C" {
#[inline]
pub unsafe fn PyCallIter_Check(op: *mut PyObject) -> c_int {
(Py_TYPE(op) == addr_of_mut_shim!(PyCallIter_Type)) as c_int
(Py_TYPE(op) == addr_of_mut!(PyCallIter_Type)) as c_int
}
extern "C" {

View file

@ -258,19 +258,6 @@ 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::*;

View file

@ -1,6 +1,7 @@
use crate::object::*;
use crate::pyport::Py_ssize_t;
use std::os::raw::c_int;
use std::ptr::addr_of_mut;
#[cfg_attr(windows, link(name = "pythonXY"))]
extern "C" {
@ -17,7 +18,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) == addr_of_mut_shim!(PyList_Type)) as c_int
(Py_TYPE(op) == addr_of_mut!(PyList_Type)) as c_int
}
extern "C" {

View file

@ -4,6 +4,7 @@ use libc::size_t;
#[cfg(not(Py_LIMITED_API))]
use std::os::raw::c_uchar;
use std::os::raw::{c_char, c_double, c_int, c_long, c_longlong, c_ulong, c_ulonglong, c_void};
use std::ptr::addr_of_mut;
opaque_struct!(PyLongObject);
@ -20,7 +21,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) == addr_of_mut_shim!(PyLong_Type)) as c_int
(Py_TYPE(op) == addr_of_mut!(PyLong_Type)) as c_int
}
extern "C" {

View file

@ -1,6 +1,7 @@
use crate::object::*;
use crate::pyport::Py_ssize_t;
use std::os::raw::{c_char, c_int};
use std::ptr::addr_of_mut;
#[cfg_attr(windows, link(name = "pythonXY"))]
extern "C" {
@ -13,7 +14,7 @@ extern "C" {
#[inline]
pub unsafe fn PyMemoryView_Check(op: *mut PyObject) -> c_int {
(Py_TYPE(op) == addr_of_mut_shim!(PyMemoryView_Type)) as c_int
(Py_TYPE(op) == addr_of_mut!(PyMemoryView_Type)) as c_int
}
// skipped non-limited PyMemoryView_GET_BUFFER

View file

@ -24,19 +24,19 @@ extern "C" {
#[cfg(Py_3_9)]
#[inline]
pub unsafe fn PyCFunction_CheckExact(op: *mut PyObject) -> c_int {
(Py_TYPE(op) == addr_of_mut_shim!(PyCFunction_Type)) as c_int
(Py_TYPE(op) == ptr::addr_of_mut!(PyCFunction_Type)) as c_int
}
#[cfg(Py_3_9)]
#[inline]
pub unsafe fn PyCFunction_Check(op: *mut PyObject) -> c_int {
PyObject_TypeCheck(op, addr_of_mut_shim!(PyCFunction_Type))
PyObject_TypeCheck(op, ptr::addr_of_mut!(PyCFunction_Type))
}
#[cfg(not(Py_3_9))]
#[inline]
pub unsafe fn PyCFunction_Check(op: *mut PyObject) -> c_int {
(Py_TYPE(op) == addr_of_mut_shim!(PyCFunction_Type)) as c_int
(Py_TYPE(op) == ptr::addr_of_mut!(PyCFunction_Type)) as c_int
}
pub type PyCFunction =

View file

@ -2,6 +2,7 @@ use crate::methodobject::PyMethodDef;
use crate::object::*;
use crate::pyport::Py_ssize_t;
use std::os::raw::{c_char, c_int, c_void};
use std::ptr::addr_of_mut;
#[cfg_attr(windows, link(name = "pythonXY"))]
extern "C" {
@ -11,12 +12,12 @@ extern "C" {
#[inline]
pub unsafe fn PyModule_Check(op: *mut PyObject) -> c_int {
PyObject_TypeCheck(op, addr_of_mut_shim!(PyModule_Type))
PyObject_TypeCheck(op, addr_of_mut!(PyModule_Type))
}
#[inline]
pub unsafe fn PyModule_CheckExact(op: *mut PyObject) -> c_int {
(Py_TYPE(op) == addr_of_mut_shim!(PyModule_Type)) as c_int
(Py_TYPE(op) == addr_of_mut!(PyModule_Type)) as c_int
}
extern "C" {

View file

@ -488,7 +488,7 @@ extern "C" {
#[inline]
pub unsafe fn Py_None() -> *mut PyObject {
addr_of_mut_shim!(_Py_NoneStruct)
ptr::addr_of_mut!(_Py_NoneStruct)
}
#[inline]
@ -506,7 +506,7 @@ extern "C" {
#[inline]
pub unsafe fn Py_NotImplemented() -> *mut PyObject {
addr_of_mut_shim!(_Py_NotImplementedStruct)
ptr::addr_of_mut!(_Py_NotImplementedStruct)
}
// skipped Py_RETURN_NOTIMPLEMENTED
@ -554,5 +554,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) == addr_of_mut_shim!(PyType_Type)) as c_int
(Py_TYPE(op) == ptr::addr_of_mut!(PyType_Type)) as c_int
}

View file

@ -1,5 +1,6 @@
use crate::object::*;
use std::os::raw::{c_char, c_int, c_void};
use std::ptr::addr_of_mut;
#[cfg_attr(windows, link(name = "pythonXY"))]
extern "C" {
@ -11,7 +12,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) == addr_of_mut_shim!(PyCapsule_Type)) as c_int
(Py_TYPE(ob) == addr_of_mut!(PyCapsule_Type)) as c_int
}
extern "C" {

View file

@ -1,5 +1,6 @@
use crate::object::*;
use std::os::raw::c_int;
use std::ptr::addr_of_mut;
#[cfg_attr(windows, link(name = "pythonXY"))]
extern "C" {
@ -11,5 +12,5 @@ extern "C" {
#[inline]
pub unsafe fn PyRange_Check(op: *mut PyObject) -> c_int {
(Py_TYPE(op) == addr_of_mut_shim!(PyRange_Type)) as c_int
(Py_TYPE(op) == addr_of_mut!(PyRange_Type)) as c_int
}

View file

@ -3,6 +3,7 @@ use crate::object::*;
use crate::pyport::Py_hash_t;
use crate::pyport::Py_ssize_t;
use std::os::raw::c_int;
use std::ptr::addr_of_mut;
pub const PySet_MINSIZE: usize = 8;
@ -93,7 +94,7 @@ extern "C" {
#[inline]
#[cfg(not(PyPy))]
pub unsafe fn PyFrozenSet_CheckExact(ob: *mut PyObject) -> c_int {
(Py_TYPE(ob) == addr_of_mut_shim!(PyFrozenSet_Type)) as c_int
(Py_TYPE(ob) == addr_of_mut!(PyFrozenSet_Type)) as c_int
}
extern "C" {
@ -105,8 +106,8 @@ extern "C" {
#[inline]
#[cfg(not(PyPy))]
pub unsafe fn PyFrozenSet_Check(ob: *mut PyObject) -> 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
(Py_TYPE(ob) == addr_of_mut!(PyFrozenSet_Type)
|| PyType_IsSubtype(Py_TYPE(ob), addr_of_mut!(PyFrozenSet_Type)) != 0) as c_int
}
extern "C" {
@ -118,21 +119,21 @@ extern "C" {
#[inline]
#[cfg(not(PyPy))]
pub unsafe fn PyAnySet_CheckExact(ob: *mut PyObject) -> c_int {
(Py_TYPE(ob) == addr_of_mut_shim!(PySet_Type)
|| Py_TYPE(ob) == addr_of_mut_shim!(PyFrozenSet_Type)) as c_int
(Py_TYPE(ob) == addr_of_mut!(PySet_Type) || Py_TYPE(ob) == addr_of_mut!(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), addr_of_mut_shim!(PySet_Type)) != 0
|| PyType_IsSubtype(Py_TYPE(ob), addr_of_mut_shim!(PyFrozenSet_Type)) != 0) as c_int
|| PyType_IsSubtype(Py_TYPE(ob), addr_of_mut!(PySet_Type)) != 0
|| PyType_IsSubtype(Py_TYPE(ob), addr_of_mut!(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, addr_of_mut_shim!(PySet_Type))
crate::Py_IS_TYPE(op, addr_of_mut!(PySet_Type))
}
extern "C" {
@ -144,6 +145,6 @@ extern "C" {
#[inline]
#[cfg(not(PyPy))]
pub unsafe fn PySet_Check(ob: *mut PyObject) -> 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
(Py_TYPE(ob) == addr_of_mut!(PySet_Type)
|| PyType_IsSubtype(Py_TYPE(ob), addr_of_mut!(PySet_Type)) != 0) as c_int
}

View file

@ -1,6 +1,7 @@
use crate::object::*;
use crate::pyport::Py_ssize_t;
use std::os::raw::c_int;
use std::ptr::addr_of_mut;
#[cfg_attr(windows, link(name = "pythonXY"))]
extern "C" {
@ -10,7 +11,7 @@ extern "C" {
#[inline]
pub unsafe fn Py_Ellipsis() -> *mut PyObject {
addr_of_mut_shim!(_Py_EllipsisObject)
addr_of_mut!(_Py_EllipsisObject)
}
#[cfg(not(Py_LIMITED_API))]
@ -31,7 +32,7 @@ extern "C" {
#[inline]
pub unsafe fn PySlice_Check(op: *mut PyObject) -> c_int {
(Py_TYPE(op) == addr_of_mut_shim!(PySlice_Type)) as c_int
(Py_TYPE(op) == addr_of_mut!(PySlice_Type)) as c_int
}
extern "C" {

View file

@ -1,5 +1,7 @@
use crate::object::*;
use std::os::raw::c_int;
#[cfg(not(PyPy))]
use std::ptr::addr_of_mut;
extern "C" {
#[cfg_attr(PyPy, link_name = "PyPyTraceBack_Here")]
@ -21,5 +23,5 @@ extern "C" {
#[inline]
#[cfg(not(PyPy))]
pub unsafe fn PyTraceBack_Check(op: *mut PyObject) -> c_int {
(Py_TYPE(op) == addr_of_mut_shim!(PyTraceBack_Type)) as c_int
(Py_TYPE(op) == addr_of_mut!(PyTraceBack_Type)) as c_int
}

View file

@ -1,6 +1,7 @@
use crate::object::*;
use crate::pyport::Py_ssize_t;
use std::os::raw::c_int;
use std::ptr::addr_of_mut;
#[cfg_attr(windows, link(name = "pythonXY"))]
extern "C" {
@ -16,7 +17,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) == addr_of_mut_shim!(PyTuple_Type)) as c_int
(Py_TYPE(op) == addr_of_mut!(PyTuple_Type)) as c_int
}
extern "C" {

View file

@ -2,6 +2,8 @@ use crate::object::*;
use crate::pyport::Py_ssize_t;
use libc::wchar_t;
use std::os::raw::{c_char, c_int, c_void};
#[cfg(not(PyPy))]
use std::ptr::addr_of_mut;
#[cfg(not(Py_LIMITED_API))]
pub type Py_UNICODE = wchar_t;
@ -34,7 +36,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) == addr_of_mut_shim!(PyUnicode_Type)) as c_int
(Py_TYPE(op) == addr_of_mut!(PyUnicode_Type)) as c_int
}
pub const Py_UNICODE_REPLACEMENT_CHARACTER: Py_UCS4 = 0xFFFD;

View file

@ -1,5 +1,7 @@
use crate::object::*;
use std::os::raw::c_int;
#[cfg(not(PyPy))]
use std::ptr::addr_of_mut;
#[cfg(all(not(PyPy), Py_LIMITED_API))]
opaque_struct!(PyWeakReference);
@ -29,20 +31,20 @@ extern "C" {
#[inline]
#[cfg(not(PyPy))]
pub unsafe fn PyWeakref_CheckRef(op: *mut PyObject) -> c_int {
PyObject_TypeCheck(op, addr_of_mut_shim!(_PyWeakref_RefType))
PyObject_TypeCheck(op, addr_of_mut!(_PyWeakref_RefType))
}
#[inline]
#[cfg(not(PyPy))]
pub unsafe fn PyWeakref_CheckRefExact(op: *mut PyObject) -> c_int {
(Py_TYPE(op) == addr_of_mut_shim!(_PyWeakref_RefType)) as c_int
(Py_TYPE(op) == addr_of_mut!(_PyWeakref_RefType)) as c_int
}
#[inline]
#[cfg(not(PyPy))]
pub unsafe fn PyWeakref_CheckProxy(op: *mut PyObject) -> c_int {
((Py_TYPE(op) == addr_of_mut_shim!(_PyWeakref_ProxyType))
|| (Py_TYPE(op) == addr_of_mut_shim!(_PyWeakref_CallableProxyType))) as c_int
((Py_TYPE(op) == addr_of_mut!(_PyWeakref_ProxyType))
|| (Py_TYPE(op) == addr_of_mut!(_PyWeakref_CallableProxyType))) as c_int
}
#[inline]