Behdad Esfahbod's daily notes on GNOME, Pango, Fedora, Persian Computing, Bob Dylan, and Dan Bern!

My Photo
Location: Toronto, Ontario, Canada

Ask Google.

Contact info
Hacker Emblem Become a Friend of GNOME I Power Blogger
follow me on Twitter
July 2003
August 2003
October 2003
November 2003
December 2003
March 2004
April 2004
May 2004
July 2004
August 2004
September 2004
November 2004
March 2005
April 2005
May 2005
June 2005
July 2005
August 2005
September 2005
October 2005
November 2005
December 2005
January 2006
February 2006
March 2006
April 2006
May 2006
June 2006
July 2006
August 2006
September 2006
October 2006
November 2006
December 2006
January 2007
February 2007
March 2007
April 2007
May 2007
June 2007
July 2007
August 2007
September 2007
October 2007
November 2007
December 2007
January 2008
February 2008
March 2008
April 2008
May 2008
June 2008
July 2008
August 2008
October 2008
November 2008
December 2008
January 2009
March 2009
April 2009
May 2009
June 2009
July 2009
August 2009
November 2009
December 2009
March 2010
April 2010
May 2010
June 2010
July 2010
October 2010
November 2010
April 2011
May 2011
August 2011
September 2011
October 2011
November 2011
November 2012
June 2013
January 2014
May 2015
Current Posts
McEs, A Hacker Life
Monday, April 23, 2007
 Cost of Code Refactoring

In cairo we had a little problem since the early days and I thought I may as well fix it in a Thursday afternoon this past week. Or did I?

The problem was that to test that certain features are working as expected, we need to be able to force those features on/off from the test suite. The features involved are such things as communicating with an X server without the Render extension, or forcing image fallbacks in PS/PDF/SVG backends. So the way we were doing this was having functions exported in the shared library with names like _cairo_*_test_*(). Apparently that's less than elegant.

There were two options: 1) to make them only available in "debug" builds, or 2) to move those functions out to a separate shared library used just for testing. First option was not that compelling as it forces some tests turned off in production builds, so I took the second approach. We already have this library that is a set of routines used by the test and performance suites. So it was perfect place to move those functions. The catch was: the new functions needed to somehow reach into cairo's internals. Something that cairo users should not be able to do. My solution to this was to use cairo's private header files to tweak certain values inside cairo objects. Clean enough: no global variables, no extra symbols exported in

So it was basically just moving code around: from cairo/src/ into cairo/boilerplate. But to do that I needed to move certain struct definitions from C source files to header files. While at that, I also decided that it makes a lot more sense if I break cairo-boilerplate.c into backend-specific files. Something that we had planned to do for some time anyway, for good reason. So now I had to break boilerplate into about 9 pieces, move some structs from source files to headers, move some functions from src/ into boilerplate/, and finally update tests to adapt to the new APIs.

What looks like simple enough mud work turned out to be a marathon taking well over 12 hours of intense typing. Renaming symbols to have proper prefix, typing lots of files names like cairo-boilerplate-xlib-private.h, adding those new files to, and to git, populating header files, and making sure the build doesn't break at any time is no small thing.

The result? Not less than 51 commits. Add to that the mutex cleanups I did Thursday morning too, and they will add up to 68. Enough said that I was so mental that in two commit logs, typed "[cairo-commit]" instead of "[cairo-mutex]". I would have had a lot more productive Thursday and Friday if people have had added those bits in the right places in the first place. But then again, that's why maintainers are... or are we?

It also meant that I was not doing what I was supposed to do during the first Toronto olpc meetup at the linuxcaffe. I still had great time. Thanks Mike, and I'll promise to be more useful next time.

Labels: , , , ,

Comments: Post a Comment

Links to this post:

Create a Link

<< Archive
<< Home