Sha256: 6cb5f48995035c1bcbdcdea0dbb7ff1eb340ae44fafc9cb1ea1388ffdb96bf49

Contents?: true

Size: 728 Bytes

Versions: 4

Compression:

Stored size: 728 Bytes

Contents

module GirFFI
  module FFIExt
    module Pointer
      def to_ptr
        self
      end

      def to_value
        self
      end

      def to_object
        gtype = GObject.type_from_instance_pointer self
        wrap_by_gtype gtype
      end

      def wrap_by_gtype gtype
        return nil if self.null?
        klass = Builder.build_by_gtype gtype
        klass.direct_wrap self
      end

      if RUBY_VERSION < "1.9"
        def to_utf8
          null? ? nil : read_string
        end
      else
        def to_utf8
          null? ? nil : read_string.force_encoding("utf-8")
        end
      end
    end
  end
end

# TODO: Move use to InPointer and InOutPointer?
FFI::Pointer.send :include, GirFFI::FFIExt::Pointer

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
gir_ffi-0.7.2 lib/gir_ffi/ffi_ext/pointer.rb
gir_ffi-0.7.1 lib/gir_ffi/ffi_ext/pointer.rb
gir_ffi-0.7.0 lib/gir_ffi/ffi_ext/pointer.rb
gir_ffi-0.6.7 lib/gir_ffi/ffi_ext/pointer.rb