[C++-sig] How to wrap function pointer in python?
David Abrahams
dave at boost-consulting.com
Tue Mar 18 15:11:50 CET 2003
Zhang Le <ejoy at peoplemail.com.cn> writes:
> Hi all,
> I just want to wrap a C++ function which takes a C++ function
> pointer as paramater. Then I think I can write callback function in python.
>
> In C++(part of source code):
> typedef boost::function<void (string s) > FUNC_TYPE;
>
> void foo(FUNC_TYPE fp)
> {
> fp("hello,world!");
> }
>
> BOOST_PYTHON_MODULE(test)
> {
> def("foo",foo) ;
> }
>
> In python I would like to write
> def hello(s):
> print s
> foo(hello)
What you're trying to do isn't possible, for Boost.Python or any other
wrapping system other than *possibly* something like weave which
recompiles C++ code on the fly during execution. See
http://aspn.activestate.com/ASPN/Mail/Message/1554837 for more
details.
--
Dave Abrahams
Boost Consulting
www.boost-consulting.com
More information about the Cplusplus-sig
mailing list