[C++-sig] Pyste suggestion: handling void * arguments

Nicodemus nicodemus at esss.com.br
Mon Oct 27 21:14:45 CET 2003

Niall Douglas wrote:

>Any chance of pyste doing http://mail.python.org/pipermail/c++-
>sig/2003-April/003781.html for us automatically?
>Even a cast to opaque type VOIDPTR would be fine by me.

How about this code (based on Dave's suggestion) for this foo:

void* foo(void *x) { return x; }


struct void_ptr{
    void_ptr(void* it_): it(it_) {}
    void* it;   

void_ptr* foo_w(void_ptr* x) { return new void_ptr(foo(x->it)); }


    def("foo", foo_w, return_value_policy<return_opaque_pointer>());

Obviously, the point of it is to only work around the limitation that 
opaque_pointer's doesn't support void*. If you want to some how fiddle 
with the contents of the void*, you will have to write some wrappers 
that do some conversion on the C++ side.

Opinions? If everyone is fine with it, I can implement this in the next 
couple of days.


More information about the Cplusplus-sig mailing list