[pypy-dev] cppyy and callbacks
Alex Stewart
foogod at gmail.com
Wed Jan 22 23:44:10 CET 2014
>
> sorry for not responding earlier; had a bit of rough week at work.
No worries.. I'm used to some lists where people can take a week or more to
respond, so this is actually a refreshing change :)
But I'll first start implementing void* now.
>
That would be awesome, if it's not too much trouble.. Using intptr_t is
working fairly well for the callback stuff, but there are some other places
in the library where void pointers are passed around (for example,
assigning "user data" to some types of objects), which I've been trying to
figure out how I would deal with if I couldn't use "void*", so it would
definitely be useful..
Sorry to be a pest, but I've got one more question:
Currently, for the callbacks, I'm converting the C++ object pointer to an
intptr_t, and then on the Python side using cppyy.bind_object to convert
that intptr_t back to an object of the specified type. I've noticed,
however, that if I (for example) call a function which returns an object of
BaseClass, but the object being returned actually happens to be a
DerivedClass object, cppyy (somehow) figures this out and it comes through
as a DerivedClass automatically in Python (so you don't need to cast it).
If, however, the same object gets passed back via a callback (and I use
cppyy.bind_object(ptr, BaseClass)), it comes out as a BaseClass regardless
(so the Python code needs to know it's actually a DerivedClass somehow, and
manually cast it).
Is there some way I could do something like bind_object, but have it do the
automagical "figure out what derived class this actually is and return that
instead" behavior that cppyy can apparently do in other places?
--Alex
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pypy-dev/attachments/20140122/e53a6b2f/attachment.html>
More information about the pypy-dev
mailing list