Replace codegen with DRY static code.

This should make building on windows possible without mingw/cygwin/msys.