blob: 9d80bbe4650db8076c51cec6a0bcb0350ac62185 [file] [log] [blame]
Georg Brandl8ec7f652007-08-15 14:28:01 +00001#include <Python.h>
2
3typedef struct {
4 PyObject_HEAD
5 /* Type-specific fields go here. */
6} noddy_NoddyObject;
7
8static PyTypeObject noddy_NoddyType = {
INADA Naoki9436bbd2017-02-21 21:12:03 +09009 PyVarObject_HEAD_INIT(NULL, 0)
10 "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 */
17 0, /* tp_compare */
18 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 Brandl8ec7f652007-08-15 14:28:01 +000029 "Noddy objects", /* tp_doc */
30};
31
32static PyMethodDef noddy_methods[] = {
33 {NULL} /* Sentinel */
34};
35
36#ifndef PyMODINIT_FUNC /* declarations for DLL import/export */
37#define PyMODINIT_FUNC void
38#endif
39PyMODINIT_FUNC
40initnoddy(void)
41{
42 PyObject* m;
43
44 noddy_NoddyType.tp_new = PyType_GenericNew;
45 if (PyType_Ready(&noddy_NoddyType) < 0)
46 return;
47
48 m = Py_InitModule3("noddy", noddy_methods,
49 "Example module that creates an extension type.");
50
51 Py_INCREF(&noddy_NoddyType);
52 PyModule_AddObject(m, "Noddy", (PyObject *)&noddy_NoddyType);
53}