diff options
author | Erlend E. Aasland <erlend.aasland@protonmail.com> | 2022-08-13 10:09:40 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-13 10:09:40 (GMT) |
commit | f07adf82f338ebb7e69475537be050e63c2009fa (patch) | |
tree | 26c4cd000b95fc45befb2ea3c87c03d84d9aed75 /PC | |
parent | f235178beccf5eb5b47e770240f32d9ba24b26fd (diff) | |
download | cpython-f07adf82f338ebb7e69475537be050e63c2009fa.zip cpython-f07adf82f338ebb7e69475537be050e63c2009fa.tar.gz cpython-f07adf82f338ebb7e69475537be050e63c2009fa.tar.bz2 |
gh-90928: Improve static initialization of keywords tuple in AC (#95907)
Diffstat (limited to 'PC')
-rw-r--r-- | PC/clinic/_testconsole.c.h | 50 | ||||
-rw-r--r-- | PC/clinic/winreg.c.h | 122 | ||||
-rw-r--r-- | PC/clinic/winsound.c.h | 74 |
3 files changed, 73 insertions, 173 deletions
diff --git a/PC/clinic/_testconsole.c.h b/PC/clinic/_testconsole.c.h index 7250150..b2f3b4c 100644 --- a/PC/clinic/_testconsole.c.h +++ b/PC/clinic/_testconsole.c.h @@ -27,18 +27,9 @@ static PyObject * _testconsole_write_input(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #define NUM_KEYWORDS 2 - #if NUM_KEYWORDS == 0 - - # if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - # else - # define KWTUPLE NULL - # endif - - #else // NUM_KEYWORDS != 0 - # if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + #define NUM_KEYWORDS 2 static struct { PyGC_Head _this_is_not_used; PyObject_VAR_HEAD @@ -47,13 +38,12 @@ _testconsole_write_input(PyObject *module, PyObject *const *args, Py_ssize_t nar .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) .ob_item = { &_Py_ID(file), &_Py_ID(s), }, }; - # define KWTUPLE (&_kwtuple.ob_base.ob_base) - - # else // !Py_BUILD_CORE - # define KWTUPLE NULL - # endif // !Py_BUILD_CORE - #endif // NUM_KEYWORDS != 0 #undef NUM_KEYWORDS + #define KWTUPLE (&_kwtuple.ob_base.ob_base) + + #else // !Py_BUILD_CORE + # define KWTUPLE NULL + #endif // !Py_BUILD_CORE static const char * const _keywords[] = {"file", "s", NULL}; static _PyArg_Parser _parser = { @@ -102,18 +92,9 @@ static PyObject * _testconsole_read_output(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #define NUM_KEYWORDS 1 - #if NUM_KEYWORDS == 0 - - # if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - # else - # define KWTUPLE NULL - # endif - - #else // NUM_KEYWORDS != 0 - # if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + #define NUM_KEYWORDS 1 static struct { PyGC_Head _this_is_not_used; PyObject_VAR_HEAD @@ -122,13 +103,12 @@ _testconsole_read_output(PyObject *module, PyObject *const *args, Py_ssize_t nar .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) .ob_item = { &_Py_ID(file), }, }; - # define KWTUPLE (&_kwtuple.ob_base.ob_base) - - # else // !Py_BUILD_CORE - # define KWTUPLE NULL - # endif // !Py_BUILD_CORE - #endif // NUM_KEYWORDS != 0 #undef NUM_KEYWORDS + #define KWTUPLE (&_kwtuple.ob_base.ob_base) + + #else // !Py_BUILD_CORE + # define KWTUPLE NULL + #endif // !Py_BUILD_CORE static const char * const _keywords[] = {"file", NULL}; static _PyArg_Parser _parser = { @@ -160,4 +140,4 @@ exit: #ifndef _TESTCONSOLE_READ_OUTPUT_METHODDEF #define _TESTCONSOLE_READ_OUTPUT_METHODDEF #endif /* !defined(_TESTCONSOLE_READ_OUTPUT_METHODDEF) */ -/*[clinic end generated code: output=73b7768a87e295a9 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=208c72e2c873555b input=a9049054013a1b77]*/ diff --git a/PC/clinic/winreg.c.h b/PC/clinic/winreg.c.h index 2cf50ef..dc78274 100644 --- a/PC/clinic/winreg.c.h +++ b/PC/clinic/winreg.c.h @@ -93,18 +93,9 @@ static PyObject * winreg_HKEYType___exit__(PyHKEYObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #define NUM_KEYWORDS 3 - #if NUM_KEYWORDS == 0 - - # if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - # else - # define KWTUPLE NULL - # endif - - #else // NUM_KEYWORDS != 0 - # if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + #define NUM_KEYWORDS 3 static struct { PyGC_Head _this_is_not_used; PyObject_VAR_HEAD @@ -113,13 +104,12 @@ winreg_HKEYType___exit__(PyHKEYObject *self, PyObject *const *args, Py_ssize_t n .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) .ob_item = { &_Py_ID(exc_type), &_Py_ID(exc_value), &_Py_ID(traceback), }, }; - # define KWTUPLE (&_kwtuple.ob_base.ob_base) - - # else // !Py_BUILD_CORE - # define KWTUPLE NULL - # endif // !Py_BUILD_CORE - #endif // NUM_KEYWORDS != 0 #undef NUM_KEYWORDS + #define KWTUPLE (&_kwtuple.ob_base.ob_base) + + #else // !Py_BUILD_CORE + # define KWTUPLE NULL + #endif // !Py_BUILD_CORE static const char * const _keywords[] = {"exc_type", "exc_value", "traceback", NULL}; static _PyArg_Parser _parser = { @@ -325,18 +315,9 @@ static PyObject * winreg_CreateKeyEx(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #define NUM_KEYWORDS 4 - #if NUM_KEYWORDS == 0 - - # if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - # else - # define KWTUPLE NULL - # endif - - #else // NUM_KEYWORDS != 0 - # if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + #define NUM_KEYWORDS 4 static struct { PyGC_Head _this_is_not_used; PyObject_VAR_HEAD @@ -345,13 +326,12 @@ winreg_CreateKeyEx(PyObject *module, PyObject *const *args, Py_ssize_t nargs, Py .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) .ob_item = { &_Py_ID(key), &_Py_ID(sub_key), &_Py_ID(reserved), &_Py_ID(access), }, }; - # define KWTUPLE (&_kwtuple.ob_base.ob_base) - - # else // !Py_BUILD_CORE - # define KWTUPLE NULL - # endif // !Py_BUILD_CORE - #endif // NUM_KEYWORDS != 0 #undef NUM_KEYWORDS + #define KWTUPLE (&_kwtuple.ob_base.ob_base) + + #else // !Py_BUILD_CORE + # define KWTUPLE NULL + #endif // !Py_BUILD_CORE static const char * const _keywords[] = {"key", "sub_key", "reserved", "access", NULL}; static _PyArg_Parser _parser = { @@ -512,18 +492,9 @@ static PyObject * winreg_DeleteKeyEx(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #define NUM_KEYWORDS 4 - #if NUM_KEYWORDS == 0 - - # if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - # else - # define KWTUPLE NULL - # endif - - #else // NUM_KEYWORDS != 0 - # if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + #define NUM_KEYWORDS 4 static struct { PyGC_Head _this_is_not_used; PyObject_VAR_HEAD @@ -532,13 +503,12 @@ winreg_DeleteKeyEx(PyObject *module, PyObject *const *args, Py_ssize_t nargs, Py .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) .ob_item = { &_Py_ID(key), &_Py_ID(sub_key), &_Py_ID(access), &_Py_ID(reserved), }, }; - # define KWTUPLE (&_kwtuple.ob_base.ob_base) - - # else // !Py_BUILD_CORE - # define KWTUPLE NULL - # endif // !Py_BUILD_CORE - #endif // NUM_KEYWORDS != 0 #undef NUM_KEYWORDS + #define KWTUPLE (&_kwtuple.ob_base.ob_base) + + #else // !Py_BUILD_CORE + # define KWTUPLE NULL + #endif // !Py_BUILD_CORE static const char * const _keywords[] = {"key", "sub_key", "access", "reserved", NULL}; static _PyArg_Parser _parser = { @@ -926,18 +896,9 @@ static PyObject * winreg_OpenKey(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #define NUM_KEYWORDS 4 - #if NUM_KEYWORDS == 0 - - # if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - # else - # define KWTUPLE NULL - # endif - - #else // NUM_KEYWORDS != 0 - # if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + #define NUM_KEYWORDS 4 static struct { PyGC_Head _this_is_not_used; PyObject_VAR_HEAD @@ -946,13 +907,12 @@ winreg_OpenKey(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObje .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) .ob_item = { &_Py_ID(key), &_Py_ID(sub_key), &_Py_ID(reserved), &_Py_ID(access), }, }; - # define KWTUPLE (&_kwtuple.ob_base.ob_base) - - # else // !Py_BUILD_CORE - # define KWTUPLE NULL - # endif // !Py_BUILD_CORE - #endif // NUM_KEYWORDS != 0 #undef NUM_KEYWORDS + #define KWTUPLE (&_kwtuple.ob_base.ob_base) + + #else // !Py_BUILD_CORE + # define KWTUPLE NULL + #endif // !Py_BUILD_CORE static const char * const _keywords[] = {"key", "sub_key", "reserved", "access", NULL}; static _PyArg_Parser _parser = { @@ -1049,18 +1009,9 @@ static PyObject * winreg_OpenKeyEx(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #define NUM_KEYWORDS 4 - #if NUM_KEYWORDS == 0 - - # if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - # else - # define KWTUPLE NULL - # endif - - #else // NUM_KEYWORDS != 0 - # if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + #define NUM_KEYWORDS 4 static struct { PyGC_Head _this_is_not_used; PyObject_VAR_HEAD @@ -1069,13 +1020,12 @@ winreg_OpenKeyEx(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyOb .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) .ob_item = { &_Py_ID(key), &_Py_ID(sub_key), &_Py_ID(reserved), &_Py_ID(access), }, }; - # define KWTUPLE (&_kwtuple.ob_base.ob_base) - - # else // !Py_BUILD_CORE - # define KWTUPLE NULL - # endif // !Py_BUILD_CORE - #endif // NUM_KEYWORDS != 0 #undef NUM_KEYWORDS + #define KWTUPLE (&_kwtuple.ob_base.ob_base) + + #else // !Py_BUILD_CORE + # define KWTUPLE NULL + #endif // !Py_BUILD_CORE static const char * const _keywords[] = {"key", "sub_key", "reserved", "access", NULL}; static _PyArg_Parser _parser = { @@ -1629,4 +1579,4 @@ winreg_QueryReflectionKey(PyObject *module, PyObject *arg) exit: return return_value; } -/*[clinic end generated code: output=dc148c077a03843e input=a9049054013a1b77]*/ +/*[clinic end generated code: output=5dfd7dbce8ccb392 input=a9049054013a1b77]*/ diff --git a/PC/clinic/winsound.c.h b/PC/clinic/winsound.c.h index c481410..241d547 100644 --- a/PC/clinic/winsound.c.h +++ b/PC/clinic/winsound.c.h @@ -29,18 +29,9 @@ static PyObject * winsound_PlaySound(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #define NUM_KEYWORDS 2 - #if NUM_KEYWORDS == 0 - - # if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - # else - # define KWTUPLE NULL - # endif - - #else // NUM_KEYWORDS != 0 - # if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + #define NUM_KEYWORDS 2 static struct { PyGC_Head _this_is_not_used; PyObject_VAR_HEAD @@ -49,13 +40,12 @@ winsound_PlaySound(PyObject *module, PyObject *const *args, Py_ssize_t nargs, Py .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) .ob_item = { &_Py_ID(sound), &_Py_ID(flags), }, }; - # define KWTUPLE (&_kwtuple.ob_base.ob_base) - - # else // !Py_BUILD_CORE - # define KWTUPLE NULL - # endif // !Py_BUILD_CORE - #endif // NUM_KEYWORDS != 0 #undef NUM_KEYWORDS + #define KWTUPLE (&_kwtuple.ob_base.ob_base) + + #else // !Py_BUILD_CORE + # define KWTUPLE NULL + #endif // !Py_BUILD_CORE static const char * const _keywords[] = {"sound", "flags", NULL}; static _PyArg_Parser _parser = { @@ -105,18 +95,9 @@ static PyObject * winsound_Beep(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #define NUM_KEYWORDS 2 - #if NUM_KEYWORDS == 0 - - # if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - # else - # define KWTUPLE NULL - # endif - - #else // NUM_KEYWORDS != 0 - # if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + #define NUM_KEYWORDS 2 static struct { PyGC_Head _this_is_not_used; PyObject_VAR_HEAD @@ -125,13 +106,12 @@ winsound_Beep(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObjec .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) .ob_item = { &_Py_ID(frequency), &_Py_ID(duration), }, }; - # define KWTUPLE (&_kwtuple.ob_base.ob_base) - - # else // !Py_BUILD_CORE - # define KWTUPLE NULL - # endif // !Py_BUILD_CORE - #endif // NUM_KEYWORDS != 0 #undef NUM_KEYWORDS + #define KWTUPLE (&_kwtuple.ob_base.ob_base) + + #else // !Py_BUILD_CORE + # define KWTUPLE NULL + #endif // !Py_BUILD_CORE static const char * const _keywords[] = {"frequency", "duration", NULL}; static _PyArg_Parser _parser = { @@ -180,18 +160,9 @@ static PyObject * winsound_MessageBeep(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; - #define NUM_KEYWORDS 1 - #if NUM_KEYWORDS == 0 - - # if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty) - # else - # define KWTUPLE NULL - # endif - - #else // NUM_KEYWORDS != 0 - # if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + #define NUM_KEYWORDS 1 static struct { PyGC_Head _this_is_not_used; PyObject_VAR_HEAD @@ -200,13 +171,12 @@ winsound_MessageBeep(PyObject *module, PyObject *const *args, Py_ssize_t nargs, .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) .ob_item = { &_Py_ID(type), }, }; - # define KWTUPLE (&_kwtuple.ob_base.ob_base) - - # else // !Py_BUILD_CORE - # define KWTUPLE NULL - # endif // !Py_BUILD_CORE - #endif // NUM_KEYWORDS != 0 #undef NUM_KEYWORDS + #define KWTUPLE (&_kwtuple.ob_base.ob_base) + + #else // !Py_BUILD_CORE + # define KWTUPLE NULL + #endif // !Py_BUILD_CORE static const char * const _keywords[] = {"type", NULL}; static _PyArg_Parser _parser = { @@ -236,4 +206,4 @@ skip_optional_pos: exit: return return_value; } -/*[clinic end generated code: output=bdca8518ca517fd8 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=f70b7730127208d8 input=a9049054013a1b77]*/ |