Simplifying dynamic_cast code for diagonal manipulation in the C interface.