How开发者_如何学Python can the following C function be wrapped with SWIG?
int add_option(const unsigned char *data);
Currently I get this wrapped to:
public static int add_option(SWIGTYPE_p_unsigned_char data);
Is it possible to wrap it for String, Byte[] or something similar?
%module Example
%{
int func(const unsigned char *data);
%}
%include <arrays_java.i>
%apply signed char[] { const unsigned char *data};
int func(const unsigned char *data);
Use this code !!!!!
Yes, it is possible. In the worst case, you could build your own typemap. But a %apply should be sufficient here. Try this:
%apply signed char *INOUT { unsigned char *pSeqData };
[I adapted this from a similar problem in my *.i file, after months of not using Swig. YMMV.]
The %apply directive copies typemaps from one type to another. There's more about it here in the SWIG manual.
精彩评论