SIP backend proof of concept
Here's some proof of concept on a SIP backend code generator for Ogre Python code bindings.
The bindings include pretty much everything in OgreMain.dll minus a few things that need hand wrappers. pygccxml is used to parse the Ogre header files and a utility called "AutoSIP" that I quickly wrote generates the SIP interface files.
A few things of note:
1. The wrapper code is generated in less than 1 minute
2. The wrappers compile in less than 1 minute
3. There is no dependency on Boost::Python or extreme use of templates
4. The release binary is 1.6 megabytes
5. Subclassing in Python for any class which implements a virtual function is supported
6. Class operators are supported
7. SIP is used to generate the PyQT wrappers. The resultant code is very tight...
8. The wrapper code is much easier to debug at the C++ level (no obfuscated templates!)
I put up the generated SIP interface file, the generated wrapper code, and a quick hacky test.py with the PyQT interface here:
The included test.py renders into a PyQT GL widget and works rather nicely... I have less than 8 hours of work into this: pygccxml + SIP really compliment one another...
Looks interesting -- I'm certainly not 'married' to boost, it is the most complete wrapper support that I've seen -- however I'll take a look at SIP to see what it can do
Can you post a copy of the sip file generator for me to look at (or email it to me directly)
I'll email it to you when I get into the office.
SIP is very nice... and beats the pants off of SWIG for generating Python wrappers. The wrappers are solely C++ based, whereas SWIG generates Python and C++ wrappers making its binding a tad slow and very hard to debug.
The PyQT wrappers (for which SIP was originally written) are some of the best around. The author also uses GCC-XML to automatically generate the SIP interface files, which are really just C++ header files with some additional directives. So, already familiar
You can send it to me via andy at python-ogre.org.
I would also suggest putting your project up on sourceforge if it proves to be valuable.
There is another python wrapping project which generates Python-C code directly but its a pain to use because you have to write so much python code to wrap a class. If that guy had an example of how to use pygccxml he would be able to implement his system quickly, and the usage of his system would go up dramatically.
I should also say, one of the things that Boost.Python does so well are the corner cases. As in the hard to wrap areas. Take a look at the special cases Andy handles in our code and see if SIP makes those any easier or harder. Not to mention its awesome C++ Python API.
As GameEnder points out it's the corner cases - or the last 10% that is where all the fun happens (this is the case in all software development).
The initial proof of concept for Ogre and Py++ (using boost) was only a days work, and yet here we are nearly 18 months later and still occasionally tweaking things
There is no doubt that SIP is a cool tool, and I'm taking a good look at it, however it's very unlikely that we would change the back end for Python-Ogre any time soon (as I simply will not go backwards in functionality just to save a few megs of memory usage)
Interesting reading on this can be found at:
"just to save a few megs of memory usage"
There's quite a bit more to it than this...
Josh, not sure if you saw my email, however can you email me the string.sip file.
Also I don't want to turn this into a Boost vs SIP discussion -- there are plenty of other places on the net where this has been discussed. As stated I will look at SIP further...
Actually, there is practically no discussion regarding Py++ generated Python::Boost wrappers vs. SIP generated wrappers... much less on large scale codebases.
I sent the string.sip from my office the other day. Did you not receive it?
No I didn't get it -- just your original email (the generator)..