boolobject.h 948 B

123456789101112131415161718192021222324252627282930313233343536
  1. /* Boolean object interface */
  2. #ifndef Py_BOOLOBJECT_H
  3. #define Py_BOOLOBJECT_H
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. typedef PyIntObject PyBoolObject;
  8. PyAPI_DATA(PyTypeObject) PyBool_Type;
  9. #define PyBool_Check(x) (Py_TYPE(x) == &PyBool_Type)
  10. /* Py_False and Py_True are the only two bools in existence.
  11. Don't forget to apply Py_INCREF() when returning either!!! */
  12. /* Don't use these directly */
  13. PyAPI_DATA(PyIntObject) _Py_ZeroStruct, _Py_TrueStruct;
  14. /* Use these macros */
  15. #define Py_False ((PyObject *) &_Py_ZeroStruct)
  16. #define Py_True ((PyObject *) &_Py_TrueStruct)
  17. /* Macros for returning Py_True or Py_False, respectively */
  18. #define Py_RETURN_TRUE return Py_INCREF(Py_True), Py_True
  19. #define Py_RETURN_FALSE return Py_INCREF(Py_False), Py_False
  20. /* Function to return a bool from a C long */
  21. PyAPI_FUNC(PyObject *) PyBool_FromLong(long);
  22. #ifdef __cplusplus
  23. }
  24. #endif
  25. #endif /* !Py_BOOLOBJECT_H */