module FFI::Library
def generic_enum(klass, *args)
-
args
(see #enum or #bitmask
) -- -
klass
(Class
) -- can be one of FFI::Enum or FFI::Bitmask
def generic_enum(klass, *args) native_type = args.first.kind_of?(FFI::Type) ? args.shift : nil name, values = if args[0].kind_of?(Symbol) && args[1].kind_of?(Array) [ args[0], args[1] ] elsif args[0].kind_of?(Array) [ nil, args[0] ] else [ nil, args ] end @ffi_enums = FFI::Enums.new unless defined?(@ffi_enums) @ffi_enums << (e = native_type ? klass.new(native_type, values, name) : klass.new(values, name)) # If called with a name, add a typedef alias typedef(e, name) if name e end