code generation for Python/C++11 binding

Started by
1 comment, last by doeme 12 years, 1 month ago
I am looking for a way to automatically generate the code to expose c++ classes and objects to python. Currently I am using the Py++ (http://sourceforge.n...ojects/pygccxml) package which works fairly well to generate boost::python wrappers. Unfortunately GCCXML is no longer actively maintained and it lacks support for a lot if not all c++11 features.
Are there any other tools out there for generating Python bindings? Since the code base is already quite large writing the wrappers by hand is not really an option as this would be extremly tedious to maintain.

While boost::python is not mandatory it would be nice if I could keep it for the binding, as I quite like it.
Advertisement
Boost python already generates the binding code automatically, based on the function and class names you give it. Or are you asking for something that will parse your source and automatically generate the boost python code for everything? If so, you're unlikely to find something that works in all cases, because doing so would require it to read your mind in order to handle pointer ownership correctly. Also, C++ is notoriously difficult to parse anyway.
I trust exceptions about as far as I can throw them.

Or are you asking for something that will parse your source and automatically generate the boost python code for everything? If so, you're unlikely to find something that works in all cases, because doing so would require it to read your mind in order to handle pointer ownership correctly. Also, C++ is notoriously difficult to parse anyway.


That is exactly what I am looking for. As I wrote above, I have a working solution for it (Py++/GCCXML), but it does not understand C++11 and some of the nice language-features of it. The parsing of the code is done by GCCXML which is a regular Gcc which "compiles" to XML instead of binary, but unfortunately it is not maintained anymore.

Of course the ownership is a bit of a problem, but I kind of solve it by stating that python is not allowed to own any objects at all and that python-exposed objects they need to be constructed over a factory-method with an explicit owner supplied. Not the nicest way, but pretty safe IMO.

This topic is closed to new replies.

Advertisement