java - swig 2 编组到 std::vector& 从 java 到 c++
问题描述
这是我所拥有的:
%module FacadeInterface
%{
#include <Facade.h>
#include <boost/filesystem/path.hpp>
%}
%typemap(jni) boost::filesystem::path "jstring"
%typemap(jstype) boost::filesystem::path "java.io.File"
%typemap(jtype) boost::filesystem::path "String"
%typemap(javain) boost::filesystem::path "$javainput.toString()"
%typemap(in) boost::filesystem::path (boost::filesystem::path tmp) {
const char *str = JCALL2(GetStringUTFChars, jenv, $input, 0);
tmp = str;
$1 = &tmp;
JCALL2(ReleaseStringUTFChars, jenv, $input, str);
}
%include "Facade.h"
%include <std_vector.i>
%template(PathsVector) std::vector<boost::filesystem::path>;
这是 Facade.h 的内容
bool run(const std::vector<boost::filesystem::path> &plyFiles);
编译java源代码时出现以下错误:
/root/build/src/main/com/facade/PathsVector.java:71: error: incompatible types: String cannot be converted to long
return new SWIGTYPE_p_boost__filesystem__path(FacadeInterfaceJNI.PathsVector_get(swigCPtr, this, i), false);
解决方案
推荐阅读
- ios - 使用 WSO2 在 IOS 中进行身份验证时出错
- c++ - SDL GPU 为什么在两个单独的 for 循环中对两个图像进行 blitting 更快?
- css - 在响应式图像上定位点
- python - 如何使用 Music21 库将所有 midi 文件转换为通用键(主要和次要)
- c# - C# Picturebox加载的PNG保存与Picturebox背景颜色
- javascript - 将数据循环到 DOM 后如何从 api 捕获数据
- flask - 如何让 pytest 正确提交烧瓶 wtforms 表单
- sublimetext3 - 为晦涩的语言创建 Sublime Text 3 语法
- python - Pandas Dataframe - 系列的真值不明确
- excel - 如何在路径名中不包含当前用户的情况下打开另一个 Excel 文件?