Module: GLib::ContainerClassMethods

Included in:
Array, HashTable, PtrArray
Defined in:
lib/ffi-glib/container_class_methods.rb

Overview

Common methods for container classes: Array, PtrArray, List, SList and HashTable.

Instance Method Summary collapse

Instance Method Details

#from(typespec = :void, it) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/ffi-glib/container_class_methods.rb', line 11

def from typespec = :void, it
  case it
  when nil
    nil
  when FFI::Pointer
    wrap typespec, it
  when self
    it.reset_typespec typespec
  else
    from_enumerable typespec, it
  end
end

#wrap(typespec, ptr) ⇒ Object



5
6
7
8
9
# File 'lib/ffi-glib/container_class_methods.rb', line 5

def wrap typespec, ptr
  super(ptr).tap do |container|
    container.reset_typespec typespec if container
  end
end