src: centralize class wrap/unwrap

While almost all cases were handled by simple WRAP/UNWRAP macros, this
extends those to cover all known occurrences.