我使用swig生成包裹我的c库的JNI代码。
但是JNI函数在java
中返回一个长整数(指向uint8数组的指针)如何使用长整数(指向uint8的指针)来获取java中的数据?
有人有想法吗?
请注意: tmp_buff_get是在结构中获取指针成员
SWIGEXPORT jlong JNICALL
Java_www_example_com_util_object_dataJNI_UTIL_OBJECT_tmp_buff_get(
JNIEnv *jenv,
jclass jcls,
jlong jarg1,
jobject jarg1_
)
{
jlong jresult = 0 ;
struct _util_object *arg1 = (struct _util_object *) 0 ;
UINT8 *result = 0 ;
(void)jenv;
(void)jcls;
(void)jarg1_;
arg1 = *(struct _util_object **)&jarg1;
result = (UINT8 *) ((arg1)->tmp_buff);
*(UINT8 **)&jresult = result;
return jresult; => the poiner to UINT8 is return as a SWIGTYPE_p_UINT8 type in java
}
public class SWIGTYPE_p_UINT8 {
private transient long swigCPtr;
protected SWIGTYPE_p_UINT8(long cPtr, @SuppressWarnings("unused") boolean futureUse) {
swigCPtr = cPtr;
}
protected SWIGTYPE_p_UINT8() {
swigCPtr = 0;
}
protected static long getCPtr(SWIGTYPE_p_UINT8 obj) {
return (obj == null) ? 0 : obj.swigCPtr;
}
}