[Python] Expose c++ instances to python
Hello. I'm trying to embed python to an application. I did that with success and I'm using boost.python to make some bindings to my API. What I would like, is that the interpreter has access to my objects at runtime, namely, I don't want to create objects from python code but to use the c++ objects, created in my c++ application, from python (and I have wrappers for those in boost.python). I don't know how to achieve this. I just know how to wrap classes, but I have no idea how to expose instances. Any idea how to achieve this? I googled and found nothing clear. Thanks in advance.
On Wed, Feb 4, 2009 at 12:19 PM, Germán Diago
Hello. I'm trying to embed python to an application. I did that with success and I'm using boost.python to make some bindings to my API.
What I would like, is that the interpreter has access to my objects at runtime, namely, I don't want to create objects from python code but to use the c++ objects, created in my c++ application, from python (and I have wrappers for those in boost.python).
If you're not limited to using Python, Lua has a very flexible binding system. It has a userdata type that can be made to access C/C++ data members or functions. Emil Dotchevski Reverge Studios, Inc. http://www.revergestudios.com/reblog/index.php?n=ReCode
2009/2/5 Emil Dotchevski
On Wed, Feb 4, 2009 at 12:19 PM, Germán Diago
wrote: Hello. I'm trying to embed python to an application. I did that with success and I'm using boost.python to make some bindings to my API.
What I would like, is that the interpreter has access to my objects at runtime, namely, I don't want to create objects from python code but to use the c++ objects, created in my c++ application, from python (and I have wrappers for those in boost.python).
If you're not limited to using Python, Lua has a very flexible binding system. It has a userdata type that can be made to access C/C++ data members or functions.
I've used python because there is boost.python for it. And, by the way, I managed to make it work :-). Now I can access my objects. It was not very difficult. And very useful. Anyway, thanks for the piece of advice, I also considered lua some time ago.
Emil Dotchevski Reverge Studios, Inc. http://www.revergestudios.com/reblog/index.php?n=ReCode _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
Emil Dotchevski
-
Germán Diago