<commit_before>module RbPlusPlus
  module Builders

    # This class handles generating source for a requested Module
    class ModuleBuilder < Base

      # Initializer takes the parent object and the RbModule construction
      def initialize(parent, mod)
        super(mod.name, mod.node)
        @module = mod
        self.parent = parent
      end

      def build
        # Using qualified name with underscores here to allow for nested modules
        # of the same name
        self.rice_variable = "rb_m#{self.qualified_name.gsub(/::/, "_")}"
        self.rice_variable_type = "Rice::Module"

        includes << "#include <rice/Module.hpp>"
        
        add_additional_includes

        mod_defn = "\t#{rice_variable_type} #{rice_variable} = "
        if !parent.is_a?(ExtensionBuilder)
          mod_defn += "Rice::define_module_under(#{parent.rice_variable}, \"#{name}\");"
        else
          mod_defn += "Rice::define_module(\"#{name}\");"
        end

        body << mod_defn

        # If a namespace has been given to this module, find and wrap the appropriate code
        if self.node
          build_enumerations 
        end

        build_functions unless @module.functions.empty?
        build_classes(@module.classes) unless @module.classes.empty?
   

        # Build each inner module
        @module.modules.each do |mod|
          builder = ModuleBuilder.new(self, mod)
          builder.build
          builders << builder
        end
      end

      # Process functions to be added to this module
      def build_functions
        @module.functions.each do |func|
          next if func.ignored? || func.moved? # fine grained function filtering
          add_includes_for func

          func_name = Inflector.underscore(func.name)
          wrapped_name = build_function_wrapper(func)
          body << "\t#{self.rice_variable}.define_module_function(\"#{func_name}\", &#{wrapped_name});"
        end
      end

      # Special name handling. Qualified name is simply the name of this module
      def qualified_name
        if parent.is_a?(ModuleBuilder)
          "#{parent.qualified_name}::#{self.name}"
        else
          self.name
        end
      end

    end
  end
end
<commit_msg>Added function#calls ability to modules as well.<commit_after>module RbPlusPlus
  module Builders

    # This class handles generating source for a requested Module
    class ModuleBuilder < Base

      # Initializer takes the parent object and the RbModule construction
      def initialize(parent, mod)
        super(mod.name, mod.node)
        @module = mod
        self.parent = parent
      end

      def build
        # Using qualified name with underscores here to allow for nested modules
        # of the same name
        self.rice_variable = "rb_m#{self.qualified_name.gsub(/::/, "_")}"
        self.rice_variable_type = "Rice::Module"

        includes << "#include <rice/Module.hpp>"
        
        add_additional_includes

        mod_defn = "\t#{rice_variable_type} #{rice_variable} = "
        if !parent.is_a?(ExtensionBuilder)
          mod_defn += "Rice::define_module_under(#{parent.rice_variable}, \"#{name}\");"
        else
          mod_defn += "Rice::define_module(\"#{name}\");"
        end

        body << mod_defn

        # If a namespace has been given to this module, find and wrap the appropriate code
        if self.node
          build_enumerations 
        end

        build_functions unless @module.functions.empty?
        build_classes(@module.classes) unless @module.classes.empty?
   

        # Build each inner module
        @module.modules.each do |mod|
          builder = ModuleBuilder.new(self, mod)
          builder.build
          builders << builder
        end
      end

      # Process functions to be added to this module
      def build_functions
        @module.functions.each do |func|
          next if func.ignored? || func.moved? # fine grained function filtering
          add_includes_for func

          func_name = Inflector.underscore(func.name)
          wrapped_name = func.special_qualified_name || build_function_wrapper(func)
          body << "\t#{self.rice_variable}.define_module_function(\"#{func_name}\", &#{wrapped_name});"
        end
      end

      # Special name handling. Qualified name is simply the name of this module
      def qualified_name
        if parent.is_a?(ModuleBuilder)
          "#{parent.qualified_name}::#{self.name}"
        else
          self.name
        end
      end

    end
  end
end

{'fraction_non_alphanumeric': 0.09024713150926743, 'fraction_numerical': 0.0, 'mean_word_length': 2.2263345195729536, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 5, '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': '6592391', 'n_tokens_mistral': 1258, 'n_tokens_neox': 1241, 'n_words': 347}