2007-08-15 11:28:22 -03:00
|
|
|
#include <Python.h>
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
PyObject_HEAD
|
|
|
|
/* Type-specific fields go here. */
|
|
|
|
} noddy_NoddyObject;
|
|
|
|
|
|
|
|
static PyTypeObject noddy_NoddyType = {
|
2009-05-05 04:55:26 -03:00
|
|
|
PyVarObject_HEAD_INIT(NULL, 0)
|
2008-12-05 11:12:15 -04:00
|
|
|
"noddy.Noddy", /* tp_name */
|
|
|
|
sizeof(noddy_NoddyObject), /* tp_basicsize */
|
|
|
|
0, /* tp_itemsize */
|
|
|
|
0, /* tp_dealloc */
|
|
|
|
0, /* tp_print */
|
|
|
|
0, /* tp_getattr */
|
|
|
|
0, /* tp_setattr */
|
2009-02-02 17:29:40 -04:00
|
|
|
0, /* tp_reserved */
|
2008-12-05 11:12:15 -04:00
|
|
|
0, /* tp_repr */
|
|
|
|
0, /* tp_as_number */
|
|
|
|
0, /* tp_as_sequence */
|
|
|
|
0, /* tp_as_mapping */
|
|
|
|
0, /* tp_hash */
|
|
|
|
0, /* tp_call */
|
|
|
|
0, /* tp_str */
|
|
|
|
0, /* tp_getattro */
|
|
|
|
0, /* tp_setattro */
|
|
|
|
0, /* tp_as_buffer */
|
|
|
|
Py_TPFLAGS_DEFAULT, /* tp_flags */
|
2007-08-15 11:28:22 -03:00
|
|
|
"Noddy objects", /* tp_doc */
|
2017-09-22 13:14:13 -03:00
|
|
|
0, /* tp_traverse */
|
|
|
|
0, /* tp_clear */
|
|
|
|
0, /* tp_richcompare */
|
|
|
|
0, /* tp_weaklistoffset */
|
|
|
|
0, /* tp_iter */
|
|
|
|
0, /* tp_iternext */
|
|
|
|
0, /* tp_methods */
|
|
|
|
0, /* tp_members */
|
|
|
|
0, /* tp_getset */
|
|
|
|
0, /* tp_base */
|
|
|
|
0, /* tp_dict */
|
|
|
|
0, /* tp_descr_get */
|
|
|
|
0, /* tp_descr_set */
|
|
|
|
0, /* tp_dictoffset */
|
|
|
|
0, /* tp_init */
|
|
|
|
0, /* tp_alloc */
|
|
|
|
PyType_GenericNew, /* tp_new */
|
2007-08-15 11:28:22 -03:00
|
|
|
};
|
|
|
|
|
2008-12-05 11:12:15 -04:00
|
|
|
static PyModuleDef noddymodule = {
|
|
|
|
PyModuleDef_HEAD_INIT,
|
|
|
|
"noddy",
|
|
|
|
"Example module that creates an extension type.",
|
|
|
|
-1,
|
|
|
|
NULL, NULL, NULL, NULL, NULL
|
2007-08-15 11:28:22 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
PyMODINIT_FUNC
|
2015-03-18 16:53:15 -03:00
|
|
|
PyInit_noddy(void)
|
2007-08-15 11:28:22 -03:00
|
|
|
{
|
|
|
|
PyObject* m;
|
|
|
|
|
|
|
|
if (PyType_Ready(&noddy_NoddyType) < 0)
|
2008-12-05 11:12:15 -04:00
|
|
|
return NULL;
|
2007-08-15 11:28:22 -03:00
|
|
|
|
2008-12-05 11:12:15 -04:00
|
|
|
m = PyModule_Create(&noddymodule);
|
|
|
|
if (m == NULL)
|
|
|
|
return NULL;
|
2007-08-15 11:28:22 -03:00
|
|
|
|
|
|
|
Py_INCREF(&noddy_NoddyType);
|
|
|
|
PyModule_AddObject(m, "Noddy", (PyObject *)&noddy_NoddyType);
|
2008-12-24 12:27:25 -04:00
|
|
|
return m;
|
2007-08-15 11:28:22 -03:00
|
|
|
}
|