【发布时间】:2017-10-03 14:55:08
【问题描述】:
我有一个带有这些原型的构造函数:
YCPTerm(const string& s);
YCPTerm(const string& s, const YCPList& l);
YCPTerm(bytecodeistream & str);
我正在使用 swig 来生成 python 绑定。在python中,我尝试调用构造函数,得到这个:
>>> import ycp
>>> ycp.YCPTerm("Empty")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "ycp.py", line 575, in __init__
this = _ycp.new_YCPTerm(*args)
NotImplementedError: Wrong number or type of arguments for overloaded function 'new_YCPTerm'.
Possible C/C++ prototypes are:
YCPTerm::YCPTerm(string const &)
YCPTerm::YCPTerm(string const &,YCPList const &)
YCPTerm::YCPTerm(bytecodeistream &)
我发现this answer 似乎是一个类似的问题,但类型映射类型检查对我不起作用。
这是我尝试过的:
%typemap(typecheck,precedence=141) const std::string& str {
$1 = Z_TYPE_PP($input) == IS_STRING;
}
我该如何解决这个问题?我需要输入和输出类型图来转换值吗?我一直是reading about typemap's here,但不确定如何对 const string& 进行类型映射。
【问题讨论】: