Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
allendowney
GitHub Repository: allendowney/cpython
Path: blob/main/Include/boolobject.h
12 views
1
/* Boolean object interface */
2
3
#ifndef Py_BOOLOBJECT_H
4
#define Py_BOOLOBJECT_H
5
#ifdef __cplusplus
6
extern "C" {
7
#endif
8
9
10
PyAPI_DATA(PyTypeObject) PyBool_Type;
11
12
#define PyBool_Check(x) Py_IS_TYPE((x), &PyBool_Type)
13
14
/* Py_False and Py_True are the only two bools in existence. */
15
16
/* Don't use these directly */
17
PyAPI_DATA(PyLongObject) _Py_FalseStruct;
18
PyAPI_DATA(PyLongObject) _Py_TrueStruct;
19
20
/* Use these macros */
21
#define Py_False _PyObject_CAST(&_Py_FalseStruct)
22
#define Py_True _PyObject_CAST(&_Py_TrueStruct)
23
24
// Test if an object is the True singleton, the same as "x is True" in Python.
25
PyAPI_FUNC(int) Py_IsTrue(PyObject *x);
26
#define Py_IsTrue(x) Py_Is((x), Py_True)
27
28
// Test if an object is the False singleton, the same as "x is False" in Python.
29
PyAPI_FUNC(int) Py_IsFalse(PyObject *x);
30
#define Py_IsFalse(x) Py_Is((x), Py_False)
31
32
/* Macros for returning Py_True or Py_False, respectively */
33
#define Py_RETURN_TRUE return Py_True
34
#define Py_RETURN_FALSE return Py_False
35
36
/* Function to return a bool from a C long */
37
PyAPI_FUNC(PyObject *) PyBool_FromLong(long);
38
39
#ifdef __cplusplus
40
}
41
#endif
42
#endif /* !Py_BOOLOBJECT_H */
43
44