Back to index

python3.2  3.2.2
Functions | Variables
boolobject.c File Reference
#include "Python.h"
#include "longintrepr.h"

Go to the source code of this file.

Functions

static PyObjectbool_repr (PyObject *self)
PyObjectPyBool_FromLong (long ok)
static PyObjectbool_new (PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObjectbool_and (PyObject *a, PyObject *b)
static PyObjectbool_or (PyObject *a, PyObject *b)
static PyObjectbool_xor (PyObject *a, PyObject *b)
 PyDoc_STRVAR (bool_doc,"bool(x) -> bool\n\ \n\ Returns True when the argument x is true, False otherwise.\n\ The builtins True and False are the only two instances of the class bool.\n\ The class bool is a subclass of the class int, and cannot be subclassed.")

Variables

static PyObjectfalse_str = NULL
static PyObjecttrue_str = NULL
static PyNumberMethods bool_as_number
PyTypeObject PyBool_Type

Function Documentation

static PyObject* bool_and ( PyObject a,
PyObject b 
) [static]

Definition at line 60 of file boolobject.c.

{
    if (!PyBool_Check(a) || !PyBool_Check(b))
        return PyLong_Type.tp_as_number->nb_and(a, b);
    return PyBool_FromLong((a == Py_True) & (b == Py_True));
}

Here is the call graph for this function:

static PyObject* bool_new ( PyTypeObject type,
PyObject args,
PyObject kwds 
) [static]

Definition at line 43 of file boolobject.c.

{
    static char *kwlist[] = {"x", 0};
    PyObject *x = Py_False;
    long ok;

    if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O:bool", kwlist, &x))
        return NULL;
    ok = PyObject_IsTrue(x);
    if (ok < 0)
        return NULL;
    return PyBool_FromLong(ok);
}

Here is the call graph for this function:

static PyObject* bool_or ( PyObject a,
PyObject b 
) [static]

Definition at line 68 of file boolobject.c.

{
    if (!PyBool_Check(a) || !PyBool_Check(b))
        return PyLong_Type.tp_as_number->nb_or(a, b);
    return PyBool_FromLong((a == Py_True) | (b == Py_True));
}

Here is the call graph for this function:

static PyObject* bool_repr ( PyObject self) [static]

Definition at line 12 of file boolobject.c.

{
    PyObject *s;

    if (self == Py_True)
        s = true_str ? true_str :
            (true_str = PyUnicode_InternFromString("True"));
    else
        s = false_str ? false_str :
            (false_str = PyUnicode_InternFromString("False"));
    Py_XINCREF(s);
    return s;
}

Here is the call graph for this function:

static PyObject* bool_xor ( PyObject a,
PyObject b 
) [static]

Definition at line 76 of file boolobject.c.

{
    if (!PyBool_Check(a) || !PyBool_Check(b))
        return PyLong_Type.tp_as_number->nb_xor(a, b);
    return PyBool_FromLong((a == Py_True) ^ (b == Py_True));
}

Here is the call graph for this function:

Definition at line 28 of file boolobject.c.

{
    PyObject *result;

    if (ok)
        result = Py_True;
    else
        result = Py_False;
    Py_INCREF(result);
    return result;
}
PyDoc_STRVAR ( bool_doc  ,
"bool(x) -> bool\n\\n\Returns True when the argument x is  true,
False otherwise.\n\The builtins True and False are the only two instances of the class bool.\n\The class bool is a subclass of the class  int,
and cannot be subclassed."   
)

Variable Documentation

Definition at line 94 of file boolobject.c.

PyObject* false_str = NULL [static]

Definition at line 8 of file boolobject.c.

Definition at line 133 of file boolobject.c.

PyObject* true_str = NULL [static]

Definition at line 9 of file boolobject.c.