ffi-bit_masks

FFI plugin which adds support for bit-wise fields (or flags) to FFI.

MIT License

Downloads
172.5K
Stars
8
Committers
2

ffi-bit_masks

Description

FFI plugin which adds support for bitmasked types (or flags) to FFI.

Features

  • Can map a Hash of flags to their bitmask value.
  • Can map an Integer bitmask to a Hash of flags.

Examples

require 'ffi/bit_masks'

module MyLibrary
  extend FFI::Library

  ffi_lib 'foo'

  bit_mask :flags, {foo: 0x1, bar: 0x2, baz: 0x4}

  attach_function :my_func, [:pointer, :size_t, :flags], :int
end

Requirements

Install

$ gem install ffi-bit_masks

Copyright

Copyright (c) 2012-2013 Hal Brodigan

See {file:LICENSE.txt} for details.

Package Rankings
Top 11.09% on Rubygems.org