我有一个拥有这些原型的构造器:
YCPTerm(const string& s);
YCPTerm(const string& s, const YCPList& l);
YCPTerm(bytecodeistream & str);
我使用swig生成python绑定。在python中,我尝试调用构造函数,得到以下结果:
^{pr2}$我发现了this answer这似乎是一个类似的问题,但是typemap类型检查对我不起作用。在
这就是我所尝试的:
%typemap(typecheck,precedence=141) const std::string& str {
$1 = Z_TYPE_PP($input) == IS_STRING;
}
我怎么解决这个问题?我需要输入和输出类型映射来转换值吗?我一直在reading about typemap's here,不知道如何对常量字符串进行类型映射;。在
std_string.i
库包含在std::string
和Python字符串之间来回转换的typedef。有关详细信息,请参见the documentation on the std::string library in SWIG。在我找到了answer here。在
将这些行添加到我的.i文件中修复了错误:
我不明白为什么。也许其他人能回答这个问题。在
相关问题 更多 >
编程相关推荐