" /> Richard Hult: August 2008 Archives

« July 2008 | Main | September 2008 »

August 13, 2008

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!