<commit_before># frozen_string_literal: true

require "gir_ffi/builders/registered_type_builder"
require "gir_ffi/builders/with_layout"
require "gir_ffi/builders/property_builder"
require "gir_ffi/object_base"
require "gir_ffi/struct"

module GirFFI
  module Builders
    # Implements the creation of a class representing a GObject Object.
    class ObjectBuilder < RegisteredTypeBuilder
      include WithLayout

      # Dummy builder for the ObjectBase class
      class ObjectBaseBuilder
        def build_class
          ObjectBase
        end

        def ancestor_infos
          []
        end
      end

      def find_signal(signal_name)
        seek_in_ancestor_infos { |info| info.find_signal signal_name }
      end

      def find_property(property_name)
        seek_in_ancestor_infos { |info| info.find_property property_name }
      end

      def object_class_struct
        @object_class_struct ||= Builder.build_class object_class_struct_info
      end

      def ancestor_infos
        @ancestor_infos ||= [info] + info.interfaces + parent_ancestor_infos
      end

      def eligible_properties
        info.properties.reject do |pinfo|
          info.find_instance_method("get_#{pinfo.name}")
        end
      end

      protected

      def object_class_struct_info
        @object_class_struct_info ||=
          info.class_struct || parent_builder.object_class_struct_info
      end

      private

      def setup_class
        setup_layout
        setup_constants
        stub_methods
        setup_property_accessors<commit_msg>Fetch parent object_class_struct from the parent class<commit_after># frozen_string_literal: true

require "gir_ffi/builders/registered_type_builder"
require "gir_ffi/builders/with_layout"
require "gir_ffi/builders/property_builder"
require "gir_ffi/object_base"
require "gir_ffi/struct"

module GirFFI
  module Builders
    # Implements the creation of a class representing a GObject Object.
    class ObjectBuilder < RegisteredTypeBuilder
      include WithLayout

      # Dummy builder for the ObjectBase class
      class ObjectBaseBuilder
        def build_class
          ObjectBase
        end

        def ancestor_infos
          []
        end
      end

      def find_signal(signal_name)
        seek_in_ancestor_infos { |info| info.find_signal signal_name }
      end

      def find_property(property_name)
        seek_in_ancestor_infos { |info| info.find_property property_name }
      end

      def object_class_struct
        @object_class_struct ||=
          if object_class_struct_info
            Builder.build_class object_class_struct_info
          else
            parent_builder.object_class_struct
          end
      end

      def ancestor_infos
        @ancestor_infos ||= [info] + info.interfaces + parent_ancestor_infos
      end

      def eligible_properties
        info.properties.reject do |pinfo|
          info.find_instance_method("get_#{pinfo.name}")
        end
      end

      protected

      def object_class_struct_info
        @object_class_struct_info ||= info.class_struct
      end

      private

      def setup_class
        setup_layout
        setup_constants
        stub_methods
        setup_property_accessors
{'fraction_non_alphanumeric': 0.04770755885997522, 'fraction_numerical': 0.0, 'mean_word_length': 2.56401766004415, 'pattern_counts': {'":': 0, '<': 5, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '657112', 'n_tokens_mistral': 952, 'n_tokens_neox': 931, 'n_words': 203}