Sha256: 69d2945a70a251bbf78d529ce9c2215f0e7366f4d708225cb2880d6de3dff9ca

Contents?: true

Size: 981 Bytes

Versions: 9

Compression:

Stored size: 981 Bytes

Contents

# frozen_string_literal: true
module GirFFI
  # Represents a signal not found in the GIR, conforming, as needed, to the
  # interface of GObjectIntrospection::ISignalInfo.
  class UnintrospectableSignalInfo
    attr_reader :signal_id

    def initialize(signal_id)
      @signal_id = signal_id
    end

    def name
      GObject.signal_name signal_id
    end

    def wrap_in_closure(&block)
      GObject::RubyClosure.new(&block)
    end

    def arguments_to_gvalues(instance, arguments)
      param_gtypes = signal_query.param_types || []

      argument_gvalues = param_gtypes.zip(arguments).map do |gtype, arg|
        GObject::Value.for_gtype(gtype).tap { |it| it.set_value arg }
      end

      argument_gvalues.unshift GObject::Value.wrap_instance(instance)
    end

    def gvalue_for_return_value
      GObject::Value.for_gtype signal_query.return_type
    end

    private

    def signal_query
      @signal_query ||= GObject.signal_query signal_id
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
gir_ffi-0.11.1 lib/gir_ffi/unintrospectable_signal_info.rb
gir_ffi-0.11.0 lib/gir_ffi/unintrospectable_signal_info.rb
gir_ffi-0.10.2 lib/gir_ffi/unintrospectable_signal_info.rb
gir_ffi-0.10.1 lib/gir_ffi/unintrospectable_signal_info.rb
gir_ffi-0.10.0 lib/gir_ffi/unintrospectable_signal_info.rb
gir_ffi-0.10.0.pre1 lib/gir_ffi/unintrospectable_signal_info.rb
gir_ffi-0.9.5 lib/gir_ffi/unintrospectable_signal_info.rb
gir_ffi-0.9.4 lib/gir_ffi/unintrospectable_signal_info.rb
gir_ffi-0.9.3 lib/gir_ffi/unintrospectable_signal_info.rb