Use the mask for the GFlagsClass to compute valid values for flags passed from C
Fix #507 (closed).
GdkModifierMask can hold private values when running under X11, and when returned from GI, it causes GJS to freeze.
As per discussion GI #445, this mirrors Rust bindings
Throws an error if the mask is larger than 32 bits
Unknown flags are simply dropped when returned from C code, regardless of if they are higher than the highest mask or smaller than the highest mask. The known flags are returned to the JS code.
No unknown flags are passed to C code and an error is thrown.