boolobject.h 886 B

12345678910111213141516171819202122232425262728293031323334
  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_TYPE(x) == &PyBool_Type)
  9. /* Py_False and Py_True are the only two bools in existence.
  10. Don't forget to apply Py_INCREF() when returning either!!! */
  11. /* Don't use these directly */
  12. PyAPI_DATA(struct _longobject) _Py_FalseStruct, _Py_TrueStruct;
  13. /* Use these macros */
  14. #define Py_False ((PyObject *) &_Py_FalseStruct)
  15. #define Py_True ((PyObject *) &_Py_TrueStruct)
  16. /* Macros for returning Py_True or Py_False, respectively */
  17. #define Py_RETURN_TRUE return Py_INCREF(Py_True), Py_True
  18. #define Py_RETURN_FALSE return Py_INCREF(Py_False), Py_False
  19. /* Function to return a bool from a C long */
  20. PyAPI_FUNC(PyObject *) PyBool_FromLong(long);
  21. #ifdef __cplusplus
  22. }
  23. #endif
  24. #endif /* !Py_BOOLOBJECT_H */