blob: 74e854f706bcc83a32b95861199c5fe3025777da [file] [log] [blame]
Guido van Rossum5f820362002-04-03 23:01:45 +00001/* Boolean object interface */
2
Mark Hammond303d05d2002-04-06 03:58:41 +00003#ifndef Py_BOOLOBJECT_H
4#define Py_BOOLOBJECT_H
5#ifdef __cplusplus
6extern "C" {
7#endif
8
9
Guido van Rossum5f820362002-04-03 23:01:45 +000010typedef PyIntObject PyBoolObject;
11
Mark Hammond91a681d2002-08-12 07:21:58 +000012PyAPI_DATA(PyTypeObject) PyBool_Type;
Guido van Rossum5f820362002-04-03 23:01:45 +000013
Christian Heimese93237d2007-12-19 02:37:44 +000014#define PyBool_Check(x) (Py_TYPE(x) == &PyBool_Type)
Guido van Rossum5f820362002-04-03 23:01:45 +000015
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 */
Mark Hammond91a681d2002-08-12 07:21:58 +000020PyAPI_DATA(PyIntObject) _Py_ZeroStruct, _Py_TrueStruct;
Guido van Rossum5f820362002-04-03 23:01:45 +000021
22/* Use these macros */
23#define Py_False ((PyObject *) &_Py_ZeroStruct)
24#define Py_True ((PyObject *) &_Py_TrueStruct)
25
Brett Cannond05235e2003-10-19 21:19:40 +000026/* Macros for returning Py_True or Py_False, respectively */
Tim Peters5980ff22004-07-22 01:46:43 +000027#define Py_RETURN_TRUE return Py_INCREF(Py_True), Py_True
28#define Py_RETURN_FALSE return Py_INCREF(Py_False), Py_False
Brett Cannond05235e2003-10-19 21:19:40 +000029
Guido van Rossum5f820362002-04-03 23:01:45 +000030/* Function to return a bool from a C long */
Mark Hammond91a681d2002-08-12 07:21:58 +000031PyAPI_FUNC(PyObject *) PyBool_FromLong(long);
Mark Hammond303d05d2002-04-06 03:58:41 +000032
33#ifdef __cplusplus
34}
35#endif
36#endif /* !Py_BOOLOBJECT_H */