module BinData::IntFactory

def const_missing(name)

def const_missing(name)
  mappings = {
    /^Uint(\d+)be$/ => [:big,    :unsigned],
    /^Uint(\d+)le$/ => [:little, :unsigned],
    /^Int(\d+)be$/  => [:big,    :signed],
    /^Int(\d+)le$/  => [:little, :signed],
  }
  mappings.each_pair do |regex, args|
    if regex =~ name.to_s
      nbits = $1.to_i
      if nbits > 0 && (nbits % 8).zero?
        return Int.define_class(name, nbits, *args)
      end
    end
  end
  super
end