Class: GirFFI::InOutPointer
- Inherits:
-
FFI::Pointer
- Object
- FFI::Pointer
- GirFFI::InOutPointer
- 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
-
#value_type ⇒ Object
readonly
Returns the value of attribute value_type.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(type, ptr) ⇒ InOutPointer
constructor
A new instance of InOutPointer.
-
#to_ruby_value ⇒ Object
Convert more fully to a ruby value than #to_value.
- #to_value ⇒ Object
Constructor Details
#initialize(type, ptr) ⇒ InOutPointer
Returns a new instance of InOutPointer.
9 10 11 12 |
# File 'lib/gir_ffi/in_out_pointer.rb', line 9 def initialize(type, ptr) @value_type = type super ptr end |
Instance Attribute Details
#value_type ⇒ Object (readonly)
Returns the value of attribute value_type.
7 8 9 |
# File 'lib/gir_ffi/in_out_pointer.rb', line 7 def value_type @value_type end |
Class Method Details
.allocate_new(type) ⇒ Object
40 41 42 43 44 |
# File 'lib/gir_ffi/in_out_pointer.rb', line 40 def self.allocate_new(type) ffi_type = TypeMap.type_specification_to_ffi_type type ptr = FFI::MemoryPointer.new(ffi_type) new type, ptr end |
Instance Method Details
#to_ruby_value ⇒ Object
Convert more fully to a ruby value than #to_value
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/gir_ffi/in_out_pointer.rb', line 26 def to_ruby_value = to_value case value_type when :utf8 .to_utf8 when Array value_type[1].wrap when Class value_type.wrap else end end |
#to_value ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/gir_ffi/in_out_pointer.rb', line 14 def to_value case value_ffi_type when Module value_ffi_type.get_value_from_pointer(self, 0) when Symbol send("get_#{value_ffi_type}", 0) else raise NotImplementedError end end |