class RDoc::Parser::C

def handle_method(type, var_name, meth_name, function, param_count,

def handle_method(type, var_name, meth_name, function, param_count,
                  source_file = nil)
  class_name = @known_classes[var_name]
  singleton  = @singleton_classes.key? var_name
  @methods[var_name][function] << meth_name
  return unless class_name
  class_obj = find_class var_name, class_name
  if existing_method = class_obj.method_list.find { |m| m.c_function == function }
    add_alias(var_name, class_obj, existing_method.name, meth_name, existing_method.comment)
  end
  if class_obj then
    if meth_name == 'initialize' then
      meth_name = 'new'
      singleton = true
      type = 'method' # force public
    end
    meth_obj = RDoc::AnyMethod.new '', meth_name
    meth_obj.c_function = function
    meth_obj.singleton =
      singleton || %w[singleton_method module_function].include?(type)
    p_count = Integer(param_count) rescue -1
    if source_file then
      file_name = File.join @file_dir, source_file
      if File.exist? file_name then
        file_content = File.read file_name
      else
        @options.warn "unknown source #{source_file} for #{meth_name} in #{@file_name}"
      end
    else
      file_content = @content
    end
    body = find_body class_name, function, meth_obj, file_content
    if body and meth_obj.document_self then
      meth_obj.params = if p_count < -1 then # -2 is Array
                          '(*args)'
                        elsif p_count == -1 then # argc, argv
                          rb_scan_args body
                        else
                          args = (1..p_count).map { |i| "p#{i}" }
                          "(#{args.join ', '})"
                        end
      meth_obj.record_location @top_level
      if meth_obj.section_title
        class_obj.temporary_section = class_obj.add_section(meth_obj.section_title)
      end
      class_obj.add_method meth_obj
      @stats.add_method meth_obj
      meth_obj.visibility = :private if 'private_method' == type
    end
  end
end