Emit METH_FASTCALL code in Argument Clinic

Issue #27810:

* Modify vgetargskeywordsfast() to work on a C array of PyObject* rather than
  working on a tuple directly.
* Add _PyArg_ParseStack()
* Argument Clinic now emits code using the new METH_FASTCALL calling convention
This commit is contained in:
Victor Stinner 2016-09-09 17:40:38 -07:00
parent a9efb2f56e
commit f0ccbbbc57
3 changed files with 179 additions and 28 deletions

View file

@ -705,6 +705,11 @@ class CLanguage(Language):
{c_basename}({self_type}{self_name}, PyObject *args, PyObject *kwargs)
""")
parser_prototype_fastcall = normalize_snippet("""
static PyObject *
{c_basename}({self_type}{self_name}, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
""")
parser_prototype_varargs = normalize_snippet("""
static PyObject *
{c_basename}({self_type}{self_name}, PyObject *args)
@ -845,6 +850,19 @@ class CLanguage(Language):
}}
""", indent=4))
elif not new_or_init:
flags = "METH_FASTCALL"
parser_prototype = parser_prototype_fastcall
body = normalize_snippet("""
if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
{parse_arguments})) {{
goto exit;
}}
""", indent=4)
parser_definition = parser_body(parser_prototype, body)
parser_definition = insert_keywords(parser_definition)
else:
# positional-or-keyword arguments
flags = "METH_VARARGS|METH_KEYWORDS"