1 /**
2 * Autogenerated by Thrift for src/module.thrift
3 *
4 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5 * @generated @nocommit
6 */
7 #include <thrift/lib/cpp2/gen/module_metadata_cpp.h>
8 #include "thrift/compiler/test/fixtures/tablebased/gen-cpp2/module_metadata.h"
9
10 namespace apache {
11 namespace thrift {
12 namespace detail {
13 namespace md {
14 using ThriftMetadata = ::apache::thrift::metadata::ThriftMetadata;
15 using ThriftPrimitiveType = ::apache::thrift::metadata::ThriftPrimitiveType;
16 using ThriftType = ::apache::thrift::metadata::ThriftType;
17 using ThriftService = ::apache::thrift::metadata::ThriftService;
18 using ThriftServiceContext = ::apache::thrift::metadata::ThriftServiceContext;
19 using ThriftFunctionGenerator = void (*)(ThriftMetadata&, ThriftService&);
20
gen(ThriftMetadata & metadata)21 void EnumMetadata<::test::fixtures::tablebased::ExampleEnum>::gen(ThriftMetadata& metadata) {
22 auto res = metadata.enums_ref()->emplace("module.ExampleEnum", ::apache::thrift::metadata::ThriftEnum{});
23 if (!res.second) {
24 return;
25 }
26 ::apache::thrift::metadata::ThriftEnum& enum_metadata = res.first->second;
27 enum_metadata.name_ref() = "module.ExampleEnum";
28 using EnumTraits = TEnumTraits<::test::fixtures::tablebased::ExampleEnum>;
29 for (std::size_t i = 0; i < EnumTraits::size; ++i) {
30 enum_metadata.elements_ref()->emplace(static_cast<int32_t>(EnumTraits::values[i]), EnumTraits::names[i].str());
31 }
32 }
33
34 const ::apache::thrift::metadata::ThriftStruct&
gen(ThriftMetadata & metadata)35 StructMetadata<::test::fixtures::tablebased::TrivialTypesStruct>::gen(ThriftMetadata& metadata) {
36 auto res = metadata.structs_ref()->emplace("module.TrivialTypesStruct", ::apache::thrift::metadata::ThriftStruct{});
37 if (!res.second) {
38 return res.first->second;
39 }
40 ::apache::thrift::metadata::ThriftStruct& module_TrivialTypesStruct = res.first->second;
41 module_TrivialTypesStruct.name_ref() = "module.TrivialTypesStruct";
42 module_TrivialTypesStruct.is_union_ref() = false;
43 static const EncodedThriftField
44 module_TrivialTypesStruct_fields[] = {
45 {1, "fieldA", true, std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_I32_TYPE), std::vector<ThriftConstStruct>{}},
46 {2, "fieldB", true, std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::vector<ThriftConstStruct>{}},
47 {3, "fieldC", true, std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_BINARY_TYPE), std::vector<ThriftConstStruct>{}},
48 {4, "fieldD", true, std::make_unique<Typedef>("module.IOBufPtr", std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_BINARY_TYPE), std::vector<ThriftConstStruct>{}), std::vector<ThriftConstStruct>{}},
49 {5, "fieldE", false, std::make_unique<Enum< ::test::fixtures::tablebased::ExampleEnum>>("module.ExampleEnum"), std::vector<ThriftConstStruct>{}},
50 };
51 for (const auto& f : module_TrivialTypesStruct_fields) {
52 ::apache::thrift::metadata::ThriftField field;
53 field.id_ref() = f.id;
54 field.name_ref() = f.name;
55 field.is_optional_ref() = f.is_optional;
56 f.metadata_type_interface->writeAndGenType(*field.type_ref(), metadata);
57 field.structured_annotations_ref() = f.structured_annotations;
58 module_TrivialTypesStruct.fields_ref()->push_back(std::move(field));
59 }
60 return res.first->second;
61 }
62 const ::apache::thrift::metadata::ThriftStruct&
gen(ThriftMetadata & metadata)63 StructMetadata<::test::fixtures::tablebased::ContainerStruct>::gen(ThriftMetadata& metadata) {
64 auto res = metadata.structs_ref()->emplace("module.ContainerStruct", ::apache::thrift::metadata::ThriftStruct{});
65 if (!res.second) {
66 return res.first->second;
67 }
68 ::apache::thrift::metadata::ThriftStruct& module_ContainerStruct = res.first->second;
69 module_ContainerStruct.name_ref() = "module.ContainerStruct";
70 module_ContainerStruct.is_union_ref() = false;
71 static const EncodedThriftField
72 module_ContainerStruct_fields[] = {
73 {12, "fieldA", false, std::make_unique<List>(std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_I32_TYPE)), std::vector<ThriftConstStruct>{}},
74 {2, "fieldB", false, std::make_unique<List>(std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_I32_TYPE)), std::vector<ThriftConstStruct>{}},
75 {3, "fieldC", false, std::make_unique<List>(std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_I32_TYPE)), std::vector<ThriftConstStruct>{}},
76 {4, "fieldD", false, std::make_unique<List>(std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_I32_TYPE)), std::vector<ThriftConstStruct>{}},
77 {5, "fieldE", false, std::make_unique<List>(std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_I32_TYPE)), std::vector<ThriftConstStruct>{}},
78 {6, "fieldF", false, std::make_unique<Set>(std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_I32_TYPE)), std::vector<ThriftConstStruct>{}},
79 {7, "fieldG", false, std::make_unique<Map>(std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_I32_TYPE), std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_STRING_TYPE)), std::vector<ThriftConstStruct>{}},
80 {8, "fieldH", false, std::make_unique<List>(std::make_unique<Struct< ::test::fixtures::tablebased::TrivialTypesStruct>>("module.TrivialTypesStruct")), std::vector<ThriftConstStruct>{}},
81 };
82 for (const auto& f : module_ContainerStruct_fields) {
83 ::apache::thrift::metadata::ThriftField field;
84 field.id_ref() = f.id;
85 field.name_ref() = f.name;
86 field.is_optional_ref() = f.is_optional;
87 f.metadata_type_interface->writeAndGenType(*field.type_ref(), metadata);
88 field.structured_annotations_ref() = f.structured_annotations;
89 module_ContainerStruct.fields_ref()->push_back(std::move(field));
90 }
91 return res.first->second;
92 }
93 const ::apache::thrift::metadata::ThriftStruct&
gen(ThriftMetadata & metadata)94 StructMetadata<::test::fixtures::tablebased::ExampleUnion>::gen(ThriftMetadata& metadata) {
95 auto res = metadata.structs_ref()->emplace("module.ExampleUnion", ::apache::thrift::metadata::ThriftStruct{});
96 if (!res.second) {
97 return res.first->second;
98 }
99 ::apache::thrift::metadata::ThriftStruct& module_ExampleUnion = res.first->second;
100 module_ExampleUnion.name_ref() = "module.ExampleUnion";
101 module_ExampleUnion.is_union_ref() = true;
102 static const EncodedThriftField
103 module_ExampleUnion_fields[] = {
104 {1, "fieldA", false, std::make_unique<Struct< ::test::fixtures::tablebased::ContainerStruct>>("module.ContainerStruct"), std::vector<ThriftConstStruct>{}},
105 {2, "fieldB", false, std::make_unique<Struct< ::test::fixtures::tablebased::TrivialTypesStruct>>("module.TrivialTypesStruct"), std::vector<ThriftConstStruct>{}},
106 };
107 for (const auto& f : module_ExampleUnion_fields) {
108 ::apache::thrift::metadata::ThriftField field;
109 field.id_ref() = f.id;
110 field.name_ref() = f.name;
111 field.is_optional_ref() = f.is_optional;
112 f.metadata_type_interface->writeAndGenType(*field.type_ref(), metadata);
113 field.structured_annotations_ref() = f.structured_annotations;
114 module_ExampleUnion.fields_ref()->push_back(std::move(field));
115 }
116 return res.first->second;
117 }
118
119 } // namespace md
120 } // namespace detail
121 } // namespace thrift
122 } // namespace apache
123