我正在尝试创建Java实现,以便使用Swig将字节[]传递到C。
大口:
%include "typemaps.i"
%apply(char *STRING, int LENGTH) { (char *buff, int len) };
%inline {
typedef struct {
char* buff;
int len;
} workit_t;
}在我生成的java类(workit_t.java)中,参数buff是一个字符串,而不是字节[]。
爪哇:
public void setBuff(String value){
...
}我在喝酒的时候做错了什么?
当我编写一个没有结构的简单的swig定义时,我得到了所需的参数类型。
大口:
%include "typemaps.i"
%apply(char *STRING, int LENGTH) { (char *buff1, int *len1) };爪哇:
public static void Mathit(byte[] buff1, byte[] buff2) {
...
}发布于 2016-06-14 01:30:30
好吧,我已经把它做对了。
在此之前:
%include "typemaps.i"
%apply(char *STRING, int LENGTH) { (char *buff, int len) };
%inline {
typedef struct {
char* buff;
int len;
} workit_t;
}现在:
%include various.i
%apply char *BYTE { char *buff }; //map a Java byte[] array to a C char array
%inline {
typedef struct {
char* buff;
int len;
} workit_t;
}或者:
%include various.i
%apply char *NIOBUFFER { char *buff }; //map Java nio buffers to C char array
%inline {
typedef struct {
char* buff;
int len;
} workit_t;
}https://stackoverflow.com/questions/37800592
复制相似问题