10 Shoddy_increment(Shoddy
*self
, PyObject
*unused
)
13 return PyInt_FromLong(self
->state
);
17 static PyMethodDef Shoddy_methods
[] = {
18 {"increment", (PyCFunction
)Shoddy_increment
, METH_NOARGS
,
19 PyDoc_STR("increment state counter")},
24 Shoddy_init(Shoddy
*self
, PyObject
*args
, PyObject
*kwds
)
26 if (PyList_Type
.tp_init((PyObject
*)self
, args
, kwds
) < 0)
33 static PyTypeObject ShoddyType
= {
34 PyObject_HEAD_INIT(NULL
)
36 "shoddy.Shoddy", /* tp_name */
37 sizeof(Shoddy
), /* tp_basicsize */
46 0, /* tp_as_sequence */
47 0, /* tp_as_mapping */
55 Py_TPFLAGS_BASETYPE
, /* tp_flags */
59 0, /* tp_richcompare */
60 0, /* tp_weaklistoffset */
63 Shoddy_methods
, /* tp_methods */
70 0, /* tp_dictoffset */
71 (initproc
)Shoddy_init
, /* tp_init */
81 ShoddyType
.tp_base
= &PyList_Type
;
82 if (PyType_Ready(&ShoddyType
) < 0)
85 m
= Py_InitModule3("shoddy", NULL
, "Shoddy module");
89 Py_INCREF(&ShoddyType
);
90 PyModule_AddObject(m
, "Shoddy", (PyObject
*) &ShoddyType
);