Sha256: 37d711bc792a346f1a2915c73af243f37a4936b50f4dd83070e838ab79dcefe5

Contents?: true

Size: 638 Bytes

Versions: 4

Compression:

Stored size: 638 Bytes

Contents

module GLib
  # Common methods for container classes: Array, PtrArray, List, SList and
  # HashTable.
  module ContainerClassMethods
    def wrap typespec, ptr
      super(ptr).tap do |container|
        container.reset_typespec typespec if container
      end
    end

    # FIXME: Drop Ruby 1.8.7 support and make first argument optional.
    def from *args
      it, typespec = *args.reverse
      typespec ||= :void
      case it
      when nil
        nil
      when FFI::Pointer
        wrap typespec, it
      when self
        it.reset_typespec typespec
      else
        from_enumerable typespec, it
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
gir_ffi-0.7.3 lib/ffi-glib/container_class_methods.rb
gir_ffi-0.7.2 lib/ffi-glib/container_class_methods.rb
gir_ffi-0.7.1 lib/ffi-glib/container_class_methods.rb
gir_ffi-0.7.0 lib/ffi-glib/container_class_methods.rb