Opened 14 years ago

Closed 12 years ago

#2230 closed Feature Requests (invalid)

Wrapping Python function pointer

Reported by: william.marie@… Owned by: Dave Abrahams
Milestone: Boost 1.37.0 Component: python USE GITHUB
Version: Boost 1.36.0 Severity: Optimization
Keywords: function pointer Cc:

Description

It would be really usefull to be able to wrap python function pointer as the following example :

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);

}

Change History (1)

comment:1 by Steven Watanabe, 12 years ago

Resolution: invalid
Status: newclosed

It isn't possible to convert a python function into a C function pointer, because a function pointer has no state. The closest you can get is to use the call operator of boost::python::object. See http://www.boost.org/libs/python/doc/v2/callbacks.html.

Note: See TracTickets for help on using tickets.