Thanks.
I have found a working typemap to convert the array variable in the SWIG interface (.i) file that works for writing an int array from the python script to the c api:
//type map for an input int array, this will calculate the length
%typemap(in) (const int length_in, int *int_in_array)
{
int i;
if (!PyList_Check($input))
{
PyErr_SetString(PyExc_ValueError, "Expecting a list");
return NULL;
}
$1 = PyList_Size($input);
$2 = (int *) malloc(($1)*sizeof(int));
for (i = 0; i < $1; i++)
{
PyObject *s = PyList_GetItem($input,i);
if (!PyInt_Check(s))
{
free($2);
PyErr_SetString(PyExc_ValueError, "List items must be integers");
return NULL;
}
$2[i] = PyInt_AsLong(s);
}
}
And now I'm trying to read an array and read/write structs..