开发者

how can 'const unsigned char *' be wrapped with swig for java

开发者 https://www.devze.com 2023-03-13 02:55 出处:网络
How开发者_如何学Python can the following C function be wrapped with SWIG? int add_option(const unsigned char *data);

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号