boolobject.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /* Boolean object interface */
  2. #ifndef Py_BOOLOBJECT_H
  3. #define Py_BOOLOBJECT_H
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. PyAPI_DATA(PyTypeObject) PyBool_Type;
  8. #define PyBool_Check(x) Py_IS_TYPE((x), &PyBool_Type)
  9. /* Py_False and Py_True are the only two bools in existence. */
  10. /* Don't use these directly */
  11. PyAPI_DATA(PyLongObject) _Py_FalseStruct;
  12. PyAPI_DATA(PyLongObject) _Py_TrueStruct;
  13. /* Use these macros */
  14. #define Py_False _PyObject_CAST(&_Py_FalseStruct)
  15. #define Py_True _PyObject_CAST(&_Py_TrueStruct)
  16. // Test if an object is the True singleton, the same as "x is True" in Python.
  17. PyAPI_FUNC(int) Py_IsTrue(PyObject *x);
  18. #define Py_IsTrue(x) Py_Is((x), Py_True)
  19. // Test if an object is the False singleton, the same as "x is False" in Python.
  20. PyAPI_FUNC(int) Py_IsFalse(PyObject *x);
  21. #define Py_IsFalse(x) Py_Is((x), Py_False)
  22. /* Macros for returning Py_True or Py_False, respectively */
  23. #define Py_RETURN_TRUE return Py_True
  24. #define Py_RETURN_FALSE return Py_False
  25. /* Function to return a bool from a C long */
  26. PyAPI_FUNC(PyObject *) PyBool_FromLong(long);
  27. #ifdef __cplusplus
  28. }
  29. #endif
  30. #endif /* !Py_BOOLOBJECT_H */