| 1 | #[cfg (not(GraalPy))] |
| 2 | use crate::longobject::PyLongObject; |
| 3 | use crate::object::*; |
| 4 | use std::os::raw::{c_int, c_long}; |
| 5 | use std::ptr::addr_of_mut; |
| 6 | |
| 7 | #[inline ] |
| 8 | pub unsafe fn PyBool_Check(op: *mut PyObject) -> c_int { |
| 9 | (Py_TYPE(ob:op) == addr_of_mut!(PyBool_Type)) as c_int |
| 10 | } |
| 11 | |
| 12 | #[cfg_attr (windows, link(name = "pythonXY" ))] |
| 13 | unsafeextern "C" { |
| 14 | #[cfg (not(GraalPy))] |
| 15 | #[cfg_attr (PyPy, link_name = "_PyPy_FalseStruct" )] |
| 16 | unsafestatic mut _Py_FalseStruct: PyLongObject; |
| 17 | #[cfg (not(GraalPy))] |
| 18 | #[cfg_attr (PyPy, link_name = "_PyPy_TrueStruct" )] |
| 19 | unsafestatic mut _Py_TrueStruct: PyLongObject; |
| 20 | |
| 21 | #[cfg (GraalPy)] |
| 22 | static mut _Py_FalseStructReference: *mut PyObject; |
| 23 | #[cfg (GraalPy)] |
| 24 | static mut _Py_TrueStructReference: *mut PyObject; |
| 25 | } |
| 26 | |
| 27 | #[inline ] |
| 28 | pub unsafe fn Py_False() -> *mut PyObject { |
| 29 | #[cfg (not(GraalPy))] |
| 30 | return addr_of_mut!(_Py_FalseStruct) as *mut PyObject; |
| 31 | #[cfg (GraalPy)] |
| 32 | return _Py_FalseStructReference; |
| 33 | } |
| 34 | |
| 35 | #[inline ] |
| 36 | pub unsafe fn Py_True() -> *mut PyObject { |
| 37 | #[cfg (not(GraalPy))] |
| 38 | return addr_of_mut!(_Py_TrueStruct) as *mut PyObject; |
| 39 | #[cfg (GraalPy)] |
| 40 | return _Py_TrueStructReference; |
| 41 | } |
| 42 | |
| 43 | #[inline ] |
| 44 | pub unsafe fn Py_IsTrue(x: *mut PyObject) -> c_int { |
| 45 | Py_Is(x, y:Py_True()) |
| 46 | } |
| 47 | |
| 48 | #[inline ] |
| 49 | pub unsafe fn Py_IsFalse(x: *mut PyObject) -> c_int { |
| 50 | Py_Is(x, y:Py_False()) |
| 51 | } |
| 52 | |
| 53 | // skipped Py_RETURN_TRUE |
| 54 | // skipped Py_RETURN_FALSE |
| 55 | |
| 56 | #[cfg_attr (windows, link(name = "pythonXY" ))] |
| 57 | unsafeextern "C" { |
| 58 | #[cfg_attr (PyPy, link_name = "PyPyBool_FromLong" )] |
| 59 | pub unsafefn PyBool_FromLong(arg1: c_long) -> *mut PyObject; |
| 60 | } |
| 61 | |