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