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