Improvements to gmmproc

Date: November 27th, 2006 by Author: Daniel Elstner

The project I’m currently working on required me to make some improvements to gmmproc, the code generator used by the gtkmm project. In my current work it’s occassionally necessary to wrap enumerations that don’t follow the consistent naming scheme of GTK+ we take for granted nowadays. This is how the enumerations look like:

  • FOO_THIS,
  • BAR_THAT,
  • FUZZ_THERE

That should of course be:

  • MODULENAME_FOO_THIS,
  • MODULENAME_BAR_THAT,
  • MODULENAME_FUZZ_THERE

Ideally, this would prompt a patch to the upstream code. But it’s not always possible to change upstream API, and even if it is you sometimes just don’t have the time for the bureaucracy involved and only want to get your code to compile for now.

But the code generator didn’t like the idea at all. The Perl script that gathers the enumeration definitions from the C header files even went into an infinite loop. I fixed that, but then it turned out that the enumeration parsing module of gmmproc unconditionally stripped everything up to and including the first underscore in every enumeration constant. The result looked like this:

  • THIS,
  • THAT,
  • THERE

Ugh. Well, this prompted me to change the behavior of the enumeration parser to only strip the prefix if it’s actually common to all constants defined in an enumeration. It’s been a long time since I last dipped my feet into Perl, but it seems to work now. The new code is available from glibmm CVS, including the earlier branches from glibmm-2-8 onwards. I do hope it doesn’t break anything.

In order to actually prefix the enumeration constants in the C++ code, you can use something like this:

  • _WRAP_ENUM(SomeType, ModuleSomeType, , s#^\b#MODULE_#)

You could even give the C++ constants the same names as in C, which would in many situations be the most appropriate scheme since we use namespaces instead of module prefixes in C++. The resulting shadowing could lead to problems though if C and C++ code is mixed. Your mileage may vary.

Microsoft Firefox

Date: November 19th, 2006 by Author: Daniel Elstner

I really couldn’t resist posting this; it’s just hilarious: Get Microsoft Firefox now! Especially don’t miss their promotion video. Have fun! :-D

Exams Half-time

Date: November 6th, 2006 by Author: Daniel Elstner

So, I’m now about halfway through this term’s written exams. So far I have sat the exams in both of my major subjects, Math and History, and of the minor ones in German and Physics. The topic for Math was linear algebra, and the History exam was about the peculiarities of the German development and attitude around the first world war and beyond (Deutscher Sonderweg). What’s left is English, Political Science, Computer Science — that’s a laugh — and the second round of my two major subjects.

I already got the results back for Math — 12 points out of 15 —, and History — 15 out of 15! Looks like I’m on a run of luck there. Mind you, with results like that, exams can even be fun. I literally inquired my teacher whether she was trying to kid me when the results of History were handed back to us. And I eagerly await the results of the German exam, where I wrote in a cock-sure manner about matters I hardly have a clue about. The task was to discuss Georg Büchner’s understanding of art. Will she notice? :-)

Today I sat the exam in Physics, which went fairly well given my frequent absence during the first couple of weeks after the last holiday. Yesterday I had to teach myself the basics of quantum physics (discovery of the photoelectric effect). Luckily we were given ample time to explain this one.

Still, this were all just this term’s exams. The big showdown will be next year around Easter, with the Abitur finals.