This is part of the code I wanna wrap:
typedef unsigned char UINT8;
...
void fn(UINT8 data[]);
In a .i file, I included:
From 8.2.2 carrays.i:
%array_class(UINT8, UINT8Array)
To support array write operation:
%typemap(in) UINT8[ANY] ($1_basetype temp[$1_dim0]) {
int i;
if (!PySequence_Check($input)) {
PyErr_SetString(PyExc_ValueError,"Expected a sequence as input");
return NULL;
}
if (PySequence_Length($input) != $1_dim0) {
PyErr_SetString(PyExc_ValueError,"Input sequence size incorrect, should have $1_dim0 ints");
return NULL;
}
for (i = 0; i < $1_dim0; i++) {
PyObject *o = PySequence_GetItem($input,i);
if (PyNumber_Check(o)) {
temp[i] = ($1_basetype)PyInt_AsLong(o);
Py_DECREF(o);
} else {
Py_XDECREF(o);
PyErr_SetString(PyExc_ValueError,"Input sequence elements must be numbers");
return NULL;
}
}
$1 = temp;
}
then, when compiling, my code fails:
example_wrap.cxx:40:15: error: storage size of ‘temp2’ isn’t known
UINT8 temp2[] ;
Please note, that the wrapping works if my function is like:
void fn(UINT8 data[10]);
void fn(UINT8* data);
Is there a way I can tell swig, when there is a UINT8[] to trait it as it is a UINT8 *. Something like this:
%typemap(in) UINT8[] ($1_basetype *temp) {
Thanks, Pablo