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

unsigned char* member gets translated incorrectly

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Not Evaluated
    • None
    • 6.7.2
    • PySide
    • None
    • Windows

    Description

      I am facing a strange conversion of a python wrapper being made for a member variable of a class.
      The generated code is the following:

      static PyObject Sbk_LUT_get_m_LUT_DATA_UB(PyObject *self, void * / closure */)
      {
          if (!Shiboken::Object::isValid(self))
              return {};
          auto *cppSelf = static_cast<LUTWrapper *>(reinterpret_cast< ::LUT *>(Shiboken::Conversions::cppPointer(Shiboken::Module::get(Sbkmy_python_moduleTypeStructs[SBK_LUT_IDX]), reinterpret_cast<SbkObject *>(self))));
          SBK_UNUSED(cppSelf)
          unsigned char cppOut_local = static_cast<LUTWrapper *>(cppSelf)->m_LUT_DATA_UB;
          PyObject *pyOut = {};
          pyOut = Shiboken::Conversions::copyToPython(Shiboken::Conversions::PrimitiveTypeConverter<unsigned char>(), cppOut_local);
          return pyOut;
      }
      

      What I expect is that the line 

      unsigned char cppOut_local = static_cast<LUTWrapper *>(cppSelf)->m_LUT_DATA_UB;
      

      would be generated as 

      unsigned char* cppOut_local = static_cast<LUTWrapper *>(cppSelf)->m_LUT_DATA_UB;
      

      as that is the type of the member variable. If I add the * and do not re-generate the wrapper, the compiler accepts this code. What is the problem in this case? I could not find any answers on stackoverflow or elsewhere on the internet, but maybe I lack the vocabulary to specify exactly what the problem is.

      In the bindings.xml I simply specify

      <object-type name="LUT" exception-handling="true"/>

      and I do not specify any special conversion functions. This only happens for pointer types of primitive-types. I have a custom histogram class for example, that also is held as a pointer in the member of another class. That wrapper generates correctly (with auto* instead of the type itself).

      I am unsure if this is a bug, or simply a small mistake somewhere in my own code. 

      For completeness:
      I am running Qt 6.7.2 with shiboken6 (-generator) version 6.7.2 and PySide6 version 6.7.2 (built from source myself) under python 3.12
      The code I am converting is C++17 compliant and built using MSVC 2019

       

      Attachments

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

        Activity

          People

            crmaurei Cristian Maureira-Fredes
            meetaig Tim Elberfeld
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes