module YARD::Handlers::C::HandlerMethods

def record_parameters(object, symbol, src)

def record_parameters(object, symbol, src)
  # use regex to extract comma-delimited list of parameters from cfunc definition
  if src.source =~ /VALUE\s+#{symbol}\(([^)]*)\)\s*\{/m
    params = $~[1].split(/\s*,\s*/) # rubocop:disable Style/SpecialGlobalVars
    # cfunc for a "varargs" method has params "int argc, VALUE *argv"
    if params[0] =~ /int\s+argc/ && params[1] =~ /VALUE\s*\*\s*argv/
      object.parameters = [['*args', nil]]
    else
      # the first cfunc argument is the 'self' argument, we don't need that
      object.parameters = params.drop(1).map {|s| [s[/VALUE\s+(\S+)/, 1], nil] }
    end
  end
end