我有一个方法导出到Python使用boost python,它需要一个boost :: function作为参数。Python的方法来提升功能
从我读过的boost ::蟒蛇应该支持的boost ::功能,无需大惊小怪,但是当我尝试调用函数与蟒蛇方法它给了我这个错误
Boost.Python.ArgumentError: Python argument types in
Class.createTimer(Class, int, method, bool)
did not match C++ signature:
createTimer(class Class {lvalue}, unsigned long interval,
class boost::function<bool _cdecl(void)> function, bool recurring=False)
我打电话它从蟒与此代码
self.__class.createTimer(3, test.timerFunc, False)
和在C++中它被定义为
boost::int32_t createTimer(boost::uint32_t interval, boost::function< bool() > function, bool recurring = false);
这里的目标是一个定时器类,我可以做这样的事情
class->createTimer(3, boost::bind(&funcWithArgs, arg1, arg2))
创建执行funcWithArgs一个计时器。多亏了boost绑定,它可以和任何函数或方法一起工作。
那么我需要什么语法来使用boost :: python来接受我的python函数作为boost :: function?