can pybindgen handle void pointer

Asked by Stefan Stiene

Hi,
I have the following method :

class Foo {

     ...

     void* At(long Index);

     ...
}
I get:
exception TypeLookupError(['void *'],) in wrapper public: retval? ???::At (params?);

How can I wrap this method? I know which object is hidden behind the void pointer. Do I have to use the CppClass.add_custom_method_wrapper for this method that returns for example a double* instead of a void pointer?

The other way is also interesting for me:

     bool setFoo(void*);

This gives:
exception TypeLookupError(['void *'],) in wrapper public: retval? ???::setFoo (params?);

My first quess to register multiple custum method wrapper for this method . For example;
     bool setFoo(int*);
     bool setFoo(double*);
     ...
Is this right?/possible?

Best
stefan

Question information

Language:
English Edit question
Status:
Answered
For:
PyBindGen Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Gustavo Carneiro (gjc) said :
#1

Wrapping this is possible:

   bool setFoo(int*);
   bool setFoo(double*);

You just wrap multiple methods with different parameter types. In this case, you have have to tell pybindgen more hints than just int*/double*. namely the direction (direction=Parameter.DIRECTION_IN or OUT or INOUT). I guess in this case it's IN, if it's a setter.

However, be cautious about overloading. To select the wrapper, pybindgen just tries to convert the python value to int or double, and if it fails it tests the other parameter type. But int and double are so similar, it is possible that a 1.0 python value will be accepted as a C int with just a warning.

Handling void* is just way too ambiguous and complicated for pybindgen to handle. I guess add_custom_method_wrapper is the only way to go.

Can you help with this problem?

Provide an answer of your own, or ask Stefan Stiene for more information if necessary.

To post a message you must log in.