Sha256: 438cb28ed4941894e4d8d24dbe73244ccb865aa9ecf4422076347bdf8a35893f

Contents?: true

Size: 631 Bytes

Versions: 10

Compression:

Stored size: 631 Bytes

Contents

module GirFFI
  module FFIExt
    # Extensions to FFI::Pointer
    module Pointer
      def to_ptr
        self
      end

      def to_value
        self
      end

      def zero?
        null?
      end

      # FIXME: Should probably not be here.
      def to_object
        return nil if self.null?
        gtype = GObject.type_from_instance_pointer self
        Builder.build_by_gtype(gtype).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

10 entries across 10 versions & 1 rubygems

Version Path
gir_ffi-0.9.0 lib/gir_ffi/ffi_ext/pointer.rb
gir_ffi-0.8.6 lib/gir_ffi/ffi_ext/pointer.rb
gir_ffi-0.8.5 lib/gir_ffi/ffi_ext/pointer.rb
gir_ffi-0.8.4 lib/gir_ffi/ffi_ext/pointer.rb
gir_ffi-0.8.3 lib/gir_ffi/ffi_ext/pointer.rb
gir_ffi-0.8.2 lib/gir_ffi/ffi_ext/pointer.rb
gir_ffi-0.8.1 lib/gir_ffi/ffi_ext/pointer.rb
gir_ffi-0.8.0 lib/gir_ffi/ffi_ext/pointer.rb
gir_ffi-0.7.10 lib/gir_ffi/ffi_ext/pointer.rb
gir_ffi-0.7.9 lib/gir_ffi/ffi_ext/pointer.rb