Use the correct storage type for converting enums and flags

Previously, we always simply interpreted enum and flags values as being of type
"long".  Depending on the permissible values and on the platform, the actual
type used by the compiler might differ from that, however.  This caused no
immediate problems on little-endian systems, but led to issues on big-endian
systems.

https://rt.cpan.org/Ticket/Display.html?id=98463