[C++-sig] Problem using wrapped void* in Python

Kor de Jong k.dejong at geog.uu.nl
Mon Dec 1 09:38:49 CET 2003


Hi Ralf,

Thank you for your reply.

Ralf W. Grosse-Kunstleve wrote:
>>So, what I am looking for is a way to tell Boost.Python how to convert 
>>from void* to Python and back. I have tried various things, like the 
>>opaque_pointer_converter and the to_python_converter, but I end up with 
>>code which I don't understand anymore and/or which doesn't compile. I 
>>would be very grateful if one of you could provide me with a bit of code 
>>to get me going again.
> 
> 
> Recently Niall Douglas added this to the Boost.Python FAQ:
> 
> http://cci.lbl.gov/~rwgk/shortcuts/boost/libs/python/doc/v2/faq.html#voidptr
> 
> Does this help in your case?

I see how this works in the case of converting void* function arguments. 
This will be useful for me too. But in my current case I am wrapping a 
struct which has a void* datamember. Accessing the enum/int/string 
datamembers of the struct from Python goes fine, but accessing the void* 
datamember is a problem and gives:

TypeError: No to_python (by-value) converter found for C++ type: Pv

Again, I don't want to access the actual data pointed to by the pointer, 
I just want to pass it along to wrapped functions.

I might be missing something obvious, but the docs and mailinglist 
archives didn't help me further.

Does anyone have something to say about converting void* to Python and back?

Thanks,
Kor





More information about the Cplusplus-sig mailing list