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/types/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<::apache::thrift::fixtures::types::has_bitwise_ops>::gen(ThriftMetadata& metadata) {
22 auto res = metadata.enums_ref()->emplace("module.has_bitwise_ops", ::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.has_bitwise_ops";
28 using EnumTraits = TEnumTraits<::apache::thrift::fixtures::types::has_bitwise_ops>;
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 }
gen(ThriftMetadata & metadata)33 void EnumMetadata<::apache::thrift::fixtures::types::is_unscoped>::gen(ThriftMetadata& metadata) {
34 auto res = metadata.enums_ref()->emplace("module.is_unscoped", ::apache::thrift::metadata::ThriftEnum{});
35 if (!res.second) {
36 return;
37 }
38 ::apache::thrift::metadata::ThriftEnum& enum_metadata = res.first->second;
39 enum_metadata.name_ref() = "module.is_unscoped";
40 using EnumTraits = TEnumTraits<::apache::thrift::fixtures::types::is_unscoped>;
41 for (std::size_t i = 0; i < EnumTraits::size; ++i) {
42 enum_metadata.elements_ref()->emplace(static_cast<int32_t>(EnumTraits::values[i]), EnumTraits::names[i].str());
43 }
44 }
gen(ThriftMetadata & metadata)45 void EnumMetadata<::apache::thrift::fixtures::types::MyForwardRefEnum>::gen(ThriftMetadata& metadata) {
46 auto res = metadata.enums_ref()->emplace("module.MyForwardRefEnum", ::apache::thrift::metadata::ThriftEnum{});
47 if (!res.second) {
48 return;
49 }
50 ::apache::thrift::metadata::ThriftEnum& enum_metadata = res.first->second;
51 enum_metadata.name_ref() = "module.MyForwardRefEnum";
52 using EnumTraits = TEnumTraits<::apache::thrift::fixtures::types::MyForwardRefEnum>;
53 for (std::size_t i = 0; i < EnumTraits::size; ++i) {
54 enum_metadata.elements_ref()->emplace(static_cast<int32_t>(EnumTraits::values[i]), EnumTraits::names[i].str());
55 }
56 }
gen(ThriftMetadata & metadata)57 void EnumMetadata<::apache::thrift::fixtures::types::MyEnumA>::gen(ThriftMetadata& metadata) {
58 auto res = metadata.enums_ref()->emplace("module.MyEnumA", ::apache::thrift::metadata::ThriftEnum{});
59 if (!res.second) {
60 return;
61 }
62 ::apache::thrift::metadata::ThriftEnum& enum_metadata = res.first->second;
63 enum_metadata.name_ref() = "module.MyEnumA";
64 using EnumTraits = TEnumTraits<::apache::thrift::fixtures::types::MyEnumA>;
65 for (std::size_t i = 0; i < EnumTraits::size; ++i) {
66 enum_metadata.elements_ref()->emplace(static_cast<int32_t>(EnumTraits::values[i]), EnumTraits::names[i].str());
67 }
68 }
69
70 const ::apache::thrift::metadata::ThriftStruct&
gen(ThriftMetadata & metadata)71 StructMetadata<::apache::thrift::fixtures::types::decorated_struct>::gen(ThriftMetadata& metadata) {
72 auto res = metadata.structs_ref()->emplace("module.decorated_struct", ::apache::thrift::metadata::ThriftStruct{});
73 if (!res.second) {
74 return res.first->second;
75 }
76 ::apache::thrift::metadata::ThriftStruct& module_decorated_struct = res.first->second;
77 module_decorated_struct.name_ref() = "module.decorated_struct";
78 module_decorated_struct.is_union_ref() = false;
79 static const EncodedThriftField
80 module_decorated_struct_fields[] = {
81 {1, "field", false, std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::vector<ThriftConstStruct>{}},
82 };
83 for (const auto& f : module_decorated_struct_fields) {
84 ::apache::thrift::metadata::ThriftField field;
85 field.id_ref() = f.id;
86 field.name_ref() = f.name;
87 field.is_optional_ref() = f.is_optional;
88 f.metadata_type_interface->writeAndGenType(*field.type_ref(), metadata);
89 field.structured_annotations_ref() = f.structured_annotations;
90 module_decorated_struct.fields_ref()->push_back(std::move(field));
91 }
92 return res.first->second;
93 }
94 const ::apache::thrift::metadata::ThriftStruct&
gen(ThriftMetadata & metadata)95 StructMetadata<::apache::thrift::fixtures::types::ContainerStruct>::gen(ThriftMetadata& metadata) {
96 auto res = metadata.structs_ref()->emplace("module.ContainerStruct", ::apache::thrift::metadata::ThriftStruct{});
97 if (!res.second) {
98 return res.first->second;
99 }
100 ::apache::thrift::metadata::ThriftStruct& module_ContainerStruct = res.first->second;
101 module_ContainerStruct.name_ref() = "module.ContainerStruct";
102 module_ContainerStruct.is_union_ref() = false;
103 static const EncodedThriftField
104 module_ContainerStruct_fields[] = {
105 {12, "fieldA", false, std::make_unique<List>(std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_I32_TYPE)), std::vector<ThriftConstStruct>{}},
106 {2, "fieldB", false, std::make_unique<List>(std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_I32_TYPE)), std::vector<ThriftConstStruct>{}},
107 {3, "fieldC", false, std::make_unique<List>(std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_I32_TYPE)), std::vector<ThriftConstStruct>{}},
108 {4, "fieldD", false, std::make_unique<List>(std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_I32_TYPE)), std::vector<ThriftConstStruct>{}},
109 {5, "fieldE", false, std::make_unique<List>(std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_I32_TYPE)), std::vector<ThriftConstStruct>{}},
110 {6, "fieldF", false, std::make_unique<Set>(std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_I32_TYPE)), std::vector<ThriftConstStruct>{}},
111 {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>{}},
112 {8, "fieldH", false, std::make_unique<Typedef>("include.SomeMap", std::make_unique<Map>(std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_I32_TYPE), std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_STRING_TYPE)), std::vector<ThriftConstStruct>{}), std::vector<ThriftConstStruct>{}},
113 };
114 for (const auto& f : module_ContainerStruct_fields) {
115 ::apache::thrift::metadata::ThriftField field;
116 field.id_ref() = f.id;
117 field.name_ref() = f.name;
118 field.is_optional_ref() = f.is_optional;
119 f.metadata_type_interface->writeAndGenType(*field.type_ref(), metadata);
120 field.structured_annotations_ref() = f.structured_annotations;
121 module_ContainerStruct.fields_ref()->push_back(std::move(field));
122 }
123 return res.first->second;
124 }
125 const ::apache::thrift::metadata::ThriftStruct&
gen(ThriftMetadata & metadata)126 StructMetadata<::apache::thrift::fixtures::types::CppTypeStruct>::gen(ThriftMetadata& metadata) {
127 auto res = metadata.structs_ref()->emplace("module.CppTypeStruct", ::apache::thrift::metadata::ThriftStruct{});
128 if (!res.second) {
129 return res.first->second;
130 }
131 ::apache::thrift::metadata::ThriftStruct& module_CppTypeStruct = res.first->second;
132 module_CppTypeStruct.name_ref() = "module.CppTypeStruct";
133 module_CppTypeStruct.is_union_ref() = false;
134 static const EncodedThriftField
135 module_CppTypeStruct_fields[] = {
136 {1, "fieldA", false, std::make_unique<List>(std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_I32_TYPE)), std::vector<ThriftConstStruct>{}},
137 };
138 for (const auto& f : module_CppTypeStruct_fields) {
139 ::apache::thrift::metadata::ThriftField field;
140 field.id_ref() = f.id;
141 field.name_ref() = f.name;
142 field.is_optional_ref() = f.is_optional;
143 f.metadata_type_interface->writeAndGenType(*field.type_ref(), metadata);
144 field.structured_annotations_ref() = f.structured_annotations;
145 module_CppTypeStruct.fields_ref()->push_back(std::move(field));
146 }
147 return res.first->second;
148 }
149 const ::apache::thrift::metadata::ThriftStruct&
gen(ThriftMetadata & metadata)150 StructMetadata<::apache::thrift::fixtures::types::VirtualStruct>::gen(ThriftMetadata& metadata) {
151 auto res = metadata.structs_ref()->emplace("module.VirtualStruct", ::apache::thrift::metadata::ThriftStruct{});
152 if (!res.second) {
153 return res.first->second;
154 }
155 ::apache::thrift::metadata::ThriftStruct& module_VirtualStruct = res.first->second;
156 module_VirtualStruct.name_ref() = "module.VirtualStruct";
157 module_VirtualStruct.is_union_ref() = false;
158 static const EncodedThriftField
159 module_VirtualStruct_fields[] = {
160 {1, "MyIntField", false, std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_I64_TYPE), std::vector<ThriftConstStruct>{}},
161 };
162 for (const auto& f : module_VirtualStruct_fields) {
163 ::apache::thrift::metadata::ThriftField field;
164 field.id_ref() = f.id;
165 field.name_ref() = f.name;
166 field.is_optional_ref() = f.is_optional;
167 f.metadata_type_interface->writeAndGenType(*field.type_ref(), metadata);
168 field.structured_annotations_ref() = f.structured_annotations;
169 module_VirtualStruct.fields_ref()->push_back(std::move(field));
170 }
171 return res.first->second;
172 }
173 const ::apache::thrift::metadata::ThriftStruct&
gen(ThriftMetadata & metadata)174 StructMetadata<::apache::thrift::fixtures::types::MyStructWithForwardRefEnum>::gen(ThriftMetadata& metadata) {
175 auto res = metadata.structs_ref()->emplace("module.MyStructWithForwardRefEnum", ::apache::thrift::metadata::ThriftStruct{});
176 if (!res.second) {
177 return res.first->second;
178 }
179 ::apache::thrift::metadata::ThriftStruct& module_MyStructWithForwardRefEnum = res.first->second;
180 module_MyStructWithForwardRefEnum.name_ref() = "module.MyStructWithForwardRefEnum";
181 module_MyStructWithForwardRefEnum.is_union_ref() = false;
182 static const EncodedThriftField
183 module_MyStructWithForwardRefEnum_fields[] = {
184 {1, "a", false, std::make_unique<Typedef>("module.MyForwardRefEnum", std::make_unique<Enum< ::apache::thrift::fixtures::types::MyForwardRefEnum>>("module.MyForwardRefEnum"), std::vector<ThriftConstStruct>{}), std::vector<ThriftConstStruct>{}},
185 {2, "b", false, std::make_unique<Typedef>("module.MyForwardRefEnum", std::make_unique<Enum< ::apache::thrift::fixtures::types::MyForwardRefEnum>>("module.MyForwardRefEnum"), std::vector<ThriftConstStruct>{}), std::vector<ThriftConstStruct>{}},
186 };
187 for (const auto& f : module_MyStructWithForwardRefEnum_fields) {
188 ::apache::thrift::metadata::ThriftField field;
189 field.id_ref() = f.id;
190 field.name_ref() = f.name;
191 field.is_optional_ref() = f.is_optional;
192 f.metadata_type_interface->writeAndGenType(*field.type_ref(), metadata);
193 field.structured_annotations_ref() = f.structured_annotations;
194 module_MyStructWithForwardRefEnum.fields_ref()->push_back(std::move(field));
195 }
196 return res.first->second;
197 }
198 const ::apache::thrift::metadata::ThriftStruct&
gen(ThriftMetadata & metadata)199 StructMetadata<::apache::thrift::fixtures::types::TrivialNumeric>::gen(ThriftMetadata& metadata) {
200 auto res = metadata.structs_ref()->emplace("module.TrivialNumeric", ::apache::thrift::metadata::ThriftStruct{});
201 if (!res.second) {
202 return res.first->second;
203 }
204 ::apache::thrift::metadata::ThriftStruct& module_TrivialNumeric = res.first->second;
205 module_TrivialNumeric.name_ref() = "module.TrivialNumeric";
206 module_TrivialNumeric.is_union_ref() = false;
207 static const EncodedThriftField
208 module_TrivialNumeric_fields[] = {
209 {1, "a", false, std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_I32_TYPE), std::vector<ThriftConstStruct>{}},
210 {2, "b", false, std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_BOOL_TYPE), std::vector<ThriftConstStruct>{}},
211 };
212 for (const auto& f : module_TrivialNumeric_fields) {
213 ::apache::thrift::metadata::ThriftField field;
214 field.id_ref() = f.id;
215 field.name_ref() = f.name;
216 field.is_optional_ref() = f.is_optional;
217 f.metadata_type_interface->writeAndGenType(*field.type_ref(), metadata);
218 field.structured_annotations_ref() = f.structured_annotations;
219 module_TrivialNumeric.fields_ref()->push_back(std::move(field));
220 }
221 return res.first->second;
222 }
223 const ::apache::thrift::metadata::ThriftStruct&
gen(ThriftMetadata & metadata)224 StructMetadata<::apache::thrift::fixtures::types::TrivialNestedWithDefault>::gen(ThriftMetadata& metadata) {
225 auto res = metadata.structs_ref()->emplace("module.TrivialNestedWithDefault", ::apache::thrift::metadata::ThriftStruct{});
226 if (!res.second) {
227 return res.first->second;
228 }
229 ::apache::thrift::metadata::ThriftStruct& module_TrivialNestedWithDefault = res.first->second;
230 module_TrivialNestedWithDefault.name_ref() = "module.TrivialNestedWithDefault";
231 module_TrivialNestedWithDefault.is_union_ref() = false;
232 static const EncodedThriftField
233 module_TrivialNestedWithDefault_fields[] = {
234 {1, "z", false, std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_I32_TYPE), std::vector<ThriftConstStruct>{}},
235 {2, "n", false, std::make_unique<Struct< ::apache::thrift::fixtures::types::TrivialNumeric>>("module.TrivialNumeric"), std::vector<ThriftConstStruct>{}},
236 };
237 for (const auto& f : module_TrivialNestedWithDefault_fields) {
238 ::apache::thrift::metadata::ThriftField field;
239 field.id_ref() = f.id;
240 field.name_ref() = f.name;
241 field.is_optional_ref() = f.is_optional;
242 f.metadata_type_interface->writeAndGenType(*field.type_ref(), metadata);
243 field.structured_annotations_ref() = f.structured_annotations;
244 module_TrivialNestedWithDefault.fields_ref()->push_back(std::move(field));
245 }
246 return res.first->second;
247 }
248 const ::apache::thrift::metadata::ThriftStruct&
gen(ThriftMetadata & metadata)249 StructMetadata<::apache::thrift::fixtures::types::ComplexString>::gen(ThriftMetadata& metadata) {
250 auto res = metadata.structs_ref()->emplace("module.ComplexString", ::apache::thrift::metadata::ThriftStruct{});
251 if (!res.second) {
252 return res.first->second;
253 }
254 ::apache::thrift::metadata::ThriftStruct& module_ComplexString = res.first->second;
255 module_ComplexString.name_ref() = "module.ComplexString";
256 module_ComplexString.is_union_ref() = false;
257 static const EncodedThriftField
258 module_ComplexString_fields[] = {
259 {1, "a", false, std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::vector<ThriftConstStruct>{}},
260 {2, "b", false, std::make_unique<Map>(std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_I32_TYPE)), std::vector<ThriftConstStruct>{}},
261 };
262 for (const auto& f : module_ComplexString_fields) {
263 ::apache::thrift::metadata::ThriftField field;
264 field.id_ref() = f.id;
265 field.name_ref() = f.name;
266 field.is_optional_ref() = f.is_optional;
267 f.metadata_type_interface->writeAndGenType(*field.type_ref(), metadata);
268 field.structured_annotations_ref() = f.structured_annotations;
269 module_ComplexString.fields_ref()->push_back(std::move(field));
270 }
271 return res.first->second;
272 }
273 const ::apache::thrift::metadata::ThriftStruct&
gen(ThriftMetadata & metadata)274 StructMetadata<::apache::thrift::fixtures::types::ComplexNestedWithDefault>::gen(ThriftMetadata& metadata) {
275 auto res = metadata.structs_ref()->emplace("module.ComplexNestedWithDefault", ::apache::thrift::metadata::ThriftStruct{});
276 if (!res.second) {
277 return res.first->second;
278 }
279 ::apache::thrift::metadata::ThriftStruct& module_ComplexNestedWithDefault = res.first->second;
280 module_ComplexNestedWithDefault.name_ref() = "module.ComplexNestedWithDefault";
281 module_ComplexNestedWithDefault.is_union_ref() = false;
282 static const EncodedThriftField
283 module_ComplexNestedWithDefault_fields[] = {
284 {1, "z", false, std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::vector<ThriftConstStruct>{}},
285 {2, "n", false, std::make_unique<Struct< ::apache::thrift::fixtures::types::ComplexString>>("module.ComplexString"), std::vector<ThriftConstStruct>{}},
286 };
287 for (const auto& f : module_ComplexNestedWithDefault_fields) {
288 ::apache::thrift::metadata::ThriftField field;
289 field.id_ref() = f.id;
290 field.name_ref() = f.name;
291 field.is_optional_ref() = f.is_optional;
292 f.metadata_type_interface->writeAndGenType(*field.type_ref(), metadata);
293 field.structured_annotations_ref() = f.structured_annotations;
294 module_ComplexNestedWithDefault.fields_ref()->push_back(std::move(field));
295 }
296 return res.first->second;
297 }
298 const ::apache::thrift::metadata::ThriftStruct&
gen(ThriftMetadata & metadata)299 StructMetadata<::apache::thrift::fixtures::types::MinPadding>::gen(ThriftMetadata& metadata) {
300 auto res = metadata.structs_ref()->emplace("module.MinPadding", ::apache::thrift::metadata::ThriftStruct{});
301 if (!res.second) {
302 return res.first->second;
303 }
304 ::apache::thrift::metadata::ThriftStruct& module_MinPadding = res.first->second;
305 module_MinPadding.name_ref() = "module.MinPadding";
306 module_MinPadding.is_union_ref() = false;
307 static const EncodedThriftField
308 module_MinPadding_fields[] = {
309 {1, "small", false, std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_BYTE_TYPE), std::vector<ThriftConstStruct>{}},
310 {2, "big", false, std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_I64_TYPE), std::vector<ThriftConstStruct>{}},
311 {3, "medium", false, std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_I16_TYPE), std::vector<ThriftConstStruct>{}},
312 {4, "biggish", false, std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_I32_TYPE), std::vector<ThriftConstStruct>{}},
313 {5, "tiny", false, std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_BYTE_TYPE), std::vector<ThriftConstStruct>{}},
314 };
315 for (const auto& f : module_MinPadding_fields) {
316 ::apache::thrift::metadata::ThriftField field;
317 field.id_ref() = f.id;
318 field.name_ref() = f.name;
319 field.is_optional_ref() = f.is_optional;
320 f.metadata_type_interface->writeAndGenType(*field.type_ref(), metadata);
321 field.structured_annotations_ref() = f.structured_annotations;
322 module_MinPadding.fields_ref()->push_back(std::move(field));
323 }
324 return res.first->second;
325 }
326 const ::apache::thrift::metadata::ThriftStruct&
gen(ThriftMetadata & metadata)327 StructMetadata<::apache::thrift::fixtures::types::MyDataItem>::gen(ThriftMetadata& metadata) {
328 auto res = metadata.structs_ref()->emplace("module.MyDataItem", ::apache::thrift::metadata::ThriftStruct{});
329 if (!res.second) {
330 return res.first->second;
331 }
332 ::apache::thrift::metadata::ThriftStruct& module_MyDataItem = res.first->second;
333 module_MyDataItem.name_ref() = "module.MyDataItem";
334 module_MyDataItem.is_union_ref() = false;
335 return res.first->second;
336 }
337 const ::apache::thrift::metadata::ThriftStruct&
gen(ThriftMetadata & metadata)338 StructMetadata<::apache::thrift::fixtures::types::MyStruct>::gen(ThriftMetadata& metadata) {
339 auto res = metadata.structs_ref()->emplace("module.MyStruct", ::apache::thrift::metadata::ThriftStruct{});
340 if (!res.second) {
341 return res.first->second;
342 }
343 ::apache::thrift::metadata::ThriftStruct& module_MyStruct = res.first->second;
344 module_MyStruct.name_ref() = "module.MyStruct";
345 module_MyStruct.is_union_ref() = false;
346 static const EncodedThriftField
347 module_MyStruct_fields[] = {
348 {1, "MyIntField", false, std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_I64_TYPE), std::vector<ThriftConstStruct>{}},
349 {2, "MyStringField", false, std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::vector<ThriftConstStruct>{}},
350 {3, "majorVer", false, std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_I64_TYPE), std::vector<ThriftConstStruct>{}},
351 {4, "data", false, std::make_unique<Typedef>("module.MyDataItem", std::make_unique<Struct< ::apache::thrift::fixtures::types::MyDataItem>>("module.MyDataItem"), std::vector<ThriftConstStruct>{}), std::vector<ThriftConstStruct>{}},
352 };
353 for (const auto& f : module_MyStruct_fields) {
354 ::apache::thrift::metadata::ThriftField field;
355 field.id_ref() = f.id;
356 field.name_ref() = f.name;
357 field.is_optional_ref() = f.is_optional;
358 f.metadata_type_interface->writeAndGenType(*field.type_ref(), metadata);
359 field.structured_annotations_ref() = f.structured_annotations;
360 module_MyStruct.fields_ref()->push_back(std::move(field));
361 }
362 return res.first->second;
363 }
364 const ::apache::thrift::metadata::ThriftStruct&
gen(ThriftMetadata & metadata)365 StructMetadata<::apache::thrift::fixtures::types::Renaming>::gen(ThriftMetadata& metadata) {
366 auto res = metadata.structs_ref()->emplace("module.Renaming", ::apache::thrift::metadata::ThriftStruct{});
367 if (!res.second) {
368 return res.first->second;
369 }
370 ::apache::thrift::metadata::ThriftStruct& module_Renaming = res.first->second;
371 module_Renaming.name_ref() = "module.Renaming";
372 module_Renaming.is_union_ref() = false;
373 static const EncodedThriftField
374 module_Renaming_fields[] = {
375 {1, "foo", false, std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_I64_TYPE), std::vector<ThriftConstStruct>{}},
376 };
377 for (const auto& f : module_Renaming_fields) {
378 ::apache::thrift::metadata::ThriftField field;
379 field.id_ref() = f.id;
380 field.name_ref() = f.name;
381 field.is_optional_ref() = f.is_optional;
382 f.metadata_type_interface->writeAndGenType(*field.type_ref(), metadata);
383 field.structured_annotations_ref() = f.structured_annotations;
384 module_Renaming.fields_ref()->push_back(std::move(field));
385 }
386 return res.first->second;
387 }
388 const ::apache::thrift::metadata::ThriftStruct&
gen(ThriftMetadata & metadata)389 StructMetadata<::apache::thrift::fixtures::types::AnnotatedTypes>::gen(ThriftMetadata& metadata) {
390 auto res = metadata.structs_ref()->emplace("module.AnnotatedTypes", ::apache::thrift::metadata::ThriftStruct{});
391 if (!res.second) {
392 return res.first->second;
393 }
394 ::apache::thrift::metadata::ThriftStruct& module_AnnotatedTypes = res.first->second;
395 module_AnnotatedTypes.name_ref() = "module.AnnotatedTypes";
396 module_AnnotatedTypes.is_union_ref() = false;
397 static const EncodedThriftField
398 module_AnnotatedTypes_fields[] = {
399 {1, "binary_field", false, std::make_unique<Typedef>("module.TBinary", std::make_unique<Typedef>("module.TBinary", std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_BINARY_TYPE), std::vector<ThriftConstStruct>{}), std::vector<ThriftConstStruct>{}), std::vector<ThriftConstStruct>{}},
400 {2, "list_field", false, std::make_unique<Typedef>("include.SomeListOfTypeMap", std::make_unique<Typedef>("include.SomeListOfTypeMap", std::make_unique<List>(std::make_unique<Typedef>("include.SomeMap", std::make_unique<Map>(std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_I32_TYPE), std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_STRING_TYPE)), std::vector<ThriftConstStruct>{})), std::vector<ThriftConstStruct>{}), std::vector<ThriftConstStruct>{}), std::vector<ThriftConstStruct>{}},
401 };
402 for (const auto& f : module_AnnotatedTypes_fields) {
403 ::apache::thrift::metadata::ThriftField field;
404 field.id_ref() = f.id;
405 field.name_ref() = f.name;
406 field.is_optional_ref() = f.is_optional;
407 f.metadata_type_interface->writeAndGenType(*field.type_ref(), metadata);
408 field.structured_annotations_ref() = f.structured_annotations;
409 module_AnnotatedTypes.fields_ref()->push_back(std::move(field));
410 }
411 return res.first->second;
412 }
413 const ::apache::thrift::metadata::ThriftStruct&
gen(ThriftMetadata & metadata)414 StructMetadata<::apache::thrift::fixtures::types::ForwardUsageStruct>::gen(ThriftMetadata& metadata) {
415 auto res = metadata.structs_ref()->emplace("module.ForwardUsageStruct", ::apache::thrift::metadata::ThriftStruct{});
416 if (!res.second) {
417 return res.first->second;
418 }
419 ::apache::thrift::metadata::ThriftStruct& module_ForwardUsageStruct = res.first->second;
420 module_ForwardUsageStruct.name_ref() = "module.ForwardUsageStruct";
421 module_ForwardUsageStruct.is_union_ref() = false;
422 static const EncodedThriftField
423 module_ForwardUsageStruct_fields[] = {
424 {1, "foo", true, std::make_unique<Struct< ::apache::thrift::fixtures::types::ForwardUsageRoot>>("module.ForwardUsageRoot"), std::vector<ThriftConstStruct>{}},
425 };
426 for (const auto& f : module_ForwardUsageStruct_fields) {
427 ::apache::thrift::metadata::ThriftField field;
428 field.id_ref() = f.id;
429 field.name_ref() = f.name;
430 field.is_optional_ref() = f.is_optional;
431 f.metadata_type_interface->writeAndGenType(*field.type_ref(), metadata);
432 field.structured_annotations_ref() = f.structured_annotations;
433 module_ForwardUsageStruct.fields_ref()->push_back(std::move(field));
434 }
435 return res.first->second;
436 }
437 const ::apache::thrift::metadata::ThriftStruct&
gen(ThriftMetadata & metadata)438 StructMetadata<::apache::thrift::fixtures::types::ForwardUsageRoot>::gen(ThriftMetadata& metadata) {
439 auto res = metadata.structs_ref()->emplace("module.ForwardUsageRoot", ::apache::thrift::metadata::ThriftStruct{});
440 if (!res.second) {
441 return res.first->second;
442 }
443 ::apache::thrift::metadata::ThriftStruct& module_ForwardUsageRoot = res.first->second;
444 module_ForwardUsageRoot.name_ref() = "module.ForwardUsageRoot";
445 module_ForwardUsageRoot.is_union_ref() = false;
446 static const EncodedThriftField
447 module_ForwardUsageRoot_fields[] = {
448 {1, "ForwardUsageStruct", true, std::make_unique<Typedef>("module.ForwardUsageStruct", std::make_unique<Struct< ::apache::thrift::fixtures::types::ForwardUsageStruct>>("module.ForwardUsageStruct"), std::vector<ThriftConstStruct>{}), std::vector<ThriftConstStruct>{}},
449 {2, "ForwardUsageByRef", true, std::make_unique<Typedef>("module.ForwardUsageByRef", std::make_unique<Struct< ::apache::thrift::fixtures::types::ForwardUsageByRef>>("module.ForwardUsageByRef"), std::vector<ThriftConstStruct>{}), std::vector<ThriftConstStruct>{}},
450 };
451 for (const auto& f : module_ForwardUsageRoot_fields) {
452 ::apache::thrift::metadata::ThriftField field;
453 field.id_ref() = f.id;
454 field.name_ref() = f.name;
455 field.is_optional_ref() = f.is_optional;
456 f.metadata_type_interface->writeAndGenType(*field.type_ref(), metadata);
457 field.structured_annotations_ref() = f.structured_annotations;
458 module_ForwardUsageRoot.fields_ref()->push_back(std::move(field));
459 }
460 return res.first->second;
461 }
462 const ::apache::thrift::metadata::ThriftStruct&
gen(ThriftMetadata & metadata)463 StructMetadata<::apache::thrift::fixtures::types::ForwardUsageByRef>::gen(ThriftMetadata& metadata) {
464 auto res = metadata.structs_ref()->emplace("module.ForwardUsageByRef", ::apache::thrift::metadata::ThriftStruct{});
465 if (!res.second) {
466 return res.first->second;
467 }
468 ::apache::thrift::metadata::ThriftStruct& module_ForwardUsageByRef = res.first->second;
469 module_ForwardUsageByRef.name_ref() = "module.ForwardUsageByRef";
470 module_ForwardUsageByRef.is_union_ref() = false;
471 static const EncodedThriftField
472 module_ForwardUsageByRef_fields[] = {
473 {1, "foo", true, std::make_unique<Struct< ::apache::thrift::fixtures::types::ForwardUsageRoot>>("module.ForwardUsageRoot"), std::vector<ThriftConstStruct>{}},
474 };
475 for (const auto& f : module_ForwardUsageByRef_fields) {
476 ::apache::thrift::metadata::ThriftField field;
477 field.id_ref() = f.id;
478 field.name_ref() = f.name;
479 field.is_optional_ref() = f.is_optional;
480 f.metadata_type_interface->writeAndGenType(*field.type_ref(), metadata);
481 field.structured_annotations_ref() = f.structured_annotations;
482 module_ForwardUsageByRef.fields_ref()->push_back(std::move(field));
483 }
484 return res.first->second;
485 }
486 const ::apache::thrift::metadata::ThriftStruct&
gen(ThriftMetadata & metadata)487 StructMetadata<::apache::thrift::fixtures::types::NoexceptMoveEmpty>::gen(ThriftMetadata& metadata) {
488 auto res = metadata.structs_ref()->emplace("module.NoexceptMoveEmpty", ::apache::thrift::metadata::ThriftStruct{});
489 if (!res.second) {
490 return res.first->second;
491 }
492 ::apache::thrift::metadata::ThriftStruct& module_NoexceptMoveEmpty = res.first->second;
493 module_NoexceptMoveEmpty.name_ref() = "module.NoexceptMoveEmpty";
494 module_NoexceptMoveEmpty.is_union_ref() = false;
495 return res.first->second;
496 }
497 const ::apache::thrift::metadata::ThriftStruct&
gen(ThriftMetadata & metadata)498 StructMetadata<::apache::thrift::fixtures::types::NoexceptMoveSimpleStruct>::gen(ThriftMetadata& metadata) {
499 auto res = metadata.structs_ref()->emplace("module.NoexceptMoveSimpleStruct", ::apache::thrift::metadata::ThriftStruct{});
500 if (!res.second) {
501 return res.first->second;
502 }
503 ::apache::thrift::metadata::ThriftStruct& module_NoexceptMoveSimpleStruct = res.first->second;
504 module_NoexceptMoveSimpleStruct.name_ref() = "module.NoexceptMoveSimpleStruct";
505 module_NoexceptMoveSimpleStruct.is_union_ref() = false;
506 static const EncodedThriftField
507 module_NoexceptMoveSimpleStruct_fields[] = {
508 {1, "boolField", false, std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_I64_TYPE), std::vector<ThriftConstStruct>{}},
509 };
510 for (const auto& f : module_NoexceptMoveSimpleStruct_fields) {
511 ::apache::thrift::metadata::ThriftField field;
512 field.id_ref() = f.id;
513 field.name_ref() = f.name;
514 field.is_optional_ref() = f.is_optional;
515 f.metadata_type_interface->writeAndGenType(*field.type_ref(), metadata);
516 field.structured_annotations_ref() = f.structured_annotations;
517 module_NoexceptMoveSimpleStruct.fields_ref()->push_back(std::move(field));
518 }
519 return res.first->second;
520 }
521 const ::apache::thrift::metadata::ThriftStruct&
gen(ThriftMetadata & metadata)522 StructMetadata<::apache::thrift::fixtures::types::NoexceptMoveComplexStruct>::gen(ThriftMetadata& metadata) {
523 auto res = metadata.structs_ref()->emplace("module.NoexceptMoveComplexStruct", ::apache::thrift::metadata::ThriftStruct{});
524 if (!res.second) {
525 return res.first->second;
526 }
527 ::apache::thrift::metadata::ThriftStruct& module_NoexceptMoveComplexStruct = res.first->second;
528 module_NoexceptMoveComplexStruct.name_ref() = "module.NoexceptMoveComplexStruct";
529 module_NoexceptMoveComplexStruct.is_union_ref() = false;
530 static const EncodedThriftField
531 module_NoexceptMoveComplexStruct_fields[] = {
532 {1, "MyBoolField", false, std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_BOOL_TYPE), std::vector<ThriftConstStruct>{}},
533 {2, "MyIntField", false, std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_I64_TYPE), std::vector<ThriftConstStruct>{}},
534 {3, "MyStringField", false, std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::vector<ThriftConstStruct>{}},
535 {4, "MyStringField2", false, std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::vector<ThriftConstStruct>{}},
536 {5, "MyBinaryField", false, std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_BINARY_TYPE), std::vector<ThriftConstStruct>{}},
537 {6, "MyBinaryField2", true, std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_BINARY_TYPE), std::vector<ThriftConstStruct>{}},
538 {7, "MyBinaryField3", false, std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_BINARY_TYPE), std::vector<ThriftConstStruct>{}},
539 {8, "MyBinaryListField4", false, std::make_unique<List>(std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_BINARY_TYPE)), std::vector<ThriftConstStruct>{}},
540 {9, "MyMapEnumAndInt", false, std::make_unique<Map>(std::make_unique<Enum< ::apache::thrift::fixtures::types::MyEnumA>>("module.MyEnumA"), std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_STRING_TYPE)), std::vector<ThriftConstStruct>{}},
541 };
542 for (const auto& f : module_NoexceptMoveComplexStruct_fields) {
543 ::apache::thrift::metadata::ThriftField field;
544 field.id_ref() = f.id;
545 field.name_ref() = f.name;
546 field.is_optional_ref() = f.is_optional;
547 f.metadata_type_interface->writeAndGenType(*field.type_ref(), metadata);
548 field.structured_annotations_ref() = f.structured_annotations;
549 module_NoexceptMoveComplexStruct.fields_ref()->push_back(std::move(field));
550 }
551 return res.first->second;
552 }
553 const ::apache::thrift::metadata::ThriftStruct&
gen(ThriftMetadata & metadata)554 StructMetadata<::apache::thrift::fixtures::types::NoExceptMoveUnion>::gen(ThriftMetadata& metadata) {
555 auto res = metadata.structs_ref()->emplace("module.NoExceptMoveUnion", ::apache::thrift::metadata::ThriftStruct{});
556 if (!res.second) {
557 return res.first->second;
558 }
559 ::apache::thrift::metadata::ThriftStruct& module_NoExceptMoveUnion = res.first->second;
560 module_NoExceptMoveUnion.name_ref() = "module.NoExceptMoveUnion";
561 module_NoExceptMoveUnion.is_union_ref() = true;
562 static const EncodedThriftField
563 module_NoExceptMoveUnion_fields[] = {
564 {1, "string_field", false, std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::vector<ThriftConstStruct>{}},
565 {2, "i32_field", false, std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_I32_TYPE), std::vector<ThriftConstStruct>{}},
566 };
567 for (const auto& f : module_NoExceptMoveUnion_fields) {
568 ::apache::thrift::metadata::ThriftField field;
569 field.id_ref() = f.id;
570 field.name_ref() = f.name;
571 field.is_optional_ref() = f.is_optional;
572 f.metadata_type_interface->writeAndGenType(*field.type_ref(), metadata);
573 field.structured_annotations_ref() = f.structured_annotations;
574 module_NoExceptMoveUnion.fields_ref()->push_back(std::move(field));
575 }
576 return res.first->second;
577 }
578 const ::apache::thrift::metadata::ThriftStruct&
gen(ThriftMetadata & metadata)579 StructMetadata<::apache::thrift::fixtures::types::AllocatorAware>::gen(ThriftMetadata& metadata) {
580 auto res = metadata.structs_ref()->emplace("module.AllocatorAware", ::apache::thrift::metadata::ThriftStruct{});
581 if (!res.second) {
582 return res.first->second;
583 }
584 ::apache::thrift::metadata::ThriftStruct& module_AllocatorAware = res.first->second;
585 module_AllocatorAware.name_ref() = "module.AllocatorAware";
586 module_AllocatorAware.is_union_ref() = false;
587 static const EncodedThriftField
588 module_AllocatorAware_fields[] = {
589 {1, "aa_list", false, std::make_unique<List>(std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_I32_TYPE)), std::vector<ThriftConstStruct>{}},
590 {2, "aa_set", false, std::make_unique<Set>(std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_I32_TYPE)), std::vector<ThriftConstStruct>{}},
591 {3, "aa_map", false, std::make_unique<Map>(std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_I32_TYPE), std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_I32_TYPE)), std::vector<ThriftConstStruct>{}},
592 {4, "aa_string", false, std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::vector<ThriftConstStruct>{}},
593 {5, "not_a_container", false, std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_I32_TYPE), std::vector<ThriftConstStruct>{}},
594 };
595 for (const auto& f : module_AllocatorAware_fields) {
596 ::apache::thrift::metadata::ThriftField field;
597 field.id_ref() = f.id;
598 field.name_ref() = f.name;
599 field.is_optional_ref() = f.is_optional;
600 f.metadata_type_interface->writeAndGenType(*field.type_ref(), metadata);
601 field.structured_annotations_ref() = f.structured_annotations;
602 module_AllocatorAware.fields_ref()->push_back(std::move(field));
603 }
604 return res.first->second;
605 }
606 const ::apache::thrift::metadata::ThriftStruct&
gen(ThriftMetadata & metadata)607 StructMetadata<::apache::thrift::fixtures::types::AllocatorAware2>::gen(ThriftMetadata& metadata) {
608 auto res = metadata.structs_ref()->emplace("module.AllocatorAware2", ::apache::thrift::metadata::ThriftStruct{});
609 if (!res.second) {
610 return res.first->second;
611 }
612 ::apache::thrift::metadata::ThriftStruct& module_AllocatorAware2 = res.first->second;
613 module_AllocatorAware2.name_ref() = "module.AllocatorAware2";
614 module_AllocatorAware2.is_union_ref() = false;
615 static const EncodedThriftField
616 module_AllocatorAware2_fields[] = {
617 {1, "not_a_container", false, std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_I32_TYPE), std::vector<ThriftConstStruct>{}},
618 };
619 for (const auto& f : module_AllocatorAware2_fields) {
620 ::apache::thrift::metadata::ThriftField field;
621 field.id_ref() = f.id;
622 field.name_ref() = f.name;
623 field.is_optional_ref() = f.is_optional;
624 f.metadata_type_interface->writeAndGenType(*field.type_ref(), metadata);
625 field.structured_annotations_ref() = f.structured_annotations;
626 module_AllocatorAware2.fields_ref()->push_back(std::move(field));
627 }
628 return res.first->second;
629 }
630 const ::apache::thrift::metadata::ThriftStruct&
gen(ThriftMetadata & metadata)631 StructMetadata<::apache::thrift::fixtures::types::TypedefStruct>::gen(ThriftMetadata& metadata) {
632 auto res = metadata.structs_ref()->emplace("module.TypedefStruct", ::apache::thrift::metadata::ThriftStruct{});
633 if (!res.second) {
634 return res.first->second;
635 }
636 ::apache::thrift::metadata::ThriftStruct& module_TypedefStruct = res.first->second;
637 module_TypedefStruct.name_ref() = "module.TypedefStruct";
638 module_TypedefStruct.is_union_ref() = false;
639 static const EncodedThriftField
640 module_TypedefStruct_fields[] = {
641 {1, "i32_field", false, std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_I32_TYPE), std::vector<ThriftConstStruct>{}},
642 {2, "IntTypedef_field", false, std::make_unique<Typedef>("module.IntTypedef", std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_I32_TYPE), std::vector<ThriftConstStruct>{}), std::vector<ThriftConstStruct>{}},
643 {3, "UintTypedef_field", false, std::make_unique<Typedef>("module.UintTypedef", std::make_unique<Typedef>("module.IntTypedef", std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_I32_TYPE), std::vector<ThriftConstStruct>{}), std::vector<ThriftConstStruct>{}), std::vector<ThriftConstStruct>{}},
644 };
645 for (const auto& f : module_TypedefStruct_fields) {
646 ::apache::thrift::metadata::ThriftField field;
647 field.id_ref() = f.id;
648 field.name_ref() = f.name;
649 field.is_optional_ref() = f.is_optional;
650 f.metadata_type_interface->writeAndGenType(*field.type_ref(), metadata);
651 field.structured_annotations_ref() = f.structured_annotations;
652 module_TypedefStruct.fields_ref()->push_back(std::move(field));
653 }
654 return res.first->second;
655 }
656 const ::apache::thrift::metadata::ThriftStruct&
gen(ThriftMetadata & metadata)657 StructMetadata<::apache::thrift::fixtures::types::StructWithDoubleUnderscores>::gen(ThriftMetadata& metadata) {
658 auto res = metadata.structs_ref()->emplace("module.StructWithDoubleUnderscores", ::apache::thrift::metadata::ThriftStruct{});
659 if (!res.second) {
660 return res.first->second;
661 }
662 ::apache::thrift::metadata::ThriftStruct& module_StructWithDoubleUnderscores = res.first->second;
663 module_StructWithDoubleUnderscores.name_ref() = "module.StructWithDoubleUnderscores";
664 module_StructWithDoubleUnderscores.is_union_ref() = false;
665 static const EncodedThriftField
666 module_StructWithDoubleUnderscores_fields[] = {
667 {1, "__field", false, std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_I32_TYPE), std::vector<ThriftConstStruct>{}},
668 };
669 for (const auto& f : module_StructWithDoubleUnderscores_fields) {
670 ::apache::thrift::metadata::ThriftField field;
671 field.id_ref() = f.id;
672 field.name_ref() = f.name;
673 field.is_optional_ref() = f.is_optional;
674 f.metadata_type_interface->writeAndGenType(*field.type_ref(), metadata);
675 field.structured_annotations_ref() = f.structured_annotations;
676 module_StructWithDoubleUnderscores.fields_ref()->push_back(std::move(field));
677 }
678 return res.first->second;
679 }
680
gen_bounce_map(ThriftMetadata & metadata,ThriftService & service)681 void ServiceMetadata<::apache::thrift::fixtures::types::SomeServiceSvIf>::gen_bounce_map(ThriftMetadata& metadata, ThriftService& service) {
682 ::apache::thrift::metadata::ThriftFunction func;
683 (void)metadata;
684 func.name_ref() = "bounce_map";
685 auto func_ret_type = std::make_unique<Typedef>("include.SomeMap", std::make_unique<Map>(std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_I32_TYPE), std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_STRING_TYPE)), std::vector<ThriftConstStruct>{});
686 func_ret_type->writeAndGenType(*func.return_type_ref(), metadata);
687 ::apache::thrift::metadata::ThriftField module_SomeService_bounce_map_m_1;
688 module_SomeService_bounce_map_m_1.id_ref() = 1;
689 module_SomeService_bounce_map_m_1.name_ref() = "m";
690 module_SomeService_bounce_map_m_1.is_optional_ref() = false;
691 auto module_SomeService_bounce_map_m_1_type = std::make_unique<Typedef>("include.SomeMap", std::make_unique<Map>(std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_I32_TYPE), std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_STRING_TYPE)), std::vector<ThriftConstStruct>{});
692 module_SomeService_bounce_map_m_1_type->writeAndGenType(*module_SomeService_bounce_map_m_1.type_ref(), metadata);
693 func.arguments_ref()->push_back(std::move(module_SomeService_bounce_map_m_1));
694 func.is_oneway_ref() = false;
695 service.functions_ref()->push_back(std::move(func));
696 }
gen_binary_keyed_map(ThriftMetadata & metadata,ThriftService & service)697 void ServiceMetadata<::apache::thrift::fixtures::types::SomeServiceSvIf>::gen_binary_keyed_map(ThriftMetadata& metadata, ThriftService& service) {
698 ::apache::thrift::metadata::ThriftFunction func;
699 (void)metadata;
700 func.name_ref() = "binary_keyed_map";
701 auto func_ret_type = std::make_unique<Map>(std::make_unique<Typedef>("module.TBinary", std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_BINARY_TYPE), std::vector<ThriftConstStruct>{}), std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_I64_TYPE));
702 func_ret_type->writeAndGenType(*func.return_type_ref(), metadata);
703 ::apache::thrift::metadata::ThriftField module_SomeService_binary_keyed_map_r_1;
704 module_SomeService_binary_keyed_map_r_1.id_ref() = 1;
705 module_SomeService_binary_keyed_map_r_1.name_ref() = "r";
706 module_SomeService_binary_keyed_map_r_1.is_optional_ref() = false;
707 auto module_SomeService_binary_keyed_map_r_1_type = std::make_unique<List>(std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_I64_TYPE));
708 module_SomeService_binary_keyed_map_r_1_type->writeAndGenType(*module_SomeService_binary_keyed_map_r_1.type_ref(), metadata);
709 func.arguments_ref()->push_back(std::move(module_SomeService_binary_keyed_map_r_1));
710 func.is_oneway_ref() = false;
711 service.functions_ref()->push_back(std::move(func));
712 }
713
gen(::apache::thrift::metadata::ThriftServiceMetadataResponse & response)714 void ServiceMetadata<::apache::thrift::fixtures::types::SomeServiceSvIf>::gen(::apache::thrift::metadata::ThriftServiceMetadataResponse& response) {
715 const ::apache::thrift::metadata::ThriftServiceContextRef* self = genRecurse(*response.metadata_ref(), *response.services_ref());
716 DCHECK(self != nullptr);
717 // TODO(praihan): Remove ThriftServiceContext from response. But in the meantime, we need to fill the field with the result of looking up in ThriftMetadata.
718 ::apache::thrift::metadata::ThriftServiceContext context;
719 context.module_ref() = *self->module_ref();
720 context.service_info_ref() = response.metadata_ref()->services_ref()->at(*self->service_name_ref());
721 response.context_ref() = std::move(context);
722 }
723
genRecurse(ThriftMetadata & metadata,std::vector<ThriftServiceContextRef> & services)724 const ThriftServiceContextRef* ServiceMetadata<::apache::thrift::fixtures::types::SomeServiceSvIf>::genRecurse(ThriftMetadata& metadata, std::vector<ThriftServiceContextRef>& services) {
725 (void) metadata;
726 ::apache::thrift::metadata::ThriftService module_SomeService;
727 module_SomeService.name_ref() = "module.SomeService";
728 static const ThriftFunctionGenerator functions[] = {
729 ServiceMetadata<::apache::thrift::fixtures::types::SomeServiceSvIf>::gen_bounce_map,
730 ServiceMetadata<::apache::thrift::fixtures::types::SomeServiceSvIf>::gen_binary_keyed_map,
731 };
732 for (auto& function_gen : functions) {
733 function_gen(metadata, module_SomeService);
734 }
735 // We need to keep the index around because a reference or iterator could be invalidated.
736 auto selfIndex = services.size();
737 services.emplace_back();
738 ThriftServiceContextRef& context = services[selfIndex];
739 metadata.services_ref()->emplace("module.SomeService", std::move(module_SomeService));
740 context.service_name_ref() = "module.SomeService";
741 ::apache::thrift::metadata::ThriftModuleContext module;
742 module.name_ref() = "module";
743 context.module_ref() = std::move(module);
744 return &context;
745 }
746 } // namespace md
747 } // namespace detail
748 } // namespace thrift
749 } // namespace apache
750