- Got rid of newmodule.c
[python/dscho.git] / Doc / ext / noddy.c
blob51d801fcd19bb0c1d96a5c8f5b95f10cc799af3f
1 #include <Python.h>
3 staticforward PyTypeObject noddy_NoddyType;
5 typedef struct {
6 PyObject_HEAD
7 /* Type-specific fields go here. */
8 } noddy_NoddyObject;
10 static PyObject*
11 noddy_new_noddy(PyObject* self, PyObject* args)
13 noddy_NoddyObject* noddy;
15 noddy = PyObject_New(noddy_NoddyObject, &noddy_NoddyType);
17 /* Initialize type-specific fields here. */
19 return (PyObject*)noddy;
22 static void
23 noddy_noddy_dealloc(PyObject* self)
25 /* Free any external resources here;
26 * if the instance owns references to any Python
27 * objects, call Py_DECREF() on them here.
29 PyObject_Del(self);
32 statichere PyTypeObject noddy_NoddyType = {
33 PyObject_HEAD_INIT(NULL)
35 "Noddy",
36 sizeof(noddy_NoddyObject),
38 noddy_noddy_dealloc, /*tp_dealloc*/
39 0, /*tp_print*/
40 0, /*tp_getattr*/
41 0, /*tp_setattr*/
42 0, /*tp_compare*/
43 0, /*tp_repr*/
44 0, /*tp_as_number*/
45 0, /*tp_as_sequence*/
46 0, /*tp_as_mapping*/
47 0, /*tp_hash */
50 static PyMethodDef noddy_methods[] = {
51 {"new_noddy", noddy_new_noddy, METH_NOARGS,
52 "Create a new Noddy object."},
54 {NULL} /* Sentinel */
57 DL_EXPORT(void)
58 initnoddy(void)
60 noddy_NoddyType.ob_type = &PyType_Type;
61 if (PyType_Ready(&noddy_NoddyType))
62 return;
64 Py_InitModule3("noddy", noddy_methods
65 "Example module that creates an extension type.");