Sha256: bcf0fb3a1d7aad0c97fd38c30ca8fbc9028125387c3811d73cfac02c7d0cf105

Contents?: true

Size: 728 Bytes

Versions: 7

Compression:

Stored size: 728 Bytes

Contents

require 'ffi-glib/list_methods'

module GLib
  load_class :List

  # Overrides for GList, GLib's doubly linked list implementation.
  class List
    include ListMethods

    class << self
      remove_method :new
    end

    def self.new type
      _real_new.tap do |it|
        struct = ffi_structure.new(FFI::Pointer.new(0))
        it.instance_variable_set :@struct, struct
        it.element_type = type
      end
    end

    def self.from_enumerable type, arr
      arr.inject(self.new type) { |lst, val|
        lst.append val }
    end

    def append data
      elm_t = element_type
      data_ptr = GirFFI::InPointer.from(elm_t, data)
      self.class.wrap(elm_t, Lib.g_list_append(self, data_ptr))
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
gir_ffi-0.4.3 lib/ffi-glib/list.rb
gir_ffi-0.4.2 lib/ffi-glib/list.rb
gir_ffi-0.4.1 lib/ffi-glib/list.rb
gir_ffi-0.4.0 lib/ffi-glib/list.rb
gir_ffi-0.3.2 lib/ffi-glib/list.rb
gir_ffi-0.3.1 lib/ffi-glib/list.rb
gir_ffi-0.3.0 lib/ffi-glib/list.rb