generator: separate enum generation from functions
generator: add more write rules to generator
generator: refactor DGenerator into Generator