Sha256: 09d505c91ae1cb53062424e6b94f6dfa2ccd413bc7856de768ff2e9ca47eb3b0

Contents?: true

Size: 1.09 KB

Versions: 10

Compression:

Stored size: 1.09 KB

Contents

module GirFFI
  module InfoExt
    # Extensions for GObjectIntrospection::ISignalInfo needed by GirFFI
    module ISignalInfo
      # Create a signal hander closure. Wraps the given block in a custom
      # descendent of RubyClosure with a marshaller tailored for this signal.
      #
      # @param  block   The body of the signal handler
      #
      # @return [GObject::RubyClosure]  The signal handler closure, ready to be
      #                                 passed as a GClosure to C.
      def wrap_in_closure(&block)
        bldr = Builders::SignalClosureBuilder.new(self)
        bldr.build_class.new(&block)
      end

      def arguments_to_gvalues(instance, arguments)
        arg_g_values = args.map { |info| info.argument_type.make_g_value }
        arg_g_values.zip(arguments).each do |g_value, arg|
          g_value.set_value arg
        end

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

      def gvalue_for_return_value
        return_type.make_g_value
      end
    end
  end
end

GObjectIntrospection::ISignalInfo.send :include, GirFFI::InfoExt::ISignalInfo

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
gir_ffi-0.9.2 lib/gir_ffi/info_ext/i_signal_info.rb
gir_ffi-0.9.1 lib/gir_ffi/info_ext/i_signal_info.rb
gir_ffi-0.9.0 lib/gir_ffi/info_ext/i_signal_info.rb
gir_ffi-0.8.6 lib/gir_ffi/info_ext/i_signal_info.rb
gir_ffi-0.8.5 lib/gir_ffi/info_ext/i_signal_info.rb
gir_ffi-0.8.4 lib/gir_ffi/info_ext/i_signal_info.rb
gir_ffi-0.8.3 lib/gir_ffi/info_ext/i_signal_info.rb
gir_ffi-0.8.2 lib/gir_ffi/info_ext/i_signal_info.rb
gir_ffi-0.8.1 lib/gir_ffi/info_ext/i_signal_info.rb
gir_ffi-0.8.0 lib/gir_ffi/info_ext/i_signal_info.rb