Class: GirFFI::InOutPointer

Inherits:
FFI::Pointer
  • Object
show all
Defined in:
lib/gir_ffi/in_out_pointer.rb

Overview

The InOutPointer class handles conversion between ruby types and pointers for arguments with direction :inout and :out.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#value_typeObject (readonly)

Returns the value of attribute value_type.



5
6
7
# File 'lib/gir_ffi/in_out_pointer.rb', line 5

def value_type
  @value_type
end

Class Method Details

.for(type) ⇒ Object



26
27
28
29
30
31
# File 'lib/gir_ffi/in_out_pointer.rb', line 26

def self.for type
  if Array === type
    return self.new nil, *type
  end
  self.new nil, type
end

.from(type, value) ⇒ Object



33
34
35
# File 'lib/gir_ffi/in_out_pointer.rb', line 33

def self.from type, value
  self.new value, type
end

Instance Method Details

#to_valueObject



21
22
23
24
# File 'lib/gir_ffi/in_out_pointer.rb', line 21

def to_value
  value = self.send "get_#{@ffi_type}", 0
  adjust_value_out value
end