我到处看了看。我已经尝试了这个网站上的一些技术。无济于事。
我有一个 C++ 全局函数
char* squid( char* buff, int len );
我创建一个 .i 文件
%module Crabby
%include "arrays_java.i"
%{
/* headers here are included in the wrapper code */
#include "sponge.h"
%}
%typemap(jtype) (const signed char *arr, size_t sz) "byte[]"
%typemap(jstype) (const signed char *arr, size_t sz) "byte[]"
%typemap(jni) (const signed char *arr, size_t sz) "jbyteArray"
%typemap(javain) (const signed char *arr, size_t sz) "$javainput"
%typemap(in) (const signed char* arr, size_t sz) {
$1 = JCALL2(GetByteArrayElements, jenv, $input, NULL);
const size_t sz = JCALL1(GetArrayLength, jenv, $input);
$2 = $1 + sz;
}
%typemap(freearg) (const signed char *arr, size_t sz) {
// Or use 0 instead of ABORT to keep changes if it was a copy
JCALL3(ReleaseByteArrayElements, jenv, $input, $1, JNI_ABORT);
}
%apply (const signed char* arr, size_t sz) { (const unsigned char* buff, int len) }
%apply (const signed char* arr, size_t sz) { (const unsigned char* query, int queryLen) }
%include "sponge.h"
无论我做什么,界面总是
public static String Squid(String buff, int len)
如果我删除未签名的,我会在 cxx 包装器中得到非法转换
这是 Swig 2.0.1