I'm using swig to wrap a c++ function to python like this:
int getBytes(unsigned char *& result, int length)
I have learnt from this question how to wrap a function returned char* by reference:
%typemap(in,numinputs=0) char*& (char* tmp) %{
$1 = &tmp;
%}
%typemap(argout) char*& (PyObject* obj) %{
obj = PyUnicode_FromString(*$1);
$result = SWIG_Python_AppendOutput($result,obj);
%}
%typemap(freearg) char*& %{
free(*$1);
%}
I tried to apply this to unsigned char* but failed and get the error that SWIG_Python_AppendOutput
cannot convert an unsigned char** to signed char**. I searched python doc and didn't find a function which can convert an unsigned char** to unsigned char**.
Anyone can help? Thanks!