Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-76888

MOC does not generate output for `using` keyword in namespace

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.12.4
    • Build tools: moc
    • None
    • All

    Description

      When creating namespace to allow qml usage of enum class types, like:

      enum class PingDeviceType {
          UNKNOWN = 0,
      };
      
      namespace PingDeviceTypeNamespace {
      Q_NAMESPACE
          using ::PingDeviceType;
          enum Enum {
              TestA = 1,
          };
          enum class EnumClass {
              TestB = 2,
          };
      Q_ENUM_NS(PingDeviceType)
      Q_ENUM_NS(Enum)
      Q_ENUM_NS(EnumClass)
      }
      

      Moc outputs the following code:

      static const qt_meta_stringdata_PingDeviceTypeNamespace_t qt_meta_stringdata_PingDeviceTypeNamespace = {
          {
      QT_MOC_LITERAL(0, 0, 23), // "PingDeviceTypeNamespace"
      QT_MOC_LITERAL(1, 24, 4), // "Enum"
      QT_MOC_LITERAL(2, 29, 5), // "TestA"
      QT_MOC_LITERAL(3, 35, 9), // "EnumClass"
      QT_MOC_LITERAL(4, 45, 5) // "TestB"
      
          },
          "PingDeviceTypeNamespace\0Enum\0TestA\0"
          "EnumClass\0TestB"
      };
      #undef QT_MOC_LITERAL
      
      static const uint qt_meta_data_PingDeviceTypeNamespace[] = {
      
       // content:
             8,       // revision
             0,       // classname
             0,    0, // classinfo
             0,    0, // methods
             0,    0, // properties
             2,   14, // enums/sets
             0,    0, // constructors
             4,       // flags
             0,       // signalCount
      
       // enums: name, alias, flags, count, data
             1,    1, 0x0,    1,   24,
             3,    3, 0x2,    1,   26,
      
       // enum data: key, value
             2, uint(PingDeviceTypeNamespace::TestA),
             4, uint(PingDeviceTypeNamespace::EnumClass::TestB),
      
             0        // eod
      };
      

      As you can see, the final result does not replicate what is being declared in the initial declaration.

      Attachments

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

        Activity

          People

            Unassigned Unassigned
            patrickelectric Patrick Pereira
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes