I'm in the process of trying to wrap a few C++ header files that have classes that use pointers in two of the following ways:
1) As arrays as data members for a class.
2) As an array as an argument for a function
These classes are to be subclassed in Python and the methods are to be overridden.
An example header file would look something like this:
struct Array{
int * array;
int array size;
}
class A{
public:
//Meant to be accessed as an array
virtual void func( int size, double * array) = 0;
virtual bool func2(long size1, long size2, float * array1, int * array2) = 0;
}
In all cases, the arrays are meant to be static in size. However, in some instances, the arrays have been initialized and in others, they have not( so the pointer=NULL).
What I need to figure out is:
1) How do you wrap a C++ array if it is a data member of a class?
2) How do you handle C++ arrays that are passed as arguments to a function?
3) How do you allocate and initialize the wrapped array in Python?
4) How do you wrap C++ arrays so that changes made in Python are passed back to the original array and that changes to the original array are reflected in the Python?
EDIT:
I'm not demanding that answers for all four questions be discussed for SWIG, cytpes, Cython and Boost-Python. A discussion on all four would be nice, however, I realize that is asking a bit much.
I have a preference for the response to use SWIG. However, I tagged all four because in trying to find a solution to this problem myself, I found that there is sparse information on how to achieve this for any of Python extension systems.
My hopes were to create a good starting point for a reoccurring issue when trying to wrap C++ code.