[C++-sig] How to wrap a python function pointer ?

David Abrahams dave at boostpro.com
Wed Aug 20 04:35:41 CEST 2008


on Mon Aug 18 2008, William Marié <william.marie-AT-gmail.com> wrote:

> I would like to wrap a python function pointer to a void (*c++fun)() pointer
> :
>
> typedef void (*fct_void_void)( void );
> void addTimer( double dStartIn, double dTickTime, u32 iTickCount,
> fct_void_void bpFctCallback )
> {
>  .....
>        
> } 
> BOOST_PYTHON_MODULE(ksys)
> {
> 	using namespace boost::python;
> 	def("addTimer", &addTimer);
> } 

Hi,

Sorry, but right now we don't have a good solution for that use case.
The best I can offer immediately is that you define a small struct that
holds a fct_void_void, expose that to Python as usual, and then create a
thin wrapper for addTimer that takes the struct instead of the function
pointer.

This could be fixed, though.  Would you care to open a trac ticket at
http://svn.boost.org


-- 
Dave Abrahams
BoostPro Computing
http://www.boostpro.com



More information about the Cplusplus-sig mailing list