On 06/23/2009 04:03 PM, Christopher Schramm wrote:
Stefan Seefeld wrote:
I read your original mail, but I didn't understand what you are trying
to achieve. You certainly can export functions to python:
void foo(...);
...
bpl::def("foo", foo);
works just fine. There shouldn't be any need to wrap the function in a
class (member function), and then create some hidden object to invoke
it. Or am I misunderstanding what you want ?
The problem is, I'm not writing a module that shall be imported, but I'm
embedding Python and want to provide a special "built in" module so the
final result is a single monolithic binary internally starting the
interpreter, creating the module and running user defined scripts.
I don't see how this affects what you export to Python.
Since boost::python's def function has a return type of void (sure,
because there seems to be no type for python functions in bpy),
functions can only be exported within a BOOST_PYTHON_MODULE (which I
don't have) or when belonging to a class (which led to my workaround).
You need a module into which to inject the symbols you export. That is
true no matter the (meta)type of what you export, i.e. classes,
functions, etc.
Once you have that module set up (via BOOST_PYTHON_MODULE), you can
instantiate the newly created Python objects (types) from within C++
code, without having to go through the interpreter, import, eval, or exec.
Regards,
Stefan
--
...ich hab' noch einen Koffer in Berlin...
_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig