123456789_123456789_123456789_123456789_123456789_

Module: FFI::DataConverter

Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Extended In:
Included In:
Defined in: lib/ffi/data_converter.rb

Overview

This module is used to extend somes classes and give then a common API.

Most of methods defined here must be overridden.

Instance Method Summary

Instance Method Details

#from_native(value, ctx)

Convert from a native type.

[ GitHub ]

  
# File 'lib/ffi/data_converter.rb', line 63

def from_native(value, ctx)
  value
end

#native_type(type) ⇒ Type #native_type

Get native type.

[ GitHub ]

  
# File 'lib/ffi/data_converter.rb', line 45

def native_type(type = nil)
  if type
    @native_type = FFI.find_type(type)
  else
    native_type = @native_type
    unless native_type
      raise NotImplementedError, 'native_type method not overridden and no native_type set'
    end
    native_type
  end
end

#to_native(value, ctx)

Convert to a native type.

[ GitHub ]

  
# File 'lib/ffi/data_converter.rb', line 58

def to_native(value, ctx)
  value
end