class GirFFI::ArrayElementConvertor
The ArrayElementConvertor
class handles conversion from C array elements to ruby values
Attributes
Public Class Methods
Source
# File lib/gir_ffi/array_element_convertor.rb, line 9 def initialize(type, ptr) @value_type = type @pointer = ptr end
Public Instance Methods
Source
# File lib/gir_ffi/array_element_convertor.rb, line 14 def to_ruby_value bare_value = to_value case value_type when :utf8, :filename bare_value.to_utf8 when Array value_type[1].wrap bare_value when Module value_type.wrap bare_value else bare_value end end
Private Instance Methods
Source
# File lib/gir_ffi/array_element_convertor.rb, line 30 def to_value case value_ffi_type when Module value_ffi_type.get_value_from_pointer(pointer, 0) when Symbol pointer.send(:"get_#{value_ffi_type}", 0) else raise NotImplementedError end end
Source
# File lib/gir_ffi/array_element_convertor.rb, line 41 def value_ffi_type @value_ffi_type ||= TypeMap.type_specification_to_ffi_type value_type end