codegen: cast instead of trying to guess *_CLASS macro name

Fixes bug 732413