/** * Autogenerated by Thrift for thrift/compiler/test/fixtures/encode/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/encode/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<::facebook::thrift::test::Enum>::gen(ThriftMetadata& metadata) { auto res = metadata.enums()->emplace("module.Enum", ::apache::thrift::metadata::ThriftEnum{}); if (!res.second) { return; } ::apache::thrift::metadata::ThriftEnum& enum_metadata = res.first->second; enum_metadata.name() = "module.Enum"; using EnumTraits = TEnumTraits<::facebook::thrift::test::Enum>; 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<::facebook::thrift::test::Foo>::gen(ThriftMetadata& metadata) { auto res = metadata.structs()->emplace("module.Foo", ::apache::thrift::metadata::ThriftStruct{}); if (!res.second) { return res.first->second; } ::apache::thrift::metadata::ThriftStruct& module_Foo = res.first->second; module_Foo.name() = "module.Foo"; module_Foo.is_union() = false; static const auto* const module_Foo_fields = new std::array{ { { 1, "field", false, std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE), std::vector{ }}, }}; for (const auto& f : *module_Foo_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_Foo.fields()->push_back(std::move(field)); } return res.first->second; } const ::apache::thrift::metadata::ThriftStruct& StructMetadata<::facebook::thrift::test::Bar>::gen(ThriftMetadata& metadata) { auto res = metadata.structs()->emplace("module.Bar", ::apache::thrift::metadata::ThriftStruct{}); if (!res.second) { return res.first->second; } ::apache::thrift::metadata::ThriftStruct& module_Bar = res.first->second; module_Bar.name() = "module.Bar"; module_Bar.is_union() = false; static const auto* const module_Bar_fields = new std::array{ { { 1, "list_field", false, std::make_unique(std::make_unique("module.AdaptedFoo", std::make_unique>("module.Foo"), std::vector{ *cvStruct("cpp.Adapter", { {"name", cvString("::apache::thrift::test::TemplatedTestAdapter") } }).cv_struct_ref(), })), std::vector{ }}, }}; for (const auto& f : *module_Bar_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_Bar.fields()->push_back(std::move(field)); } module_Bar.structured_annotations()->push_back(*cvStruct("cpp.UseOpEncode", { }).cv_struct_ref()); return res.first->second; } const ::apache::thrift::metadata::ThriftStruct& StructMetadata<::facebook::thrift::test::Baz>::gen(ThriftMetadata& metadata) { auto res = metadata.structs()->emplace("module.Baz", ::apache::thrift::metadata::ThriftStruct{}); if (!res.second) { return res.first->second; } ::apache::thrift::metadata::ThriftStruct& module_Baz = res.first->second; module_Baz.name() = "module.Baz"; module_Baz.is_union() = false; static const auto* const module_Baz_fields = new std::array{ { { 1, "list_field", false, std::make_unique(std::make_unique("module.AdaptedFoo", std::make_unique>("module.Foo"), std::vector{ *cvStruct("cpp.Adapter", { {"name", cvString("::apache::thrift::test::TemplatedTestAdapter") } }).cv_struct_ref(), })), std::vector{ }}, { 2, "nested_list_field", false, std::make_unique(std::make_unique(std::make_unique("module.AdaptedFoo", std::make_unique>("module.Foo"), std::vector{ *cvStruct("cpp.Adapter", { {"name", cvString("::apache::thrift::test::TemplatedTestAdapter") } }).cv_struct_ref(), }))), std::vector{ }}, }}; for (const auto& f : *module_Baz_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_Baz.fields()->push_back(std::move(field)); } return res.first->second; } const ::apache::thrift::metadata::ThriftStruct& StructMetadata<::facebook::thrift::test::OpEncodeStruct>::gen(ThriftMetadata& metadata) { auto res = metadata.structs()->emplace("module.OpEncodeStruct", ::apache::thrift::metadata::ThriftStruct{}); if (!res.second) { return res.first->second; } ::apache::thrift::metadata::ThriftStruct& module_OpEncodeStruct = res.first->second; module_OpEncodeStruct.name() = "module.OpEncodeStruct"; module_OpEncodeStruct.is_union() = false; static const auto* const module_OpEncodeStruct_fields = new std::array{ { { 1, "int_field", false, std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE), std::vector{ }}, { 2, "enum_field", false, std::make_unique>("module.Enum"), std::vector{ }}, { 3, "foo_field", false, std::make_unique>("module.Foo"), std::vector{ }}, { 4, "adapted_field", false, std::make_unique("module.AdaptedFoo", std::make_unique>("module.Foo"), std::vector{ *cvStruct("cpp.Adapter", { {"name", cvString("::apache::thrift::test::TemplatedTestAdapter") } }).cv_struct_ref(), }), std::vector{ }}, { 5, "list_field", false, std::make_unique(std::make_unique("module.AdaptedFoo", std::make_unique>("module.Foo"), std::vector{ *cvStruct("cpp.Adapter", { {"name", cvString("::apache::thrift::test::TemplatedTestAdapter") } }).cv_struct_ref(), })), std::vector{ }}, { 6, "list_shared_ptr_field", true, std::make_unique(std::make_unique("module.AdaptedFoo", std::make_unique>("module.Foo"), std::vector{ *cvStruct("cpp.Adapter", { {"name", cvString("::apache::thrift::test::TemplatedTestAdapter") } }).cv_struct_ref(), })), std::vector{ *cvStruct("cpp.Ref", { {"type", cvInteger(1) } }).cv_struct_ref(), }}, { 7, "list_cpp_type_field", false, std::make_unique(std::make_unique("module.AdaptedFoo", std::make_unique>("module.Foo"), std::vector{ *cvStruct("cpp.Adapter", { {"name", cvString("::apache::thrift::test::TemplatedTestAdapter") } }).cv_struct_ref(), })), std::vector{ }}, { 8, "set_field", false, std::make_unique(std::make_unique("module.AdaptedFoo", std::make_unique>("module.Foo"), std::vector{ *cvStruct("cpp.Adapter", { {"name", cvString("::apache::thrift::test::TemplatedTestAdapter") } }).cv_struct_ref(), })), std::vector{ }}, { 9, "map_field", false, std::make_unique(std::make_unique("module.AdaptedFoo", std::make_unique>("module.Foo"), std::vector{ *cvStruct("cpp.Adapter", { {"name", cvString("::apache::thrift::test::TemplatedTestAdapter") } }).cv_struct_ref(), }), std::make_unique("module.AdaptedFoo", std::make_unique>("module.Foo"), std::vector{ *cvStruct("cpp.Adapter", { {"name", cvString("::apache::thrift::test::TemplatedTestAdapter") } }).cv_struct_ref(), })), std::vector{ }}, { 10, "nested_field", false, std::make_unique(std::make_unique(ThriftPrimitiveType::THRIFT_I32_TYPE), std::make_unique(std::make_unique("module.AdaptedFoo", std::make_unique>("module.Foo"), std::vector{ *cvStruct("cpp.Adapter", { {"name", cvString("::apache::thrift::test::TemplatedTestAdapter") } }).cv_struct_ref(), }))), std::vector{ }}, { 11, "bar_field", false, std::make_unique>("module.Bar"), std::vector{ }}, { 12, "adapted_list_field", false, std::make_unique(std::make_unique("module.AdaptedFoo", std::make_unique>("module.Foo"), std::vector{ *cvStruct("cpp.Adapter", { {"name", cvString("::apache::thrift::test::TemplatedTestAdapter") } }).cv_struct_ref(), })), std::vector{ *cvStruct("cpp.Adapter", { {"name", cvString("::FieldAdapter") } }).cv_struct_ref(), }}, }}; for (const auto& f : *module_OpEncodeStruct_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_OpEncodeStruct.fields()->push_back(std::move(field)); } module_OpEncodeStruct.structured_annotations()->push_back(*cvStruct("cpp.UseOpEncode", { }).cv_struct_ref()); return res.first->second; } } // namespace md } // namespace detail } // namespace thrift } // namespace apache