| 
									
										
										
										
											2002-03-28 23:32:53 +00:00
										 |  |  | #include <Python.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-07-17 16:42:48 +00:00
										 |  |  | static PyTypeObject noddy_NoddyType; | 
					
						
							| 
									
										
										
										
											2002-03-28 23:32:53 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | typedef struct { | 
					
						
							|  |  |  |     PyObject_HEAD | 
					
						
							| 
									
										
										
										
											2002-04-12 16:17:06 +00:00
										 |  |  |     /* Type-specific fields go here. */ | 
					
						
							| 
									
										
										
										
											2002-03-28 23:32:53 +00:00
										 |  |  | } noddy_NoddyObject; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject* | 
					
						
							|  |  |  | noddy_new_noddy(PyObject* self, PyObject* args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     noddy_NoddyObject* noddy; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     noddy = PyObject_New(noddy_NoddyObject, &noddy_NoddyType); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-04-12 16:17:06 +00:00
										 |  |  |     /* Initialize type-specific fields here. */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-03-28 23:32:53 +00:00
										 |  |  |     return (PyObject*)noddy; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void | 
					
						
							|  |  |  | noddy_noddy_dealloc(PyObject* self) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2002-04-12 16:17:06 +00:00
										 |  |  |     /* Free any external resources here;
 | 
					
						
							|  |  |  |      * if the instance owns references to any Python | 
					
						
							|  |  |  |      * objects, call Py_DECREF() on them here. | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2002-03-28 23:32:53 +00:00
										 |  |  |     PyObject_Del(self); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-07-17 16:42:48 +00:00
										 |  |  | static PyTypeObject noddy_NoddyType = { | 
					
						
							| 
									
										
										
										
											2002-03-28 23:32:53 +00:00
										 |  |  |     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[] = { | 
					
						
							| 
									
										
										
										
											2002-04-12 16:17:06 +00:00
										 |  |  |     {"new_noddy", noddy_new_noddy, METH_NOARGS, | 
					
						
							| 
									
										
										
										
											2002-03-28 23:32:53 +00:00
										 |  |  |      "Create a new Noddy object."}, | 
					
						
							| 
									
										
										
										
											2002-04-12 16:17:06 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     {NULL}  /* Sentinel */ | 
					
						
							| 
									
										
										
										
											2002-03-28 23:32:53 +00:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-07-31 06:17:46 +00:00
										 |  |  | PyMODINIT_FUNC | 
					
						
							| 
									
										
										
										
											2002-03-28 23:32:53 +00:00
										 |  |  | initnoddy(void)  | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     noddy_NoddyType.ob_type = &PyType_Type; | 
					
						
							| 
									
										
										
										
											2002-04-12 16:17:06 +00:00
										 |  |  |     if (PyType_Ready(&noddy_NoddyType)) | 
					
						
							|  |  |  |         return; | 
					
						
							| 
									
										
										
										
											2002-03-28 23:32:53 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-04-12 16:17:06 +00:00
										 |  |  |     Py_InitModule3("noddy", noddy_methods | 
					
						
							|  |  |  |                    "Example module that creates an extension type."); | 
					
						
							| 
									
										
										
										
											2002-03-28 23:32:53 +00:00
										 |  |  | } |