[C++-sig] ANNOUNCE: PyBindGen 0.8
Gustavo Carneiro
gjcarneiro at gmail.com
Sun Jun 1 22:09:45 CEST 2008
On 01/06/2008, Hans Meine <meine at informatik.uni-hamburg.de> wrote:
>
> Hi!
>
>
> On Dienstag 04 Dezember 2007, Gustavo Carneiro wrote:
> > The other day I released PyBindGen 0.8. Main news is that it features a
> > new experimental header file scanner based on pygccxml (i.e., it's
> similar
> > to py++ in scope, if not in maturity, but does not use
> > boost.pythonunderneath).
>
>
> This all sounded very interesting, so I have just tried pybindgen out.
>
> First, I noticed, that void return type is handled with Py_BuildValue,
> which
> is slight overkill, isn't it (since one of PyBindGen's design goals is to
> write lean, nearly-handwritten style code)?
True. But I think special-casing for when only None is returned makes sense
and should be relatively simple to implement.
I have registered on launchpad
> to be able to submit a patch when I would have managed to make it return
> Py_None directly, but I have more serious problems when trying to wrap the
> following simple type declaration:
>
> union Word
> {
> short word;
> struct
> {
> char low, high;
> };
> };
>
> The gccxml module does not seem to recognize the "short" return value:
>
> .../word.h:6: Warning: Return value 'short int' error (used in Word::word
> [variable]): TypeLookupError('short int',)
> short word;
>
> However, when looking at pybindgen/typehandlers/inttype.py, fixing this
> seems
> to be possible, but I wonder if a more general approach than adding one
> class
> for each combination of const/ptr/ref/unsigned/width integer type would be
> more sensible?
I'm not sure. Maybe it's possible to find a common base class for all
int-like types.
Obviously, I'd better leave this decision & fix to the
> original authors.
>
> Finally, the anonymous struct inside the union is not yet
> supported. AFAICS,
> PyBindGen would "simply" need to descend into the struct and export its
> members like direct members of the surrounding type. Right now, it
> produces
> illegal code because it tries to wrap a data member with an empty string as
> name:
>
> static PyObject* _wrap_PyWord__get_(PyWord *self)
> {
> PyObject *py_retval;
> PyWord *py_Word;
>
> py_Word = PyObject_New(PyWord, &PyWord_Type);
> py_Word->obj = new Word(self->obj->);
> py_retval = Py_BuildValue("N", py_Word);
> return py_retval;
> }
> [...]
> static PyGetSetDef PyWord__getsets[] = {
> {
> "", /* attribute name */
> (getter) _wrap_PyWord__get_, /* C function to get the attribute */
> (setter) _wrap_PyWord__set_, /* C function to set the attribute */
> NULL, /* optional doc string */
> NULL /* optional additional data for getter and setter */
> },
> { NULL, NULL, NULL, NULL, NULL }
> };
Ugh.. right, I guess it's a bug. But I am curious, how do you access
anonymous structures from C? It does not seem possible, unless I am missing
something, and if so, what would be the point in wrapping them? Maybe it's
better to just ignore it?
Thanks for your feedback.
Although I have not made any PyBindGen release in a very long time,
development is far from stagnated, in case anyone is wondering...
--
Gustavo J. A. M. Carneiro
INESC Porto, Telecommunications and Multimedia Unit
"The universe is always one step beyond logic." -- Frank Herbert
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20080601/fad950e2/attachment.htm>
More information about the Cplusplus-sig
mailing list