Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-11-19 09:50:53

0001 /* Boolean object interface */
0002 
0003 #ifndef Py_BOOLOBJECT_H
0004 #define Py_BOOLOBJECT_H
0005 #ifdef __cplusplus
0006 extern "C" {
0007 #endif
0008 
0009 
0010 // PyBool_Type is declared by object.h
0011 
0012 #define PyBool_Check(x) Py_IS_TYPE((x), &PyBool_Type)
0013 
0014 /* Py_False and Py_True are the only two bools in existence. */
0015 
0016 /* Don't use these directly */
0017 PyAPI_DATA(PyLongObject) _Py_FalseStruct;
0018 PyAPI_DATA(PyLongObject) _Py_TrueStruct;
0019 
0020 /* Use these macros */
0021 #if defined(Py_LIMITED_API) && Py_LIMITED_API+0 >= 0x030D0000
0022 #  define Py_False Py_GetConstantBorrowed(Py_CONSTANT_FALSE)
0023 #  define Py_True Py_GetConstantBorrowed(Py_CONSTANT_TRUE)
0024 #else
0025 #  define Py_False _PyObject_CAST(&_Py_FalseStruct)
0026 #  define Py_True _PyObject_CAST(&_Py_TrueStruct)
0027 #endif
0028 
0029 // Test if an object is the True singleton, the same as "x is True" in Python.
0030 PyAPI_FUNC(int) Py_IsTrue(PyObject *x);
0031 #define Py_IsTrue(x) Py_Is((x), Py_True)
0032 
0033 // Test if an object is the False singleton, the same as "x is False" in Python.
0034 PyAPI_FUNC(int) Py_IsFalse(PyObject *x);
0035 #define Py_IsFalse(x) Py_Is((x), Py_False)
0036 
0037 /* Macros for returning Py_True or Py_False, respectively.
0038  * Only treat Py_True and Py_False as immortal in the limited C API 3.12
0039  * and newer. */
0040 #if defined(Py_LIMITED_API) && Py_LIMITED_API+0 < 0x030c0000
0041 #  define Py_RETURN_TRUE return Py_NewRef(Py_True)
0042 #  define Py_RETURN_FALSE return Py_NewRef(Py_False)
0043 #else
0044 #  define Py_RETURN_TRUE return Py_True
0045 #  define Py_RETURN_FALSE return Py_False
0046 #endif
0047 
0048 /* Function to return a bool from a C long */
0049 PyAPI_FUNC(PyObject *) PyBool_FromLong(long);
0050 
0051 #ifdef __cplusplus
0052 }
0053 #endif
0054 #endif /* !Py_BOOLOBJECT_H */