class FFI::Bitmask

def initialize(*args)

Parameters:
  • tag (nil, Symbol) -- name of new Bitmask
  • info (nil, Enumerable) -- symbols and bit rank for new Bitmask
  • native_type (FFI::Type) -- Native type for new Bitmask
  • tag (nil, Symbol) -- name of new Bitmask
  • info (nil, Enumerable) -- symbols and bit rank for new Bitmask

Overloads:
  • initialize(native_type, info, tag=nil)
  • initialize(info, tag=nil)
def initialize(*args)
  @native_type = args.first.kind_of?(FFI::Type) ? args.shift : Type::INT
  @signed = [Type::INT8, Type::INT16, Type::INT32, Type::INT64].include?(@native_type)
  info, @tag = *args
  @kv_map = Hash.new
  unless info.nil?
    last_cst = nil
    value = 0
    info.each do |i|
      case i
      when Symbol
        raise ArgumentError, "duplicate bitmask key" if @kv_map.has_key?(i)
        @kv_map[i] = 1 << value
        last_cst = i
        value += 1
      when Integer
        raise ArgumentError, "bitmask index should be positive" if i<0
        @kv_map[last_cst] = 1 << i
        value = i+1
      end
    end
  end
  @vk_map = @kv_map.invert
end