enum io_mode -> io_mode_t; make io_data_t::io_mode typed
Use new IO_INVALID as default value of io_data_t::io_mode
Let io_data_t constructor take optional io_mode
Make io_data_t destructor virtual
Introduce a macro cast_init to abbreviate common static_cast's a bit

This macro doesn't work with type names containing commas, but that doesn't
seem to be too common in fish.