Back to index

python3.2  3.2.2
Defines | Functions | Variables
cellobject.c File Reference
#include "Python.h"

Go to the source code of this file.

Defines

#define TEST_COND(cond)   ((cond) ? Py_True : Py_False)

Functions

PyObjectPyCell_New (PyObject *obj)
PyObjectPyCell_Get (PyObject *op)
int PyCell_Set (PyObject *op, PyObject *obj)
static void cell_dealloc (PyCellObject *op)
static PyObjectcell_richcompare (PyObject *a, PyObject *b, int op)
static PyObjectcell_repr (PyCellObject *op)
static int cell_traverse (PyCellObject *op, visitproc visit, void *arg)
static int cell_clear (PyCellObject *op)
static PyObjectcell_get_contents (PyCellObject *op, void *closure)

Variables

static PyGetSetDef cell_getsetlist []
PyTypeObject PyCell_Type

Define Documentation

#define TEST_COND (   cond)    ((cond) ? Py_True : Py_False)

Definition at line 54 of file cellobject.c.


Function Documentation

static int cell_clear ( PyCellObject op) [static]

Definition at line 125 of file cellobject.c.

{
    Py_CLEAR(op->ob_ref);
    return 0;
}
static void cell_dealloc ( PyCellObject op) [static]

Definition at line 47 of file cellobject.c.

Here is the call graph for this function:

static PyObject* cell_get_contents ( PyCellObject op,
void closure 
) [static]

Definition at line 132 of file cellobject.c.

{
    if (op->ob_ref == NULL)
    {
        PyErr_SetString(PyExc_ValueError, "Cell is empty");
        return NULL;
    }
    Py_INCREF(op->ob_ref);
    return op->ob_ref;
}

Here is the call graph for this function:

static PyObject* cell_repr ( PyCellObject op) [static]

Definition at line 107 of file cellobject.c.

{
    if (op->ob_ref == NULL)
        return PyUnicode_FromFormat("<cell at %p: empty>", op);

    return PyUnicode_FromFormat("<cell at %p: %.80s object at %p>",
                               op, op->ob_ref->ob_type->tp_name,
                               op->ob_ref);
}
static PyObject* cell_richcompare ( PyObject a,
PyObject b,
int  op 
) [static]

Definition at line 57 of file cellobject.c.

{
    int result;
    PyObject *v;

    /* neither argument should be NULL, unless something's gone wrong */
    assert(a != NULL && b != NULL);

    /* both arguments should be instances of PyCellObject */
    if (!PyCell_Check(a) || !PyCell_Check(b)) {
        v = Py_NotImplemented;
        Py_INCREF(v);
        return v;
    }

    /* compare cells by contents; empty cells come before anything else */
    a = ((PyCellObject *)a)->ob_ref;
    b = ((PyCellObject *)b)->ob_ref;
    if (a != NULL && b != NULL)
        return PyObject_RichCompare(a, b, op);

    result = (b == NULL) - (a == NULL);
    switch (op) {
    case Py_EQ:
        v = TEST_COND(result == 0);
        break;
    case Py_NE:
        v = TEST_COND(result != 0);
        break;
    case Py_LE:
        v = TEST_COND(result <= 0);
        break;
    case Py_GE:
        v = TEST_COND(result >= 0);
        break;
    case Py_LT:
        v = TEST_COND(result < 0);
        break;
    case Py_GT:
        v = TEST_COND(result > 0);
        break;
    default:
        PyErr_BadArgument();
        return NULL;
    }
    Py_INCREF(v);
    return v;
}

Here is the call graph for this function:

static int cell_traverse ( PyCellObject op,
visitproc  visit,
void arg 
) [static]

Definition at line 118 of file cellobject.c.

{
    Py_VISIT(op->ob_ref);
    return 0;
}

Definition at line 21 of file cellobject.c.

{
    if (!PyCell_Check(op)) {
        PyErr_BadInternalCall();
        return NULL;
    }
    Py_XINCREF(((PyCellObject*)op)->ob_ref);
    return PyCell_GET(op);
}

Here is the caller graph for this function:

Definition at line 6 of file cellobject.c.

{
    PyCellObject *op;

    op = (PyCellObject *)PyObject_GC_New(PyCellObject, &PyCell_Type);
    if (op == NULL)
        return NULL;
    op->ob_ref = obj;
    Py_XINCREF(obj);

    _PyObject_GC_TRACK(op);
    return (PyObject *)op;
}

Here is the caller graph for this function:

int PyCell_Set ( PyObject op,
PyObject obj 
)

Definition at line 32 of file cellobject.c.

{
    PyObject* oldobj;
    if (!PyCell_Check(op)) {
        PyErr_BadInternalCall();
        return -1;
    }
    oldobj = PyCell_GET(op);
    Py_XINCREF(obj);
    PyCell_SET(op, obj);
    Py_XDECREF(oldobj);
    return 0;
}

Here is the caller graph for this function:


Variable Documentation

Initial value:
 {
    {"cell_contents", (getter)cell_get_contents, NULL},
    {NULL} 
}

Definition at line 143 of file cellobject.c.

Definition at line 148 of file cellobject.c.