Injecting python derived C++ types at runtime in embedded environment
Hello all, I have a C++ application where I want to be able to provide the user with creating a derived python class at runtime. I basically have 3 C++ classes that I want to expose to python, and then at any time the user will be allowed to create a new custom python class derived from one of the 3 exposed classes. They will also be allowed to modify their code and run it again. Should I expose the types using the BOOST_PYTHON_MODULE macro? Or can I expose them after PyInitialize directly into the __main__ namespace? Is it possible to reevaluate the code and have it update the derived class or will I have to purge the globals in some fashion? Any help would be much appreciated. Brian Hall
Am Sa, den 10.07.2004 schrieb Brian Hall um 0:01:
Should I expose the types using the BOOST_PYTHON_MODULE macro? Or can I expose them after PyInitialize directly into the __main__ namespace? Is it possible to reevaluate the code and have it update the derived class or will I have to purge the globals in some fashion?
Boost.Python helps you a lot with making the C++ types available to Python at all. The results is a module that you can import. After having created the module, you have to make it available to the python script. Just use a normal import statement, that will work as usual. If the user provides the python script, you can prepend the statement the top, before compiling it. regards -- Ingo Soll doch jeder bleiben, wie er gerne wäre.
participants (2)
-
Brian Hall -
Ingo Luetkebohle