Python, SWIG and pointers

Nicolas Devillard ndev42 at yahoo.com
Fri Mar 10 10:56:19 CET 2000


I have a C library and I have to make bindings to
Python using SWIG. The problem I have is: how to
handle pointers to pointers?

If I have the following data struct in C:

typedef struct _OBJ_ {
   ...
} obj ;

And the associated constructor, used as:

obj * b ;
a = new_obj() ;

Then there are functions expecting a pointer to
a pointer to struct for modification, something like:

modify_obj(&a);

The SWIG-generated binding for new_obj() will
return an opaque object that is compatible with a
pointer to obj, but how do I pass it in Python
to modify_obj(), that is expecting a pointer to
this opaque object?

Do I need to declare some type conversion by hand
or is there a way to make SWIG aware of that kind
of pointer to pointer?

Thanks for helping
--
Nicolas
__________________________________________________
Do You Yahoo!?
Talk to your friends online with Yahoo! Messenger.
http://im.yahoo.com




More information about the Python-list mailing list