blob: d0842e08c305c7f1040147e02d5dee28f35d6752 [file] [log] [blame]
Fred Drake2ab0a102002-03-28 23:32:53 +00001#include <Python.h>
2
3staticforward PyTypeObject noddy_NoddyType;
4
5typedef struct {
6 PyObject_HEAD
7} noddy_NoddyObject;
8
9static PyObject*
10noddy_new_noddy(PyObject* self, PyObject* args)
11{
12 noddy_NoddyObject* noddy;
13
14 if (!PyArg_ParseTuple(args,":new_noddy"))
15 return NULL;
16
17 noddy = PyObject_New(noddy_NoddyObject, &noddy_NoddyType);
18
19 return (PyObject*)noddy;
20}
21
22static void
23noddy_noddy_dealloc(PyObject* self)
24{
25 PyObject_Del(self);
26}
27
28static PyTypeObject noddy_NoddyType = {
29 PyObject_HEAD_INIT(NULL)
30 0,
31 "Noddy",
32 sizeof(noddy_NoddyObject),
33 0,
34 noddy_noddy_dealloc, /*tp_dealloc*/
35 0, /*tp_print*/
36 0, /*tp_getattr*/
37 0, /*tp_setattr*/
38 0, /*tp_compare*/
39 0, /*tp_repr*/
40 0, /*tp_as_number*/
41 0, /*tp_as_sequence*/
42 0, /*tp_as_mapping*/
43 0, /*tp_hash */
44};
45
46static PyMethodDef noddy_methods[] = {
47 {"new_noddy", noddy_new_noddy, METH_VARARGS,
48 "Create a new Noddy object."},
49 {NULL, NULL, 0, NULL}
50};
51
52DL_EXPORT(void)
53initnoddy(void)
54{
55 noddy_NoddyType.ob_type = &PyType_Type;
56
57 Py_InitModule("noddy", noddy_methods);
58}