Sha256: 1fe0dede2d786fe4b1016d1a6d0eddd3c093ec32d1bbc4703208f7af998f5a7f

Contents?: true

Size: 588 Bytes

Versions: 1

Compression:

Stored size: 588 Bytes

Contents

module GLib
  module ListMethods
    include Enumerable
    attr_accessor :element_type

    def self.included base
      base.extend ClassMethods
    end

    def each
      list = self
      rval = nil
      until list.nil?
        rval = yield GirFFI::ArgHelper.cast_from_pointer(element_type, list[:data])
        list = self.class.wrap(element_type, list[:next])
      end
      rval
    end

    module ClassMethods
      def wrap elmttype, ptr
        super(ptr).tap do |it|
          break if it.nil?
          it.element_type = elmttype
        end
      end
    end
  end
end


Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gir_ffi-0.1.0 lib/ffi-glib/list_methods.rb