@@ -601,75 +601,8 @@ using namespace std::literals;
601601 outputGetRequestImplementation (sourceFile);
602602
603603 const auto & operations = _requestLoader.getOperations ();
604- std::unordered_set<std::string_view> outputEnumNames;
605604 std::unordered_set<std::string_view> outputInputMethods;
606605
607- for (const auto & operation : operations)
608- {
609- for (const auto & enumType : _requestLoader.getReferencedEnums (operation))
610- {
611- const auto cppType = _schemaLoader.getCppType (enumType->name ());
612-
613- if (!outputEnumNames.insert (cppType).second )
614- {
615- continue ;
616- }
617-
618- pendingSeparator.reset ();
619-
620- const auto & enumValues = enumType->enumValues ();
621-
622- sourceFile << R"cpp( static const std::array<std::string_view, )cpp" << enumValues.size ()
623- << R"cpp( > s_names)cpp" << cppType << R"cpp( = {)cpp" ;
624-
625- bool firstValue = true ;
626-
627- for (const auto & enumValue : enumValues)
628- {
629- if (!firstValue)
630- {
631- sourceFile << R"cpp( ,)cpp" ;
632- }
633-
634- firstValue = false ;
635- sourceFile << R"cpp(
636- R"gql()cpp" << enumValue->name ()
637- << R"cpp( )gql"sv)cpp" ;
638- pendingSeparator.add ();
639- }
640-
641- pendingSeparator.reset ();
642- sourceFile << R"cpp( };
643-
644- static const std::array<std::pair<std::string_view, )cpp"
645- << cppType << R"cpp( >, )cpp" << enumValues.size () << R"cpp( > s_values)cpp"
646- << cppType << R"cpp( = {)cpp" ;
647-
648- firstValue = true ;
649-
650- for (const auto & enumValue : enumValues)
651- {
652- if (!firstValue)
653- {
654- sourceFile << R"cpp( ,)cpp" ;
655- }
656-
657- firstValue = false ;
658- sourceFile << R"cpp(
659- std::make_pair(R"gql()cpp"
660- << enumValue->name () << R"cpp( )gql"sv, )cpp" << cppType << R"cpp( ::)cpp"
661- << SchemaLoader::getSafeCppName (enumValue->name ()) << R"cpp( ))cpp" ;
662- pendingSeparator.add ();
663- }
664-
665- pendingSeparator.reset ();
666- sourceFile << R"cpp( };
667- )cpp" ;
668-
669- pendingSeparator.add ();
670- }
671- }
672-
673606 for (const auto & operation : operations)
674607 {
675608 for (const auto & inputType : _requestLoader.getReferencedInputTypes (operation))
@@ -808,8 +741,10 @@ using namespace )cpp"
808741
809742 pendingSeparator.add ();
810743
744+ std::unordered_set<std::string_view> outputEnumNames;
811745 std::unordered_set<std::string_view> outputModifiedVariableEnum;
812746 std::unordered_set<std::string_view> outputModifiedVariableInput;
747+ std::unordered_set<std::string_view> outputEnumValues;
813748 std::unordered_set<std::string_view> outputModifiedResponseEnum;
814749
815750 for (const auto & operation : operations)
@@ -827,24 +762,52 @@ using namespace )cpp"
827762 continue ;
828763 }
829764
765+ if (outputEnumNames.insert (cppType).second )
766+ {
767+ pendingSeparator.reset ();
768+
769+ const auto & enumValues = enumType->enumValues ();
770+
771+ sourceFile << R"cpp( static const std::array<std::string_view, )cpp"
772+ << enumValues.size () << R"cpp( > s_names)cpp" << cppType
773+ << R"cpp( = {)cpp" ;
774+
775+ bool firstValue = true ;
776+
777+ for (const auto & enumValue : enumValues)
778+ {
779+ if (!firstValue)
780+ {
781+ sourceFile << R"cpp( ,)cpp" ;
782+ }
783+
784+ firstValue = false ;
785+ sourceFile << R"cpp(
786+ R"gql()cpp" << enumValue->name ()
787+ << R"cpp( )gql"sv)cpp" ;
788+ pendingSeparator.add ();
789+ }
790+
791+ pendingSeparator.reset ();
792+ sourceFile << R"cpp( };
793+
794+ )cpp" ;
795+ }
796+
830797 pendingSeparator.reset ();
831798
832- if (!variables.empty ())
833- {
834- sourceFile << R"cpp( template <>
799+ sourceFile << R"cpp( template <>
835800response::Value ModifiedVariable<)cpp"
836- << cppType << R"cpp( >::serialize()cpp" << cppType << R"cpp( && value)
801+ << cppType << R"cpp( >::serialize()cpp" << cppType << R"cpp( && value)
837802{
838803 response::Value result { response::Type::EnumValue };
839804
840805 result.set<std::string>(std::string { s_names)cpp"
841- << cppType << R"cpp( [static_cast<size_t>(value)] });
806+ << cppType << R"cpp( [static_cast<size_t>(value)] });
842807
843808 return result;
844809}
845810)cpp" ;
846- }
847-
848811 pendingSeparator.add ();
849812 }
850813
@@ -900,6 +863,40 @@ response::Value ModifiedVariable<)cpp"
900863 continue ;
901864 }
902865
866+ if (outputEnumValues.insert (cppType).second )
867+ {
868+ pendingSeparator.reset ();
869+
870+ const auto & enumValues = enumType->enumValues ();
871+
872+ sourceFile << R"cpp( static const std::array<std::pair<std::string_view, )cpp"
873+ << cppType << R"cpp( >, )cpp" << enumValues.size ()
874+ << R"cpp( > s_values)cpp" << cppType << R"cpp( = {)cpp" ;
875+
876+ bool firstValue = true ;
877+
878+ for (const auto & enumValue : enumValues)
879+ {
880+ if (!firstValue)
881+ {
882+ sourceFile << R"cpp( ,)cpp" ;
883+ }
884+
885+ firstValue = false ;
886+ sourceFile << R"cpp(
887+ std::make_pair(R"gql()cpp" << enumValue->name ()
888+ << R"cpp( )gql"sv, )cpp" << cppType << R"cpp( ::)cpp"
889+ << SchemaLoader::getSafeCppName (enumValue->name ()) << R"cpp( ))cpp" ;
890+ pendingSeparator.add ();
891+ }
892+
893+ pendingSeparator.reset ();
894+ sourceFile << R"cpp( };
895+ )cpp" ;
896+
897+ pendingSeparator.add ();
898+ }
899+
903900 pendingSeparator.reset ();
904901
905902 sourceFile << R"cpp( template <>
0 commit comments