module GLib::ListMethods
Attributes
element_type[R]
Public Class Methods
included(base)
click to toggle source
# File lib/ffi-glib/list_methods.rb, line 11 def self.included(base) # Override default field accessors. replace_method base, :next, :tail replace_method base, :data, :head base.extend ContainerClassMethods base.extend ClassMethods end
new(type)
click to toggle source
# File lib/ffi-glib/list_methods.rb, line 27 def initialize(type) store_pointer(FFI::Pointer.new(0)) @element_type = type end
replace_method(base, old, new)
click to toggle source
# File lib/ffi-glib/list_methods.rb, line 20 def self.replace_method(base, old, new) base.class_eval do remove_method old alias_method old, new end end
Public Instance Methods
==(other)
click to toggle source
# File lib/ffi-glib/list_methods.rb, line 56 def ==(other) to_a == other.to_a end
each() { |elem| ... }
click to toggle source
# File lib/ffi-glib/list_methods.rb, line 32 def each reset_iterator while (elem = next_element) yield elem end end
head()
click to toggle source
# File lib/ffi-glib/list_methods.rb, line 45 def head return nil if struct.null? GirFFI::ArgHelper.cast_from_pointer(element_type, struct[:data]) end
reset_typespec(typespec)
click to toggle source
# File lib/ffi-glib/list_methods.rb, line 51 def reset_typespec(typespec) @element_type = typespec self end
tail()
click to toggle source
# File lib/ffi-glib/list_methods.rb, line 39 def tail return nil if struct.null? self.class.wrap(element_type, struct[:next]) end
Private Instance Methods
element_ptr_for(data)
click to toggle source
# File lib/ffi-glib/list_methods.rb, line 74 def element_ptr_for(data) GirFFI::InPointer.from(element_type, data) end
next_element()
click to toggle source
# File lib/ffi-glib/list_methods.rb, line 66 def next_element return unless @current element = @current.head @current = @current.tail element end
reset_iterator()
click to toggle source
# File lib/ffi-glib/list_methods.rb, line 62 def reset_iterator @current = self end