IDL pre-processing

IDL pre-processor Perl script and a text/plain version.

Following up on my previous post, here is evil, nefarious scheme number 692. Sample .mozconfig:

. /cygdrive/m/configs/sm-debug.mozconfig
ac_add_options --disable-mailnews
ac_add_options --disable-composer
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/../nav-sm-debug
mkdir -p ${OBJDIR_CONFIG}
echo "
export:: idl-preprocess
\$(PERL) /cygdrive/m/ \$(XULPPFLAGS) \$(DEFINES) \$(ACDEFINES) --srcdir=\$(srcdir)
.PHONY: idl-preprocess

This allows me to take a file and create a foo.idl file from it. Two known bugs in it: foo.idl must exist before you call it via the Makefile rule above, and you really can’t risk compiling more than one build at a time over the directory must live in (lest conflicting #ifdef macros take effect).

Why, you might ask, would anyone in their right mind want to preprocess IDL? One of the big goals of IDL is to make sure your interfaces are clearly defined, and preprocessing clutters it up.

I answer: because I want to preprocess C++ and chrome files using the same flags. But I want to do it locally only, in my development tree.

Basically, I’m combining a lot of ongoing work into a “supertrunk” tree (evil, nefarious scheme number 691), which I’ll use to develop a lot of Web Forms 2 code concurrently. When I’m ready to create a patch, I’ll make a complete copy of this tree and use preprocessing (of IDL, C++ and chrome) on the copy to get rid of the code that isn’t relevant to that patch.

This also allows me to develop code which depends on other code which awaits reviews. In other words, I only create a new tree when I absolutely have to. Plus, conflicts when I update (after a checkin) become somewhat more manageable.

Note that I don’t recommend this script be checked into’s repository. One of the big reasons I wrote this IDL preprocessor was to avoid mixing up UUID’s for each change to the interface. Consider:

#casedef FOO
[scriptable, uuid(e78e4889-d21d-442b-b89f-ab757f40458d)]
[scriptable, uuid(6438d086-68a4-4938-a781-b88f674f3eb1)]

There’s no way in the world I’d want to see that in a patch for code. I use the switchdef structure so that when I go from one patch to another, I’ll ultimately get a different UUID for each patch to the same IDL file – which is perfectly reasonable. But I don’t see any reason to have code like this ifdef’d in’s repository. This is just to help me out on my local tree.