diff options
author | Victor Stinner <vstinner@redhat.com> | 2018-11-09 15:56:48 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-09 15:56:48 (GMT) |
commit | d17a693fa08ce9f2d35acbb1f76e20bdae3e01da (patch) | |
tree | d3cd55ed960c8444a7411f1c21fc631ee19447c9 /Objects | |
parent | 130893debfd97c70e3a89d9ba49892f53e6b9d79 (diff) | |
download | cpython-d17a693fa08ce9f2d35acbb1f76e20bdae3e01da.zip cpython-d17a693fa08ce9f2d35acbb1f76e20bdae3e01da.tar.gz cpython-d17a693fa08ce9f2d35acbb1f76e20bdae3e01da.tar.bz2 |
bpo-35199: Add an internal _PyTuple_ITEMS() macro (GH-10434)
* _PyTuple_ITEMS() gives access to the tuple->ob_item field and cast the
first argument to PyTupleObject*. This internal macro is only usable if
Py_BUILD_CORE is defined.
* Replace &PyTuple_GET_ITEM(ob, 0) with _PyTuple_ITEMS(ob).
* Replace PyTuple_GET_ITEM(op, 1) with &_PyTuple_ITEMS(ob)[1].
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/call.c | 22 | ||||
-rw-r--r-- | Objects/codeobject.c | 2 | ||||
-rw-r--r-- | Objects/descrobject.c | 4 | ||||
-rw-r--r-- | Objects/funcobject.c | 2 |
4 files changed, 15 insertions, 15 deletions
diff --git a/Objects/call.c b/Objects/call.c index 48e3aaf..707b49a 100644 --- a/Objects/call.c +++ b/Objects/call.c @@ -224,7 +224,7 @@ PyObject_Call(PyObject *callable, PyObject *args, PyObject *kwargs) if (PyFunction_Check(callable)) { return _PyFunction_FastCallDict(callable, - &PyTuple_GET_ITEM(args, 0), + _PyTuple_ITEMS(args), PyTuple_GET_SIZE(args), kwargs); } @@ -325,7 +325,7 @@ _PyFunction_FastCallDict(PyObject *func, PyObject *const *args, Py_ssize_t nargs && co->co_argcount == PyTuple_GET_SIZE(argdefs)) { /* function called with no arguments, but all parameters have a default value: use default values as arguments .*/ - args = &PyTuple_GET_ITEM(argdefs, 0); + args = _PyTuple_ITEMS(argdefs); return function_code_fastcall(co, args, PyTuple_GET_SIZE(argdefs), globals); } @@ -342,7 +342,7 @@ _PyFunction_FastCallDict(PyObject *func, PyObject *const *args, Py_ssize_t nargs return NULL; } - k = &PyTuple_GET_ITEM(kwtuple, 0); + k = _PyTuple_ITEMS(kwtuple); pos = i = 0; while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) { /* We must hold strong references because keyword arguments can be @@ -365,7 +365,7 @@ _PyFunction_FastCallDict(PyObject *func, PyObject *const *args, Py_ssize_t nargs qualname = ((PyFunctionObject *)func) -> func_qualname; if (argdefs != NULL) { - d = &PyTuple_GET_ITEM(argdefs, 0); + d = _PyTuple_ITEMS(argdefs); nd = PyTuple_GET_SIZE(argdefs); } else { @@ -411,7 +411,7 @@ _PyFunction_FastCallKeywords(PyObject *func, PyObject *const *stack, && co->co_argcount == PyTuple_GET_SIZE(argdefs)) { /* function called with no arguments, but all parameters have a default value: use default values as arguments .*/ - stack = &PyTuple_GET_ITEM(argdefs, 0); + stack = _PyTuple_ITEMS(argdefs); return function_code_fastcall(co, stack, PyTuple_GET_SIZE(argdefs), globals); } @@ -423,7 +423,7 @@ _PyFunction_FastCallKeywords(PyObject *func, PyObject *const *stack, qualname = ((PyFunctionObject *)func) -> func_qualname; if (argdefs != NULL) { - d = &PyTuple_GET_ITEM(argdefs, 0); + d = _PyTuple_ITEMS(argdefs); nd = PyTuple_GET_SIZE(argdefs); } else { @@ -432,7 +432,7 @@ _PyFunction_FastCallKeywords(PyObject *func, PyObject *const *stack, } return _PyEval_EvalCodeWithName((PyObject*)co, globals, (PyObject *)NULL, stack, nargs, - nkwargs ? &PyTuple_GET_ITEM(kwnames, 0) : NULL, + nkwargs ? _PyTuple_ITEMS(kwnames) : NULL, stack + nargs, nkwargs, 1, d, (int)nd, kwdefs, @@ -785,7 +785,7 @@ PyCFunction_Call(PyObject *func, PyObject *args, PyObject *kwargs) } else { return _PyCFunction_FastCallDict(func, - &PyTuple_GET_ITEM(args, 0), + _PyTuple_ITEMS(args), PyTuple_GET_SIZE(args), kwargs); } @@ -898,8 +898,8 @@ _PyObject_Call_Prepend(PyObject *callable, /* use borrowed references */ stack[0] = obj; memcpy(&stack[1], - &PyTuple_GET_ITEM(args, 0), - argcount * sizeof(PyObject *)); + _PyTuple_ITEMS(args), + argcount * sizeof(PyObject *)); result = _PyObject_FastCallDict(callable, stack, argcount + 1, @@ -950,7 +950,7 @@ _PyObject_CallFunctionVa(PyObject *callable, const char *format, func(*(arg1, arg2, arg3)): func(arg1, arg2, arg3) */ PyObject *args = stack[0]; result = _PyObject_FastCall(callable, - &PyTuple_GET_ITEM(args, 0), + _PyTuple_ITEMS(args), PyTuple_GET_SIZE(args)); } else { diff --git a/Objects/codeobject.c b/Objects/codeobject.c index 6d8e9ac..2450213 100644 --- a/Objects/codeobject.c +++ b/Objects/codeobject.c @@ -39,7 +39,7 @@ intern_strings(PyObject *tuple) if (v == NULL || !PyUnicode_CheckExact(v)) { Py_FatalError("non-string found in code slot"); } - PyUnicode_InternInPlace(&PyTuple_GET_ITEM(tuple, i)); + PyUnicode_InternInPlace(&_PyTuple_ITEMS(tuple)[i]); } } diff --git a/Objects/descrobject.c b/Objects/descrobject.c index a23b97f..17d0f5a 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -247,7 +247,7 @@ methoddescr_call(PyMethodDescrObject *descr, PyObject *args, PyObject *kwargs) } result = _PyMethodDef_RawFastCallDict(descr->d_method, self, - &PyTuple_GET_ITEM(args, 1), nargs - 1, + &_PyTuple_ITEMS(args)[1], nargs - 1, kwargs); result = _Py_CheckFunctionResult((PyObject *)descr, result, NULL); return result; @@ -331,7 +331,7 @@ classmethoddescr_call(PyMethodDescrObject *descr, PyObject *args, } result = _PyMethodDef_RawFastCallDict(descr->d_method, self, - &PyTuple_GET_ITEM(args, 1), argc - 1, + &_PyTuple_ITEMS(args)[1], argc - 1, kwds); result = _Py_CheckFunctionResult((PyObject *)descr, result, NULL); return result; diff --git a/Objects/funcobject.c b/Objects/funcobject.c index e5278f0..8648821 100644 --- a/Objects/funcobject.c +++ b/Objects/funcobject.c @@ -581,7 +581,7 @@ function_call(PyObject *func, PyObject *args, PyObject *kwargs) PyObject **stack; Py_ssize_t nargs; - stack = &PyTuple_GET_ITEM(args, 0); + stack = _PyTuple_ITEMS(args); nargs = PyTuple_GET_SIZE(args); return _PyFunction_FastCallDict(func, stack, nargs, kwargs); } |