diff options
author | Fred Drake <fdrake@acm.org> | 2002-03-28 23:32:53 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 2002-03-28 23:32:53 (GMT) |
commit | 2ab0a10913aebb663b2729add2a5f30a6cdbd54e (patch) | |
tree | 5933cd3d4cb77866da246dd7ce2a7d29e47f593b /Doc/ext/noddy.c | |
parent | 81b750d467b38fe51ad8e338823338c8123b30e0 (diff) | |
download | cpython-2ab0a10913aebb663b2729add2a5f30a6cdbd54e.zip cpython-2ab0a10913aebb663b2729add2a5f30a6cdbd54e.tar.gz cpython-2ab0a10913aebb663b2729add2a5f30a6cdbd54e.tar.bz2 |
The new files included by \verbatiminput in newtypes.tex.
Diffstat (limited to 'Doc/ext/noddy.c')
-rw-r--r-- | Doc/ext/noddy.c | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/Doc/ext/noddy.c b/Doc/ext/noddy.c new file mode 100644 index 0000000..d0842e0 --- /dev/null +++ b/Doc/ext/noddy.c @@ -0,0 +1,58 @@ +#include <Python.h> + +staticforward PyTypeObject noddy_NoddyType; + +typedef struct { + PyObject_HEAD +} noddy_NoddyObject; + +static PyObject* +noddy_new_noddy(PyObject* self, PyObject* args) +{ + noddy_NoddyObject* noddy; + + if (!PyArg_ParseTuple(args,":new_noddy")) + return NULL; + + noddy = PyObject_New(noddy_NoddyObject, &noddy_NoddyType); + + return (PyObject*)noddy; +} + +static void +noddy_noddy_dealloc(PyObject* self) +{ + PyObject_Del(self); +} + +static PyTypeObject noddy_NoddyType = { + PyObject_HEAD_INIT(NULL) + 0, + "Noddy", + sizeof(noddy_NoddyObject), + 0, + noddy_noddy_dealloc, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare*/ + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash */ +}; + +static PyMethodDef noddy_methods[] = { + {"new_noddy", noddy_new_noddy, METH_VARARGS, + "Create a new Noddy object."}, + {NULL, NULL, 0, NULL} +}; + +DL_EXPORT(void) +initnoddy(void) +{ + noddy_NoddyType.ob_type = &PyType_Type; + + Py_InitModule("noddy", noddy_methods); +} |