123456789_123456789_123456789_123456789_123456789_

Module: Fiddle::FFIBackend

Relationships & Source Files
Defined in: ext/fiddle/lib/fiddle/ffi_backend.rb

Constant Summary

Class Method Summary

Class Method Details

.to_ffi_type(fiddle_type)

Raises:

  • (TypeError)
[ GitHub ]

  
# File 'ext/fiddle/lib/fiddle/ffi_backend.rb', line 107

def self.to_ffi_type(fiddle_type)
  if fiddle_type.is_a?(Symbol)
    fiddle_type = Types.const_get(fiddle_type.to_s.upcase)
  end
  if !fiddle_type.is_a?(Integer) && fiddle_type.respond_to?(:to_int)
    fiddle_type = fiddle_type.to_int
  end
  ffi_type = FFITypes[fiddle_type]
  ffi_type = FFITypes[-fiddle_type] if ffi_type.nil? && fiddle_type.is_a?(Integer) && fiddle_type < 0
  raise TypeError.new("cannot convert #{fiddle_type} to ffi") unless ffi_type
  ffi_type
end