misc: add code generator script; regenerate compat.h; fix #21