blob: 632d8e1559851e6670f7c7979050cc7207a6fca5 [file] [log] [blame]
Fred Drake2ab0a102002-03-28 23:32:53 +00001#include <Python.h>
2
Fred Drake2ab0a102002-03-28 23:32:53 +00003typedef struct {
4 PyObject_HEAD
Fred Drakeee485192002-04-12 16:17:06 +00005 /* Type-specific fields go here. */
Fred Drake2ab0a102002-03-28 23:32:53 +00006} noddy_NoddyObject;
7
Fred Drake50ceb682002-07-17 16:42:48 +00008static PyTypeObject noddy_NoddyType = {
Fred Drake2ab0a102002-03-28 23:32:53 +00009 PyObject_HEAD_INIT(NULL)
Jim Fultond2eadc62003-05-12 17:42:56 +000010 0, /*ob_size*/
11 "noddy.Noddy", /*tp_name*/
12 sizeof(noddy_NoddyObject), /*tp_basicsize*/
13 0, /*tp_itemsize*/
14 0, /*tp_dealloc*/
15 0, /*tp_print*/
16 0, /*tp_getattr*/
17 0, /*tp_setattr*/
18 0, /*tp_compare*/
19 0, /*tp_repr*/
20 0, /*tp_as_number*/
21 0, /*tp_as_sequence*/
22 0, /*tp_as_mapping*/
23 0, /*tp_hash */
24 0, /*tp_call*/
25 0, /*tp_str*/
26 0, /*tp_getattro*/
27 0, /*tp_setattro*/
28 0, /*tp_as_buffer*/
29 Py_TPFLAGS_DEFAULT, /*tp_flags*/
30 "Noddy objects", /* tp_doc */
31 0, /* tp_traverse */
32 0, /* tp_clear */
33 0, /* tp_richcompare */
34 0, /* tp_weaklistoffset */
35 0, /* tp_iter */
36 0, /* tp_iternext */
37 0, /* tp_methods */
38 0, /* tp_members */
39 0, /* tp_getset */
40 0, /* tp_base */
41 0, /* tp_dict */
42 0, /* tp_descr_get */
43 0, /* tp_descr_set */
44 0, /* tp_dictoffset */
45 0, /* tp_init */
46 0, /* tp_alloc */
47 PyType_GenericNew, /* tp_new */
Fred Drake2ab0a102002-03-28 23:32:53 +000048};
49
50static PyMethodDef noddy_methods[] = {
Fred Drakeee485192002-04-12 16:17:06 +000051 {NULL} /* Sentinel */
Fred Drake2ab0a102002-03-28 23:32:53 +000052};
53
Jim Fulton1f325562003-05-16 13:53:43 +000054#ifndef PyMODINIT_FUNC /* declarations for DLL import/export */
55#define PyMODINIT_FUNC void
56#endif
Mark Hammond543fb352002-07-31 06:17:46 +000057PyMODINIT_FUNC
Fred Drake2ab0a102002-03-28 23:32:53 +000058initnoddy(void)
59{
Jim Fultond2eadc62003-05-12 17:42:56 +000060 PyObject* m;
61
62 if (PyType_Ready(&noddy_NoddyType) < 0)
Fred Drakeee485192002-04-12 16:17:06 +000063 return;
Fred Drake2ab0a102002-03-28 23:32:53 +000064
Jim Fultond2eadc62003-05-12 17:42:56 +000065 m = Py_InitModule3("noddy", noddy_methods,
66 "Example module that creates an extension type.");
67
Raymond Hettinger8fb665a2003-05-25 17:59:38 +000068 Py_INCREF(&noddy_NoddyType);
Jim Fultond2eadc62003-05-12 17:42:56 +000069 PyModule_AddObject(m, "Noddy", (PyObject *)&noddy_NoddyType);
Fred Drake2ab0a102002-03-28 23:32:53 +000070}