<commit_before>require 'gir_ffi/return_value_info'
require 'gir_ffi/builders/base_type_builder'
require 'gir_ffi/builders/mapping_method_builder'
require 'gir_ffi/signal_base'

module GirFFI
  module Builders
    # Implements the creation of a signal module for handling a particular
    # signal. The type will be attached to the appropriate class.
    class SignalBuilder < BaseTypeBuilder
      class SignalReceiverTypeInfo
        include InfoExt::ITypeInfo

        def initialize interface_info
          @interface_info = interface_info
        end

        def interface
          @interface_info
        end

        def tag
          :interface
        end
      end

      class SignalReceiverArgumentInfo < ReturnValueInfo
        def closure
          -1
        end
      end

      class UserDataTypeInfo
        include InfoExt::ITypeInfo

        def tag
          :void
        end

        def pointer?
          true
        end
      end

      class UserDataArgumentInfo < ReturnValueInfo
        attr_reader :closure

        def initialize type, position
          super type
          @closure = position
        end
      end

      def instantiate_class
        unless already_set_up
          klass.extend SignalBase
          setup_constants
          klass.class_eval mapping_method_definition
        end
        klass
      end

      def klass
        @klass ||= get_or_define_module container_class, @classname
      end

      def mapping_method_definition
        arg_infos = info.args

        container_type_info = SignalReceiverTypeInfo.new(container_info)
        receiver_info = SignalReceiverArgumentInfo.new(container_type_info)

        user_data_type_info = UserDataTypeInfo.new
        user_data_argument_info = UserDataArgumentInfo.new(user_data_type_info,
                                                           arg_infos.length + 1)

        MappingMethodBuilder.for_signal(receiver_info,
                                        arg_infos,
                                        user_data_argument_info,
                                        info.return_type).method_definition
      end

      def container_class
        @container_class ||= Builder.build_class(container_info)
      end

      def container_info
        @container_info ||= info.container
      end
    end
  end
end
<commit_msg>Remove superfluous subclasses of ReturnValueInfo<commit_after>require 'gir_ffi/return_value_info'
require 'gir_ffi/builders/base_type_builder'
require 'gir_ffi/builders/mapping_method_builder'
require 'gir_ffi/signal_base'

module GirFFI
  module Builders
    # Implements the creation of a signal module for handling a particular
    # signal. The type will be attached to the appropriate class.
    class SignalBuilder < BaseTypeBuilder
      class SignalReceiverTypeInfo
        include InfoExt::ITypeInfo

        def initialize interface_info
          @interface_info = interface_info
        end

        def interface
          @interface_info
        end

        def tag
          :interface
        end
      end

      class UserDataTypeInfo
        include InfoExt::ITypeInfo

        def tag
          :void
        end

        def pointer?
          true
        end
      end

      def instantiate_class
        unless already_set_up
          klass.extend SignalBase
          setup_constants
          klass.class_eval mapping_method_definition
        end
        klass
      end

      def klass
        @klass ||= get_or_define_module container_class, @classname
      end

      def mapping_method_definition
        arg_infos = info.args

        container_type_info = SignalReceiverTypeInfo.new(container_info)
        receiver_info = ReturnValueInfo.new(container_type_info)

        user_data_type_info = UserDataTypeInfo.new
        user_data_argument_info = ReturnValueInfo.new(user_data_type_info)

        MappingMethodBuilder.for_signal(receiver_info,
                                        arg_infos,
                                        user_data_argument_info,
                                        info.return_type).method_definition
      end

      def container_class
        @container_class ||= Builder.build_class(container_info)
      end

      def container_info
        @container_info ||= info.container
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.03732718894009217, 'fraction_numerical': 0.0004608294930875576, 'mean_word_length': 1.871031746031746, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4877102', 'n_tokens_mistral': 1110, 'n_tokens_neox': 1089, 'n_words': 263}