/** * Autogenerated by Thrift for thrift/compiler/test/fixtures/optionals/src/module.thrift * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated @nocommit */ #include #include "thrift/compiler/test/fixtures/optionals/gen-cpp2/module_metadata.h" // some of these functions can be so large that the compiler gives up optimizing // them - and issues a warning which may be treated as an error! // // these functions are so rarely called that it is probably okay for them not to // be optimized in practice FOLLY_CLANG_DISABLE_WARNING("-Wignored-optimization-argument") namespace apache { namespace thrift { namespace detail { namespace md { using ThriftMetadata = ::apache::thrift::metadata::ThriftMetadata; using ThriftPrimitiveType = ::apache::thrift::metadata::ThriftPrimitiveType; using ThriftType = ::apache::thrift::metadata::ThriftType; using ThriftService = ::apache::thrift::metadata::ThriftService; using ThriftServiceContext = ::apache::thrift::metadata::ThriftServiceContext; using ThriftFunctionGenerator = void (*)(ThriftMetadata&, ThriftService&); void EnumMetadata<::cpp2::Animal>::gen(ThriftMetadata& metadata) { auto res = metadata.enums()->emplace("module.Animal", ::apache::thrift::metadata::ThriftEnum{}); if (!res.second) { return; } ::apache::thrift::metadata::ThriftEnum& enum_metadata = res.first->second; enum_metadata.name() = "module.Animal"; using EnumTraits = TEnumTraits<::cpp2::Animal>; for (std::size_t i = 0; i != EnumTraits::size; ++i) { enum_metadata.elements()->emplace(static_cast(EnumTraits::values[i]), EnumTraits::names[i]); } } const ::apache::thrift::metadata::ThriftStruct& StructMetadata<::cpp2::Color>::gen(ThriftMetadata& metadata) { auto res = metadata.structs()->emplace("module.Color", ::apache::thrift::metadata::ThriftStruct{}); if (!res.second) { return res.first->second; } ::apache::thrift::metadata::ThriftStruct& module_Color = res.first->second; module_Color.name() = "module.Color"; module_Color.is_union() = false; static const auto* const module_Color_fields = new std::array{ { { 1, "red", false, std::make_unique(ThriftPrimitiveType::THRIFT_DOUBLE_TYPE), std::vector{ }}, { 2, "green", false, std::make_unique(ThriftPrimitiveType::THRIFT_DOUBLE_TYPE), std::vector{ }}, { 3, "blue", false, std::make_unique(ThriftPrimitiveType::THRIFT_DOUBLE_TYPE), std::vector{ }}, { 4, "alpha", false, std::make_unique(ThriftPrimitiveType::THRIFT_DOUBLE_TYPE), std::vector{ }}, }}; for (const auto& f : *module_Color_fields) { ::apache::thrift::metadata::ThriftField field; field.id() = f.id; field.name() = f.name; field.is_optional() = f.is_optional; f.metadata_type_interface->writeAndGenType(*field.type(), metadata); field.structured_annotations() = f.structured_annotations; module_Color.fields()->push_back(std::move(field)); } return res.first->second; } const ::apache::thrift::metadata::ThriftStruct& StructMetadata<::cpp2::Vehicle>::gen(ThriftMetadata& metadata) { auto res = metadata.structs()->emplace("module.Vehicle", ::apache::thrift::metadata::ThriftStruct{}); if (!res.second) { return res.first->second; } ::apache::thrift::metadata::ThriftStruct& module_Vehicle = res.first->second; module_Vehicle.name() = "module.Vehicle"; module_Vehicle.is_union() = false; static const auto* const module_Vehicle_fields = new std::array{ { { 1, "color", false, std::make_unique>("module.Color"), std::vector{ }}, { 2, "licensePlate", true, std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::vector{ }}, { 3, "description", true, std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::vector{ }}, { 4, "name", true, std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::vector{ }}, { 5, "hasAC", true, std::make_unique(ThriftPrimitiveType::THRIFT_BOOL_TYPE), std::vector{ }}, }}; for (const auto& f : *module_Vehicle_fields) { ::apache::thrift::metadata::ThriftField field; field.id() = f.id; field.name() = f.name; field.is_optional() = f.is_optional; f.metadata_type_interface->writeAndGenType(*field.type(), metadata); field.structured_annotations() = f.structured_annotations; module_Vehicle.fields()->push_back(std::move(field)); } return res.first->second; } const ::apache::thrift::metadata::ThriftStruct& StructMetadata<::cpp2::Person>::gen(ThriftMetadata& metadata) { auto res = metadata.structs()->emplace("module.Person", ::apache::thrift::metadata::ThriftStruct{}); if (!res.second) { return res.first->second; } ::apache::thrift::metadata::ThriftStruct& module_Person = res.first->second; module_Person.name() = "module.Person"; module_Person.is_union() = false; static const auto* const module_Person_fields = new std::array{ { { 1, "id", false, std::make_unique("module.PersonID", std::make_unique(ThriftPrimitiveType::THRIFT_I64_TYPE), std::vector{ }), std::vector{ }}, { 2, "name", false, std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::vector{ }}, { 3, "age", true, std::make_unique(ThriftPrimitiveType::THRIFT_I16_TYPE), std::vector{ }}, { 4, "address", true, std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::vector{ }}, { 5, "favoriteColor", true, std::make_unique>("module.Color"), std::vector{ }}, { 6, "friends", true, std::make_unique(std::make_unique("module.PersonID", std::make_unique(ThriftPrimitiveType::THRIFT_I64_TYPE), std::vector{ })), std::vector{ }}, { 7, "bestFriend", true, std::make_unique("module.PersonID", std::make_unique(ThriftPrimitiveType::THRIFT_I64_TYPE), std::vector{ }), std::vector{ }}, { 8, "petNames", true, std::make_unique(std::make_unique>("module.Animal"), std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE)), std::vector{ }}, { 9, "afraidOfAnimal", true, std::make_unique>("module.Animal"), std::vector{ }}, { 10, "vehicles", true, std::make_unique(std::make_unique>("module.Vehicle")), std::vector{ }}, }}; for (const auto& f : *module_Person_fields) { ::apache::thrift::metadata::ThriftField field; field.id() = f.id; field.name() = f.name; field.is_optional() = f.is_optional; f.metadata_type_interface->writeAndGenType(*field.type(), metadata); field.structured_annotations() = f.structured_annotations; module_Person.fields()->push_back(std::move(field)); } return res.first->second; } } // namespace md } // namespace detail } // namespace thrift } // namespace apache