Details
Description
Currently, the add-function tag does not allow to name variables.
Shiboken generates them with the names arg_1, arg_2, and so on.
Usually, that's not a problem, but when a new function is added, which includes a name parameter, for example: function(int, str, option=nullptr) one cannot refer to it as option, but arg__3.
The following snippet is invalid:
<add-function signature="value(int, float, PyTypeObject* type = nullptr)" return-type="PyObject*">
because then shiboken complains that the type "PyTypeObject*type" doesn't exist.
The option to include this function is to drop the name:
<add-function signature="value(int, float, PyTypeObject* = nullptr)" return-type="PyObject*">
Then the generated code becomes:
case 0: // value(int arg__1, float arg__2, PyTypeObject * arg__3) { if (kwds) { PyObject* value = PyDict_GetItemString(kwds, "arg__3"); if (value && pyArgs[2]) { PyErr_SetString(PyExc_TypeError, "PySide2.QtCore.QSettings.value(): got multiple values for keyword argument 'arg__3'."); return {}; } else if (value) { pyArgs[2] = value; if (!PyType_Check(pyArgs[2])) goto Sbk_QSettingsFunc_value_TypeError; } } int cppArg0; pythonToCpp[0](pyArgs[0], &cppArg0); SBK_UNUSED(cppArg0) float cppArg1; pythonToCpp[1](pyArgs[1], &cppArg1); SBK_UNUSED(cppArg1)
And for that, one can see that the name of this named parameter will be arg__3
PyObject* value = PyDict_GetItemString(kwds, "arg__3");
and executing something like that using value(1, 3.4, arg__3=list) is really not the proper expected result.
Attachments
Issue Links
- is required for
-
PYSIDE-1010 Data type in QSettings
- Closed
For Gerrit Dashboard: PYSIDE-1017 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
263976,1 | Remove space from custom type names | 5.12 | pyside/pyside-setup | Status: ABANDONED | 0 | 0 |
263977,5 | shiboken: Enable specifying names for a parameters of added functions | 5.12 | pyside/pyside-setup | Status: MERGED | +2 | 0 |