Jump to content
  • Advertisement
Sign in to follow this  
doeme

code generation for Python/C++11 binding

This topic is 2462 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!