Sha256: e4b73ac3c912fb0a69df04f34db7786d71c47c9887022d5898728ddabeefb602

Contents?: true

Size: 587 Bytes

Versions: 3

Compression:

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

      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

3 entries across 3 versions & 1 rubygems

Version Path
gir_ffi-0.7.7 lib/gir_ffi/ffi_ext/pointer.rb
gir_ffi-0.7.6 lib/gir_ffi/ffi_ext/pointer.rb
gir_ffi-0.7.5 lib/gir_ffi/ffi_ext/pointer.rb