Overrides for GPtrArray, GLib’s automatically growing array of pointers.
# File lib/ffi-glib/ptr_array.rb, line 22 def self.add array, data array.add data end
# File lib/ffi-glib/ptr_array.rb, line 17 def self.new type wrap(Lib.g_ptr_array_new).tap {|it| it.element_type = type} end
# File lib/ffi-glib/ptr_array.rb, line 26 def add data ptr = GirFFI::InPointer.from element_type, data Lib.g_ptr_array_add self, ptr end
# File lib/ffi-glib/ptr_array.rb, line 38 def each @struct[:len].times.each do |idx| yield index(idx) end end
Re-implementation of the g_ptr_array_index macro
# File lib/ffi-glib/ptr_array.rb, line 32 def index idx sz = FFI.type_size :pointer ptr = @struct[:pdata].get_pointer(idx * sz) GirFFI::ArgHelper.cast_from_pointer(element_type, ptr) end