module FFI::Library
def enum(*args)
-
(FFI::Enum)
-
Parameters:
-
values
(Array
) -- values for enum -
args
() -- values for enum
-
values
(Array
) -- values for enum -
name
(Symbol
) -- name for new enum
Overloads:
-
enum(values)
-
enum(*args)
-
enum(name, values)
def enum(*args) 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 = FFI::Enum.new(values, name)) # If called as enum :foo, [ :zero, :one, :two ], add a typedef alias typedef(e, name) if name e end