[C++-sig] Boost Python: C++ struct with a function pointer
puneet goel
p_goel at coverify.net
Wed Mar 3 03:18:36 CET 2010
Mathew/Jim
> If you just need your Python interface to support calling those function
> pointers, not adding new functions in Python, it's relatively easy.
Thanks for your support.
Actually I need to pass data from Python to C++. I am required to
pass Python functions as part of the structure in a way that these get
executed somewhere in C++.
Now that I know that this can not be done in a straightforward manner,
I am looking for a workaround. I would like to know whether it is at
all possible to pass a Python function, as data, to C++ using
boost-python. What would be the C++ type of a structure element that
would be able to hold a Python function when passed using
boost-python?
To clarify, if I get the C++ API changed to something like
struct foo {
public:
int a, b;
char *str;
foobar func1;
foobar func2;
};
What type (in C++) would foobar be so that I am able to pass a python
function for func1 and func2?
Regards
- Puneet
More information about the Cplusplus-sig
mailing list