1 diff --git plugins/python/python-window.c plugins/python/python-window.c
2 index e0ac50f..3fee09a 100644
3 --- plugins/python/python-window.c
4 +++ plugins/python/python-window.c
7 // * ***************************************************************************
9 +PyTypeObject ekg_window_type = {
10 + PyObject_HEAD_INIT(NULL)
13 + sizeof(ekg_windowObj),
15 + (destructor)ekg_window_dealloc,
17 + (getattrfunc)ekg_window_get_attr,
20 + (reprfunc)ekg_window_repr,
26 + (reprfunc)ekg_window_str, /*tp_str*/
30 + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
31 + "Window object", /* tp_doc */
32 + 0, /* tp_traverse */
34 + 0, /* tp_richcompare */
35 + 0, /* tp_weaklistoffset */
37 + 0, /* tp_iternext */
38 + ekg_window_methods, /* tp_methods */
43 + 0, /* tp_descr_get */
44 + 0, /* tp_descr_set */
45 + 0, /* tp_dictoffset */
46 + (initproc)ekg_window_init, /* tp_init */
54 diff --git plugins/python/python-window.h plugins/python/python-window.h
55 index 8361164..dce92ff 100644
56 --- plugins/python/python-window.h
57 +++ plugins/python/python-window.h
58 @@ -52,48 +52,7 @@ staticforward PyMethodDef ekg_window_methods[] = {
62 -static PyTypeObject ekg_window_type = {
63 - PyObject_HEAD_INIT(NULL)
66 - sizeof(ekg_windowObj),
68 - (destructor)ekg_window_dealloc,
70 - (getattrfunc)ekg_window_get_attr,
73 - (reprfunc)ekg_window_repr,
79 - (reprfunc)ekg_window_str, /*tp_str*/
83 - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
84 - "Window object", /* tp_doc */
85 - 0, /* tp_traverse */
87 - 0, /* tp_richcompare */
88 - 0, /* tp_weaklistoffset */
90 - 0, /* tp_iternext */
91 - ekg_window_methods, /* tp_methods */
96 - 0, /* tp_descr_get */
97 - 0, /* tp_descr_set */
98 - 0, /* tp_dictoffset */
99 - (initproc)ekg_window_init, /* tp_init */
104 +extern PyTypeObject ekg_window_type;
108 diff --git plugins/python/python.c plugins/python/python.c
109 index 272ad4f..207a8d3 100644
110 --- plugins/python/python.c
111 +++ plugins/python/python.c
114 #include "python-ekg.h"
115 #include "python-config.h"
116 +#include "python-window.h"
118 #include <sys/types.h>
120 @@ -531,6 +532,22 @@ without that works ? wtf ?!
122 // ********************************************************************************
125 +/* XXX check http://docs.python.org/extending/newtypes.html */
126 +static void python_init_type(PyTypeObject *type)
128 + type->tp_new = PyType_GenericNew;
129 + if (PyType_Ready(type) < 0)
132 + PyObject* m = Py_InitModule3("noddy", noddy_methods,
133 + "Example module that creates an extension type.");
135 + Py_INCREF(&noddy_NoddyType);
136 + PyModule_AddObject(m, "Noddy", (PyObject *)&noddy_NoddyType);
141 * python_initialize()
143 @@ -550,6 +567,8 @@ int python_initialize()
144 ekg_config = PyObject_NEW(PyObject, &ekg_config_type);
145 PyModule_AddObject(ekg, "config", ekg_config);
147 + python_init_type(&ekg_window_type);
150 PyModule_AddStringConstant(ekg, "VERSION", VERSION);