Sha256: fdd95dc3d80bf12b7bf5b4610cc2c176783f005b696df7fb4fea30b3aa77c5a4

Contents?: true

Size: 946 Bytes

Versions: 4

Compression:

Stored size: 946 Bytes

Contents

# frozen_string_literal: true
GLib.load_class :Variant

module GLib
  # Overrides for GVariant, GLib's variant data type.
  class Variant
    setup_instance_method 'get_string'

    def get_string_with_override
      get_string_without_override.first
    end

    alias_method :get_string_without_override, :get_string
    alias_method :get_string, :get_string_with_override

    # Initializing method used in constructors. For Variant, this needs to sink
    # the variant's floating reference.
    #
    # NOTE: This is very hard to test since it is not possible to get the
    # variant's ref count directely. However, there is an error when running
    # the tests on 32-bit systems.
    # TODO: Move this logic elsewhere
    def store_pointer(ptr)
      super

      # TODO: Ensure ptr is not autorelease
      ::GLib::Lib.g_variant_ref_sink ptr
    end

    # TODO: Update ref?
    def self.wrap_copy(val)
      wrap(val)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
gir_ffi-0.10.2 lib/ffi-glib/variant.rb
gir_ffi-0.10.1 lib/ffi-glib/variant.rb
gir_ffi-0.10.0 lib/ffi-glib/variant.rb
gir_ffi-0.10.0.pre1 lib/ffi-glib/variant.rb