File: bit_masks.rb

package info (click to toggle)
ruby-ffi-bit-masks 0.1.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 148 kB
  • sloc: ruby: 232; makefile: 3
file content (31 lines) | stat: -rw-r--r-- 605 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
require 'ffi/bit_masks/bit_mask'
require 'ffi/bit_masks/version'

module FFI
  #
  # Adds bitmask types to FFI libraries.
  #
  module BitMasks
    #
    # Defines a new bitmask.
    #
    # @param [Symbol] name
    #   The name of the bitmask.
    #
    # @param [Hash{Symbol => Integer}] flags
    #   The flags and their masks.
    #
    # @param [Symbol] type
    #   The underlying type.
    #
    # @return [BitMask]
    #   The new bitmask.
    #
    def bit_mask(name,flags,type=:uint)
      bit_mask = BitMask.new(flags,type)

      typedef(bit_mask,name)
      return bit_mask
    end
  end
end