Guido van Rossum | 5f82036 | 2002-04-03 23:01:45 +0000 | [diff] [blame] | 1 | /* Boolean object interface */ |
| 2 | |
Mark Hammond | 303d05d | 2002-04-06 03:58:41 +0000 | [diff] [blame] | 3 | #ifndef Py_BOOLOBJECT_H |
| 4 | #define Py_BOOLOBJECT_H |
| 5 | #ifdef __cplusplus |
| 6 | extern "C" { |
| 7 | #endif |
| 8 | |
| 9 | |
Guido van Rossum | 5f82036 | 2002-04-03 23:01:45 +0000 | [diff] [blame] | 10 | typedef PyIntObject PyBoolObject; |
| 11 | |
| 12 | extern DL_IMPORT(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. |
| 17 | Don't forget to apply Py_INCREF() when returning either!!! */ |
| 18 | |
| 19 | /* Don't use these directly */ |
| 20 | extern DL_IMPORT(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 | /* Function to return a bool from a C long */ |
Martin v. Löwis | 76da0c3 | 2002-05-02 20:23:27 +0000 | [diff] [blame] | 27 | extern DL_IMPORT(PyObject *) PyBool_FromLong(long); |
Mark Hammond | 303d05d | 2002-04-06 03:58:41 +0000 | [diff] [blame] | 28 | |
| 29 | #ifdef __cplusplus |
| 30 | } |
| 31 | #endif |
| 32 | #endif /* !Py_BOOLOBJECT_H */ |