Class: GirFFI::InPointer

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

Overview

The InPointer class handles conversion from ruby types to pointers for arguments with direction :in. This is used for arguments that are arrays, strings, or interfaces.

Class Method Summary collapse

Class Method Details

.from(type, val) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/gir_ffi/in_pointer.rb', line 26

def self.from type, val
  return if !val
  case type
  when :utf8, :filename
    from_utf8 val
  when :gint32, :guint32, :gint8
    self.new val
  when Module
    self.new type[val]
  when :void
    ArgHelper.object_to_inptr val
  else
    raise NotImplementedError, type
  end
end

.from_array(type, ary) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/gir_ffi/in_pointer.rb', line 6

def self.from_array type, ary
  return if !ary
  case type
  when :utf8, :filename
    from_utf8_array ary
  when :gboolean
    from_boolean_array ary
  when Symbol
    from_basic_type_array type, ary
  when Class
    from_struct_array type, ary
  when Module
    from_enum_array type, ary
  when Array
    from_interface_pointer_array ary
  else
    raise NotImplementedError, type
  end
end