[pygtk] virtual function without a return value
Gustavo J. A. M. Carneiro
gjc at inescporto.pt
Mon Jun 11 19:07:37 WST 2007
On Dom, 2007-06-10 at 23:26 +0100, Gustavo J. A. M. Carneiro wrote:
> On Dom, 2007-06-10 at 21:46 +0200, Sébastien Granjoux wrote:
> > Hi All,
> >
> > I'm writing a wrapper for a GInterface derived type, so I have written a
> > .defs file with something like
> >
> > (define-virtual activate
> > (of-object "Plugin")
> > (c-name "plugin_activate")
> > (return-type "none")
> > )
> >
> >
> > Using codegen I get a function
> >
> > static void _wrap_Plugin__proxy_do_activate(Plugin *self)
> > {
> > ...
> > py_retval = PyObject_CallObject(py_method, py_args);
> > ...
> > py_retval = Py_BuildValue("(N)", py_retval);
> > if (!PyArg_ParseTuple(py_retval, "")) {
> > if (PyErr_Occurred())
> >
> >
> > I don't understand why codegen generates some code to extract the return
> > value from the python method as the C function doesn't need to return
> > anything. Moreover, I have an error (not fatal) "TypeError: function
> > takes exactly 0 arguments (1 given)" in PyArg_ParseTuple which I think
> > is due to the empty string "".
> >
> > Is it something wrong in codegen or do I have made an error somewhere ?
>
> I think it's a bug in codegen. A patch (codegen/reversewrapper.py)
> would be most welcome; it just needs to special case where
> PyArg_ParseTuple is called to parse return value if the template string
> is "", then just check for Py_None instead of calling PyArg_ParseTuple.
Nevermind, I fixed this myself in svn trunk.
--
Gustavo J. A. M. Carneiro
<gjc at inescporto.pt> <gustavo at users.sourceforge.net>
The universe is always one step beyond logic.
More information about the pygtk
mailing list