blob: 07b5d5a9b83ce08dacc3aca57ab86ff6139b028e [file] [log] [blame]
Georg Brandl116aa622007-08-15 14:28:22 +00001#include <Python.h>
2
3typedef struct {
4 PyObject_HEAD
5 /* Type-specific fields go here. */
6} noddy_NoddyObject;
7
8static PyTypeObject noddy_NoddyType = {
Georg Brandl51335292009-05-05 07:55:26 +00009 PyVarObject_HEAD_INIT(NULL, 0)
Georg Brandl913b2a32008-12-05 15:12:15 +000010 "noddy.Noddy", /* tp_name */
11 sizeof(noddy_NoddyObject), /* tp_basicsize */
12 0, /* tp_itemsize */
13 0, /* tp_dealloc */
14 0, /* tp_print */
15 0, /* tp_getattr */
16 0, /* tp_setattr */
Mark Dickinson9f989262009-02-02 21:29:40 +000017 0, /* tp_reserved */
Georg Brandl913b2a32008-12-05 15:12:15 +000018 0, /* tp_repr */
19 0, /* tp_as_number */
20 0, /* tp_as_sequence */
21 0, /* tp_as_mapping */
22 0, /* tp_hash */
23 0, /* tp_call */
24 0, /* tp_str */
25 0, /* tp_getattro */
26 0, /* tp_setattro */
27 0, /* tp_as_buffer */
28 Py_TPFLAGS_DEFAULT, /* tp_flags */
Georg Brandl116aa622007-08-15 14:28:22 +000029 "Noddy objects", /* tp_doc */
Stefan Krahb1558a02017-09-22 18:14:13 +020030 0, /* tp_traverse */
31 0, /* tp_clear */
32 0, /* tp_richcompare */
33 0, /* tp_weaklistoffset */
34 0, /* tp_iter */
35 0, /* tp_iternext */
36 0, /* tp_methods */
37 0, /* tp_members */
38 0, /* tp_getset */
39 0, /* tp_base */
40 0, /* tp_dict */
41 0, /* tp_descr_get */
42 0, /* tp_descr_set */
43 0, /* tp_dictoffset */
44 0, /* tp_init */
45 0, /* tp_alloc */
46 PyType_GenericNew, /* tp_new */
Georg Brandl116aa622007-08-15 14:28:22 +000047};
48
Georg Brandl913b2a32008-12-05 15:12:15 +000049static PyModuleDef noddymodule = {
50 PyModuleDef_HEAD_INIT,
51 "noddy",
52 "Example module that creates an extension type.",
53 -1,
54 NULL, NULL, NULL, NULL, NULL
Georg Brandl116aa622007-08-15 14:28:22 +000055};
56
Georg Brandl116aa622007-08-15 14:28:22 +000057PyMODINIT_FUNC
Serhiy Storchaka009b8112015-03-18 21:53:15 +020058PyInit_noddy(void)
Georg Brandl116aa622007-08-15 14:28:22 +000059{
60 PyObject* m;
61
Georg Brandl116aa622007-08-15 14:28:22 +000062 if (PyType_Ready(&noddy_NoddyType) < 0)
Georg Brandl913b2a32008-12-05 15:12:15 +000063 return NULL;
Georg Brandl116aa622007-08-15 14:28:22 +000064
Georg Brandl913b2a32008-12-05 15:12:15 +000065 m = PyModule_Create(&noddymodule);
66 if (m == NULL)
67 return NULL;
Georg Brandl116aa622007-08-15 14:28:22 +000068
69 Py_INCREF(&noddy_NoddyType);
70 PyModule_AddObject(m, "Noddy", (PyObject *)&noddy_NoddyType);
Benjamin Peterson71e30a02008-12-24 16:27:25 +000071 return m;
Georg Brandl116aa622007-08-15 14:28:22 +000072}