Sha256: 5c7b0b7b1264e58f80160fb6127e390a4bfd3f665f547a821bfe536b121ab890

Contents?: true

Size: 603 Bytes

Versions: 1

Compression:

Stored size: 603 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

      def to_utf8
        null? ? nil : read_string.force_encoding("utf-8")
      end
    end
  end
end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gir_ffi-0.7.3 lib/gir_ffi/ffi_ext/pointer.rb