SWFProcessing.SWFModeller.ABCDataTypeReader.ReadU30 C# (CSharp) Method

ReadU30() public method

Reads an aligned 30-bit unsigned integer. The top two bits will be 0. See ReadEncodedU32 for a 32-bit version. This belongs in the ABC spec; 32-bit values belong in the SWF spec.
public ReadU30 ( ) : uint
return uint
        public uint ReadU30()
        {
            uint v = this.ReadUI32();

            uint top3 = (v & 0xE0000000);

            /* The type is meant to be unsigned, but it's used in signed values anyway.
             * Oh flash, you decrepit weirdo. This means that the top 3 bits here must either all
             * be 0s, or all 1s. */

            /* It does seem that if the top-30th bit is set, then the next 2 top bits will also
             * be set. */
            if (top3 != 0 && top3 != 0xE0000000)
            {
                throw new SWFModellerException(
                        SWFModellerError.ABCParsing,
                        "Value validation error: 32-bit number is too large for 30-bit value.");
            }

            return v;
        }