Module: FFI::DataConverter

Included in:
AutoPointer, Enum, StrPtrConverter, StructByReference
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/ffi-1.15.5/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 overriden.

Instance Method Summary collapse

Instance Method Details

#from_native(value, ctx) ⇒ Object

Convert from a native type.



63
64
65
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/ffi-1.15.5/lib/ffi/data_converter.rb', line 63

def from_native(value, ctx)
  value
end

#native_type(type) ⇒ Type #native_typeObject

Get native type.

Overloads:

  • #native_type(type) ⇒ Type

    Get native type from type.

    Parameters:

    Returns:

    • (Type)
  • #native_typeObject

    Raises:

    • (NotImplementedError)

      This method must be overriden.



45
46
47
48
49
50
51
52
53
54
55
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/ffi-1.15.5/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) ⇒ Object

Convert to a native type.



58
59
60
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/ffi-1.15.5/lib/ffi/data_converter.rb', line 58

def to_native(value, ctx)
  value
end