blob: ec2d669dd1e8bf0fb31e30c4535009e277eb1890 [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 */
Fred Drake2ab0a102002-03-28 23:32:53 +000031};
32
33static PyMethodDef noddy_methods[] = {
Fred Drakeee485192002-04-12 16:17:06 +000034 {NULL} /* Sentinel */
Fred Drake2ab0a102002-03-28 23:32:53 +000035};
36
Jim Fulton1f325562003-05-16 13:53:43 +000037#ifndef PyMODINIT_FUNC /* declarations for DLL import/export */
38#define PyMODINIT_FUNC void
39#endif
Mark Hammond543fb352002-07-31 06:17:46 +000040PyMODINIT_FUNC
Fred Drake2ab0a102002-03-28 23:32:53 +000041initnoddy(void)
42{
Jim Fultond2eadc62003-05-12 17:42:56 +000043 PyObject* m;
44
Jim Fulton4b59f912003-06-28 11:53:29 +000045 noddy_NoddyType.tp_new = PyType_GenericNew;
Jim Fultond2eadc62003-05-12 17:42:56 +000046 if (PyType_Ready(&noddy_NoddyType) < 0)
Fred Drakeee485192002-04-12 16:17:06 +000047 return;
Fred Drake2ab0a102002-03-28 23:32:53 +000048
Jim Fultond2eadc62003-05-12 17:42:56 +000049 m = Py_InitModule3("noddy", noddy_methods,
50 "Example module that creates an extension type.");
51
Raymond Hettinger8fb665a2003-05-25 17:59:38 +000052 Py_INCREF(&noddy_NoddyType);
Jim Fultond2eadc62003-05-12 17:42:56 +000053 PyModule_AddObject(m, "Noddy", (PyObject *)&noddy_NoddyType);
Fred Drake2ab0a102002-03-28 23:32:53 +000054}