blob: 7cc2f1fe23937acbca1ac7c2f3e4654395214b1b [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
Mark Hammond91a681d2002-08-12 07:21:58 +000010PyAPI_DATA(PyTypeObject) PyBool_Type;
Guido van Rossum5f820362002-04-03 23:01:45 +000011
Christian Heimes90aa7642007-12-19 02:45:37 +000012#define PyBool_Check(x) (Py_TYPE(x) == &PyBool_Type)
Guido van Rossum5f820362002-04-03 23:01:45 +000013
14/* Py_False and Py_True are the only two bools in existence.
15Don't forget to apply Py_INCREF() when returning either!!! */
16
17/* Don't use these directly */
Guido van Rossumddefaf32007-01-14 03:31:43 +000018PyAPI_DATA(struct _longobject) _Py_FalseStruct, _Py_TrueStruct;
Guido van Rossum5f820362002-04-03 23:01:45 +000019
20/* Use these macros */
Guido van Rossumddefaf32007-01-14 03:31:43 +000021#define Py_False ((PyObject *) &_Py_FalseStruct)
Guido van Rossum5f820362002-04-03 23:01:45 +000022#define Py_True ((PyObject *) &_Py_TrueStruct)
23
Brett Cannond05235e2003-10-19 21:19:40 +000024/* Macros for returning Py_True or Py_False, respectively */
Tim Peters5980ff22004-07-22 01:46:43 +000025#define Py_RETURN_TRUE return Py_INCREF(Py_True), Py_True
26#define Py_RETURN_FALSE return Py_INCREF(Py_False), Py_False
Brett Cannond05235e2003-10-19 21:19:40 +000027
Guido van Rossum5f820362002-04-03 23:01:45 +000028/* Function to return a bool from a C long */
Mark Hammond91a681d2002-08-12 07:21:58 +000029PyAPI_FUNC(PyObject *) PyBool_FromLong(long);
Mark Hammond303d05d2002-04-06 03:58:41 +000030
31#ifdef __cplusplus
32}
33#endif
34#endif /* !Py_BOOLOBJECT_H */