Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-50101

Allow IDL usage to represent cpp_type of C++ Enum

    • Type: Icon: Task Task
    • Resolution: Declined
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Service Arch

      For example, I want to define the following:

      types:
        fcv_string:
          bson_serialization_type: string
          description: >-
            Ensures that the version strings in featureCompatibilityVersion documents
            serialize/deserialize to a fixed set of string values
          cpp_type: "ServerGlobalParams::FeatureCompatibility::Version"
          serializer: "::mongo::FeatureCompatibilityVersionParser::serializeVersion"
          deserializer: "mongo::FeatureCompatibilityVersionParser::parseVersion"
      

      ServerGlobalParams::FeatureCompatibility::Version is of type C++ enum, which has no default constructor/initialize value. Therefore, IDL ends up generating C++ code that will not compile:

      build/opt/mongo/db/commands/set_feature_compatibility_version_gen.cpp:42:50: error: variable 'localCmdType' is uninitialized when used here [-Werror,-Wuninitialized]
          SetFeatureCompatibilityVersionCommand object(localCmdType);
                                                       ^~~~~~~~~~~~
      build/opt/mongo/db/commands/set_feature_compatibility_version_gen.cpp:41:5: note: variable 'localCmdType' is declared here
          ServerGlobalParams::FeatureCompatibility::Version localCmdType;
          ^
      

      It would be nice for IDL to support C++ Enum types in this regard.

            Assignee:
            backlog-server-servicearch [DO NOT USE] Backlog - Service Architecture
            Reporter:
            jason.chan@mongodb.com Jason Chan
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: