I am wrapping this lib with Python SWIG that has a function looking like this:
int set_option(Foo *foo, const char *name, void *value);
In the lib const char *name
is mapped to a type that I have access to look up: int
, char *
, char **
.
The wrapper code generated by default accepts only a wrapped void *
(naturally).
What is the best way to make the wrapped method accept any Python object as argument, and do the type checking, and Python to C conversion in my own C code?
My guess would be some kind of type map, but alas I cannot figure it out.
@Goodies
In [12]: lib.set_option(foo, "option", "value") --------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-12-4ccf706b5c50> in <module>() ----> 1 lib.set_option(foo, "option", "value") TypeError: in method 'set_option', argument 3 of type 'void *'