这里是swig typemap,它将c++类型转换为python类型。
# ifdef SWIGPYTHON
%typemap(in) (char *data, size_t datasize) {
Py_ssize_t len;
PyBytes_AsStringAndSize($input, &$1, &len);
$2 = (size_t)len;
}
%typemap(in, numinputs=0) (char**data, size_t *datasize)(char *temp, size_t tempsize) {
$1 = &temp;
$2 = &tempsize;
}
%typemap(argout) (char**data, size_t *datasize) {
if(*$1) {
$result = PyBytes_FromStringAndSize(*$1, *$2);
free(*$1);
}
}
# endif
你能做同样的事吗,但是对于java语言?所以答案是
# ifdef SWIGJAVA
%typemap(in) (char *data, size_t datasize) {
convertJavaBytesToC++Bytes();
...something else...
}
...
所以我需要它来生成正确的java Package 器代码
我想翻译成java的c++函数声明:
public void getFrames(char**data, size_t *datasize) {
std::string s = getFramesAsString();
size_t size = s.length();
char *c = new char[size];
s.copy(c, size, 0);
*datasize = size;
*data = c;
};
public void putFrame(char *data, size_t datasize) {
const std::lock_guard<std::mutex> lock(frames_mtx);
frames.push_front(std::string(data, datasize));
};
暂无答案!
目前还没有任何答案,快来回答吧!