I have a method that takes a boost function object as so bool createTimer( boost::int64_t interval, boost::function< bool() > function, bool recurring = false )
that I would like to call in python. I tried exporting the class in Py++ but it did not look like it does anything special with that argument. However, when I try to use this from python I get Boost.Python.ArgumentError: Python argument types in createTimer( int, method, bool ) did not match C++ signature: createTimer( unsigned long interval, class boost::function<bool __cdecl(void)> function, bool recurring=False) that is with the export code .def( "createTimer", &Class::createTimer, ( bp::arg( "interval" ), bp::arg( "function" ), bp::arg( "recurring" ) = false ) ) Py++ recommends exporting it like { //::Class::createTimer typedef ::boost::int32_t ( ::Class::*createTimer_function_type )( ::boost::uint32_t,::boost::function< bool ()() >,bool ) ; Class_exposer.def( "createTimer" , createTimer_function_type( &::Class::createTimer ) , ( bp::arg("interval"), bp::arg("function"), bp::arg("recurring")=(bool)(false) ) ); } which btw there is an error here in Py++, ::boost::function< bool ()() > should be ::boost::function< bool () > that code also fails in python with the same error. I have seen the page here http://wiki.python.org/moin/boost.python/HowTo#boost.functionobjects about boost function objects but I do not think that is exactly what I am looking for. If there an easy way to get python to work with this function definition? Or am I trying to do something stupid? with this code I can do createTimer( 3, boost::bind( &longFunc, arg1, arg2 ) ) which is extremely convenient. I would like to have the same ability in python. Thanks
_______________________________________________ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig