Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


code generation for Python/C++11 binding


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 doeme   Members   -  Reputation: 718

Like
0Likes
Like

Posted 28 February 2012 - 10:50 AM

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.

Sponsor:

#2 Storyyeller   Members   -  Reputation: 212

Like
0Likes
Like

Posted 17 March 2012 - 09:08 PM

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.

#3 doeme   Members   -  Reputation: 718

Like
0Likes
Like

Posted 19 March 2012 - 02:18 AM

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.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS