genlib/fsm: rename {entering,leaving} to after_{entering,leaving}, add before_{entering,leaving}