我有一個方法導出到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?