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

Nesting enums should be declared outside the C++ classes

XMLWordPrintable

    • Icon: Task Task
    • Resolution: Fixed
    • Icon: P1: Critical P1: Critical
    • 6.7.0 FF
    • 6.5, 6.6, dev
    • Protocol Buffers
    • None

      Current implementation doesn't allow forward declaration the nested enumerations. This leads to the issue when we want to use the following protobuf construction, that is legal from protobuf syntax point of view:

      message A {
          enum AEnum {
              AVal0 = 0;
              AVal1 = 1;
          }
          B.BEnum val = 1;
      }
      
      message B {
          enum BEnum {
              BVal0 = 0;
              BVal1 = 1;
          }
          A.AEnum val = 1;
      }
      

      The resulting code refelects the .proto structure and as the result A::val accesses the inclomplete type:

      error: invalid use of incomplete type ‘class qtprotobufnamespace::tests::B’
        <num> |     B::BEnum val() const;
      

      To support this, we should make the same trick that we already made for netsted messages - put all enumerations to the nested namespaces, but not nest them into containing messages.

      This is major refactoring that breaks compatibility and has impact on meta-object model that will be generated.

      We need to make sure that all enums are still accessible from both C++ and QML code using the message-based qualifiers.

      Global or package enums use the similar concept so we should follow it.

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

            semlanik Alexey Edelev
            semlanik Alexey Edelev
            Vladimir Minenko Vladimir Minenko
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes