Translator listener cleanup
I. Remove unused Listener::trampoline
II. Add Translator::add_listener to simplify macro
In isolation, this doesn't look like much of a simplification, but it simplifies experimenting with variations on the ADD_LISTENER macro
III. Remove class name from ADD_LISTENER_FOR etc.
Define a private type alias self_type
in TRANSLATOR_DECLARATIONS to make the type of the translator generically available in static methods, where decltype(*this) is not an option.
Several macros will no longer require repeating the class name as a macro argument. In this commit, only these less-used macros are changed to take advantage of this:
- ADD_ACKNOWLEDGER_FOR
- ADD_END_ACKNOWLEDGER_FOR
- ADD_LISTENER_FOR
These are also changed not to prepend text (e.g. "listen_") to the provided function names. It makes sense for the short forms (e.g. ADD_LISTENER) to do that, but it makes these less flexible and less clear. Compare:
ADD_LISTENER_FOR(slur, phrasing_slur) // listen for both? no
ADD_LISTENER_FOR(listen_slur, phrasing_slur) // I see: method, event
IV. Remove class name from ADD_LISTENER etc.
These macros no longer require the class name as an argument. Changes to translator.icc are manual. The rest is a search & replace with this sed script:
s/(ADD_ACKNOWLEDGER|ADD_END_ACKNOWLEDGER|ADD_LISTENER) \([^,]+, +/\1 (/g