GTK+ code rewriter
I have been looking at the compiler framework llvm/clang recently in order to do automatic refactoring and code rewriting. One use case for this is to move code that does things like:
gdk_window_foo (widget->window);
to
gdk_window_foo (gtk_widget_get_window (widget));
automatically, to get code working with a sealed GTK+.
Another useful thing that can be done automatically is to change code so that only gtk/gtk.h is included, which is the recommended way, instead of many individual header files. There are more examples of things that can help developers clean up their code, such as spotting common mistakes like not chaining up in finalizers etc etc. Clang makes it quite easy to implement those ideas.
I have started working on a tool to do the accessor and header file rewriting as a first step. Please check it out and let me know if there are any issues or if you want to help out!
Comments
You almost certainly want to investigate Pork, Mozilla's automatic rewriting/refactoring tools.
Posted by: Joe | August 13, 2008 07:32 PM
@Joe, I did look at the elsa/pork/oink stuff a while ago but it was way too messy at the time to build and setup. It might be in much better shape now.
If someone wants to create a similar tool using that stack instead, that would be great too, as long as we get the tool in the end.
Posted by: Richard | August 13, 2008 08:34 PM
I suggest you take a look at coccinelle [1], it is a tool to address interface/code evolution in linux kernel. It works on C source code, so it may be used in your case. What's interesting in this soft is that you write "semantic" patch that tells what has changed and the tool find all the sites in your code where it may apply and there modify the code according to your patch.
[1] http://www.emn.fr/x-info/coccinelle/
Posted by: Christophe | August 14, 2008 12:29 PM
Having the compatibility header would be great. Requiring the latest gtk is not viable for many projects.
I wonder where such a header could be kept, so that project can pull a copy and update from time to time.
Posted by: Stefan Kost | August 14, 2008 04:04 PM
You should definitely try out and use Clang, I here it is awesome and has a friendly and supportive community ;-)
Posted by: Chris Lattner | August 15, 2008 05:45 AM