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

William Marié william.marie at gmail.com
Mon Aug 18 12:01:48 CEST 2008


Hi,

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

here is my output :
1>        ..\..\libs\boost\boost/python/converter/registered.hpp(41) : see
reference to class template instantiation 'boost::add_cv<T>' being compiled
1>        with
1>        [
1>            T=void (void)
1>        ]
1>        ..\..\libs\boost\boost/python/converter/registered_pointee.hpp(27)
: see reference to class template instantiation
'boost::python::converter::registered<T>' being compiled
1>        with
1>        [
1>            T=void (void)
1>        ]
1>        ..\..\libs\boost\boost/python/converter/arg_from_python.hpp(269) :
see reference to class template instantiation
'boost::python::converter::registered_pointee<T>' being compiled
1>        with
1>        [
1>            T=void (__cdecl *)(void)
1>        ]
1>        ..\..\libs\boost\boost/python/converter/arg_from_python.hpp(268) :
while compiling class template member function
'boost::python::converter::pointer_arg_from_python<T>::pointer_arg_from_python(PyObject
*)'
1>        with
1>        [
1>            T=void (__cdecl *)(void)
1>        ]
1>        ..\..\libs\boost\boost/python/arg_from_python.hpp(70) : while
compiling class template member function
'boost::python::arg_from_python<T>::arg_from_python(PyObject *)'
1>        with
1>        [
1>            T=void (__cdecl *)(void)
1>        ]
1>        ..\..\libs\boost\boost/preprocessor/iteration/detail/local.hpp(43)
: see reference to class template instantiation
'boost::python::arg_from_python<T>' being compiled
1>        with
1>        [
1>            T=void (__cdecl *)(void)
1>        ]
1>        ..\..\libs\boost\boost/python/detail/caller.hpp(200) : while
compiling class template member function 'PyObject
*boost::python::detail::caller_arity<4>::impl<F,Policies,Sig>::operator
()(PyObject *,PyObject *)'
1>        with
1>        [
1>            F=void (__cdecl *)(double,double,u32,fct_void_void),
1>            Policies=boost::python::default_call_policies,
1>            Sig=boost::mpl::vector5<void,double,double,u32,fct_void_void>
1>        ]
1>        ..\..\libs\boost\boost/python/detail/caller.hpp(169) : see
reference to class template instantiation
'boost::python::detail::caller_arity<4>::impl<F,Policies,Sig>' being
compiled
1>        with
1>        [
1>            F=void (__cdecl *)(double,double,u32,fct_void_void),
1>            Policies=boost::python::default_call_policies,
1>            Sig=boost::mpl::vector5<void,double,double,u32,fct_void_void>
1>        ]
1>        ..\..\libs\boost\boost/python/make_function.hpp(37) : see
reference to class template instantiation
'boost::python::detail::caller<F,CallPolicies,Sig>' being compiled
1>        with
1>        [
1>            F=void (__cdecl *)(double,double,u32,fct_void_void),
1>            CallPolicies=boost::python::default_call_policies,
1>            Sig=boost::mpl::vector5<void,double,double,u32,fct_void_void>
1>        ]
1>        ..\..\libs\boost\boost/python/make_function.hpp(104) : see
reference to function template instantiation 'boost::python::api::object
boost::python::detail::make_function_aux<void(__cdecl
*)(double,double,u32,fct_void_void),boost::python::default_call_policies,boost::mpl::vector5<T0,T1,T2,T3,T4>>(F,const
CallPolicies &,const Sig &)' being compiled
1>        with
1>        [
1>            T0=void,
1>            T1=double,
1>            T2=double,
1>            T3=u32,
1>            T4=fct_void_void,
1>            F=void (__cdecl *)(double,double,u32,fct_void_void),
1>            CallPolicies=boost::python::default_call_policies,
1>            Sig=boost::mpl::vector5<void,double,double,u32,fct_void_void>
1>        ]
1>        ..\..\libs\boost\boost/python/def.hpp(82) : see reference to
function template instantiation 'boost::python::api::object
boost::python::make_function<void(__cdecl
*)(double,double,u32,fct_void_void)>(F)' being compiled
1>        with
1>        [
1>            F=void (__cdecl *)(double,double,u32,fct_void_void)
1>        ]
1>        ..\..\libs\boost\boost/python/def.hpp(91) : see reference to
function template instantiation 'boost::python::api::object
boost::python::detail::make_function1<void(__cdecl
*)(double,double,u32,fct_void_void)>(T,...)' being compiled
1>        with
1>        [
1>            T=void (__cdecl *)(double,double,u32,fct_void_void)
1>        ]
1>        ..\..\libs\script\src\ksysmodule.cpp(35) : see reference to
function template instantiation 'void boost::python::def<void(__cdecl
*)(double,double,u32,fct_void_void)>(const char *,Fn)' being compiled
1>        with
1>        [
1>            Fn=void (__cdecl *)(double,double,u32,fct_void_void)
1>        ]
1>..\..\libs\boost\boost/python/converter/registered.hpp(86) : error C2784:
'void boost::python::converter::detail::register_shared_ptr1(volatile const
T *)' : could not deduce template argument for 'volatile const T *' from
'void (__cdecl *)(void)'
1>        ..\..\libs\boost\boost/python/converter/registered.hpp(77) : see
declaration of 'boost::python::converter::detail::register_shared_ptr1'
1>        ..\..\libs\boost\boost/python/converter/registered.hpp(94) : see
reference to function template instantiation 'const
boost::python::converter::registration
&boost::python::converter::detail::registry_lookup2<T>(T (__cdecl &(__cdecl
*)(void)))' being compiled
1>        with
1>        [
1>            T=void (void)
1>        ]
1>        ..\..\libs\boost\boost/python/converter/registered.hpp(105) : see
reference to function template instantiation 'const
boost::python::converter::registration
&boost::python::converter::detail::registry_lookup1<T>(boost::type<T>)'
being compiled
1>        with
1>        [
1>            T=void (__cdecl &)(void)
1>        ]
1>        ..\..\libs\boost\boost/python/converter/registered.hpp(105) :
while compiling class template static data member 'const
boost::python::converter::registration
&boost::python::converter::detail::registered_base<T>::converters'
1>        with
1>        [
1>            T=void (__cdecl &)(void)
1>        ]
1>        ..\..\libs\boost\boost/python/converter/registered.hpp(44) : see
reference to class template instantiation
'boost::python::converter::detail::registered_base<T>' being compiled
1>        with
1>        [
1>            T=void (__cdecl &)(void)
1>        ]
1>        ..\..\libs\boost\boost/python/converter/registered_pointee.hpp(27)
: see reference to class template instantiation
'boost::python::converter::registered<T>' being compiled
1>        with
1>        [
1>            T=void (void)
1>        ]
1>        ..\..\libs\boost\boost/python/converter/arg_from_python.hpp(269) :
see reference to class template instantiation
'boost::python::converter::registered_pointee<T>' being compiled
1>        with
1>        [
1>            T=void (__cdecl *)(void)
1>        ]
1>        ..\..\libs\boost\boost/python/converter/arg_from_python.hpp(268) :
while compiling class template member function
'boost::python::converter::pointer_arg_from_python<T>::pointer_arg_from_python(PyObject
*)'
1>        with
1>        [
1>            T=void (__cdecl *)(void)
1>        ]

Could someone tell me how i can do that please ?
Thank you

William
-- 
View this message in context: http://www.nabble.com/How-to-wrap-a-python-function-pointer---tp19028640p19028640.html
Sent from the Python - c++-sig mailing list archive at Nabble.com.




More information about the Cplusplus-sig mailing list