Grantlee rustles on toward a release. I recently added one more example application showing the code generation opportunities it makes possible.
In the video I edit and create some Qt Properties and methods with arguments in a simple UI, fill in some additional metadata, and then generate code representing the content of the dialog. The actual code is generated with some Grantlee templates. Simple loops are used to create the properties in the dialog, and if conditions for empty argument lists or the use of the pimpl idiom.
This could potentially be a time saver for generating the boring bits when creating a new class. Beyond that though, it is language independent. The structure and grammar of the generated code comes entirely from some template code files. The output language is entirely contained in the templates, and the Context of the rendering stage describes the content of the class. That means that it can also generate python code with the same Context and the same UI. There is a strong separation and encapsulation of language structure in the templates themselves.
Use of the Qt Resource system means that additional language templates could be added and distributed as external binary resources. So potentially someone could write and ship java templates long after the initial application was deployed.
I didn’t add that myself because if I let feature-creepism take hold in the example applications, there would never be a release of Grantlee. So back to that.
Unfortunately the video is quite jumpy, but if you want to try it out for yourself:
git clone git://gitorious.org/grantlee/grantlee.git cd grantlee mkdir build && cd build cmake .. && make && make install cd ../examples/codegen mkdir build && cd build cmake .. && make && ./codegen
So who wants to turn it into a QtCreator or KDevelop plugin?