Split wrapper.rs into modules.

 * and refactor codegen.py