class GLib::PtrArray
Overrides for GPtrArray, GLib's automatically growing array of pointers.
Constants
- POINTER_SIZE
Attributes
element_type[R]
Public Class Methods
add(array, data)
click to toggle source
# File lib/ffi-glib/ptr_array.rb, line 32 def self.add(array, data) array.add data end
from_enumerable(type, it)
click to toggle source
# File lib/ffi-glib/ptr_array.rb, line 28 def self.from_enumerable(type, it) new(type).tap { |arr| arr.add_array it } end
new(type)
click to toggle source
# File lib/ffi-glib/ptr_array.rb, line 23 def initialize(type) @element_type = type store_pointer Lib.g_ptr_array_new end
Public Instance Methods
==(other)
click to toggle source
# File lib/ffi-glib/ptr_array.rb, line 68 def ==(other) to_a == other.to_a end
add(data)
click to toggle source
# File lib/ffi-glib/ptr_array.rb, line 41 def add(data) ptr = GirFFI::InPointer.from element_type, data Lib.g_ptr_array_add self, ptr end
add_array(ary)
click to toggle source
# File lib/ffi-glib/ptr_array.rb, line 46 def add_array(ary) ary.each { |item| add item } end
data_ptr()
click to toggle source
# File lib/ffi-glib/ptr_array.rb, line 50 def data_ptr @struct[:pdata] end
each() { |index(idx)| ... }
click to toggle source
# File lib/ffi-glib/ptr_array.rb, line 58 def each length.times do |idx| yield index(idx) end end
element_size()
click to toggle source
# File lib/ffi-glib/ptr_array.rb, line 54 def element_size POINTER_SIZE end
length()
click to toggle source
# File lib/ffi-glib/ptr_array.rb, line 64 def length @struct[:len] end
reset_typespec(typespec)
click to toggle source
# File lib/ffi-glib/ptr_array.rb, line 36 def reset_typespec(typespec) @element_type = typespec self end