module FFI::Library
def enum(*args)
def enum(*args) # # enum can be called as: # enum :zero, :one, :two # unnamed enum # enum [ :zero, :one, :two ] # equivalent to above # enum :foo, [ :zero, :one, :two ] create an enum named :foo # 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