Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-1017

Support named variables while adding functions in the typesystems

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Not Evaluated
    • 5.12.4, 5.13.1
    • 5.12.3
    • Shiboken
    • None
    • 4a1d5f1d6cc6325c8e26512f408966821b41c480 (pyside/pyside-setup/5.12)

    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

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              kleint Friedemann Kleint
              crmaurei Cristian Maureira-Fredes
              Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes