Back to index

python3.2  3.2.2
Classes | Functions | Variables
shoddy.c File Reference
#include <Python.h>

Go to the source code of this file.

Classes

struct  Shoddy

Functions

static PyObjectShoddy_increment (Shoddy *self, PyObject *unused)
static int Shoddy_init (Shoddy *self, PyObject *args, PyObject *kwds)
PyMODINIT_FUNC PyInit_shoddy (void)

Variables

static PyMethodDef Shoddy_methods []
static PyTypeObject ShoddyType
static PyModuleDef shoddymodule

Class Documentation

struct Shoddy

Definition at line 3 of file shoddy.c.

Collaboration diagram for Shoddy:
Class Members
PyListObject list
int state

Function Documentation

Definition at line 84 of file shoddy.c.

{
    PyObject *m;

    ShoddyType.tp_base = &PyList_Type;
    if (PyType_Ready(&ShoddyType) < 0)
        return NULL;

    m = PyModule_Create(&shoddymodule);
    if (m == NULL)
        return NULL;

    Py_INCREF(&ShoddyType);
    PyModule_AddObject(m, "Shoddy", (PyObject *) &ShoddyType);
    return m;
}

Here is the call graph for this function:

static PyObject* Shoddy_increment ( Shoddy self,
PyObject unused 
) [static]

Definition at line 10 of file shoddy.c.

{
    self->state++;
    return PyLong_FromLong(self->state);
}

Here is the call graph for this function:

static int Shoddy_init ( Shoddy self,
PyObject args,
PyObject kwds 
) [static]

Definition at line 24 of file shoddy.c.

{
    if (PyList_Type.tp_init((PyObject *)self, args, kwds) < 0)
        return -1;
    self->state = 0;
    return 0;
}

Variable Documentation

Initial value:
 {
    {"increment", (PyCFunction)Shoddy_increment, METH_NOARGS,
     PyDoc_STR("increment state counter")},
    {NULL,    NULL},
}

Definition at line 17 of file shoddy.c.

Initial value:
 {
    PyModuleDef_HEAD_INIT,
    "shoddy",
    "Shoddy module",
    -1,
    NULL, NULL, NULL, NULL, NULL
}

Definition at line 75 of file shoddy.c.

Definition at line 33 of file shoddy.c.