/** * Autogenerated by Thrift for thrift/compiler/test/fixtures/service-schema/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/service-schema/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::Result>::gen(ThriftMetadata& metadata) { auto res = metadata.enums()->emplace("module.Result", ::apache::thrift::metadata::ThriftEnum{}); if (!res.second) { return; } ::apache::thrift::metadata::ThriftEnum& enum_metadata = res.first->second; enum_metadata.name() = "module.Result"; using EnumTraits = TEnumTraits<::cpp2::Result>; 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::CustomException>::gen(ThriftMetadata& metadata) { auto res = metadata.structs()->emplace("module.CustomException", ::apache::thrift::metadata::ThriftStruct{}); if (!res.second) { return res.first->second; } ::apache::thrift::metadata::ThriftStruct& module_CustomException = res.first->second; module_CustomException.name() = "module.CustomException"; module_CustomException.is_union() = false; static const auto* const module_CustomException_fields = new std::array{ { { 1, "name", false, std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::vector{ }}, }}; for (const auto& f : *module_CustomException_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_CustomException.fields()->push_back(std::move(field)); } return res.first->second; } void ExceptionMetadata<::cpp2::CustomException>::gen(ThriftMetadata& metadata) { auto res = metadata.exceptions()->emplace("module.CustomException", ::apache::thrift::metadata::ThriftException{}); if (!res.second) { return; } ::apache::thrift::metadata::ThriftException& module_CustomException = res.first->second; module_CustomException.name() = "module.CustomException"; static const auto* const module_CustomException_fields = new std::array{ { { 1, "name", false, std::make_unique(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::vector{ }}, }}; for (const auto& f : *module_CustomException_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); module_CustomException.fields()->push_back(std::move(field)); } } void ServiceMetadata<::apache::thrift::ServiceHandler<::cpp2::PrimitivesService>>::gen_init([[maybe_unused]] ThriftMetadata& metadata, ThriftService& service) { ::apache::thrift::metadata::ThriftFunction func; func.name() = "init"; auto func_ret_type = std::make_unique(ThriftPrimitiveType::THRIFT_I64_TYPE); func_ret_type->writeAndGenType(*func.return_type(), metadata); ::apache::thrift::metadata::ThriftField module_PrimitivesService_init_param0_1; module_PrimitivesService_init_param0_1.id() = 1; module_PrimitivesService_init_param0_1.name() = "param0"; module_PrimitivesService_init_param0_1.is_optional() = false; auto module_PrimitivesService_init_param0_1_type = std::make_unique(ThriftPrimitiveType::THRIFT_I64_TYPE); module_PrimitivesService_init_param0_1_type->writeAndGenType(*module_PrimitivesService_init_param0_1.type(), metadata); func.arguments()->push_back(std::move(module_PrimitivesService_init_param0_1)); ::apache::thrift::metadata::ThriftField module_PrimitivesService_init_param1_2; module_PrimitivesService_init_param1_2.id() = 2; module_PrimitivesService_init_param1_2.name() = "param1"; module_PrimitivesService_init_param1_2.is_optional() = false; auto module_PrimitivesService_init_param1_2_type = std::make_unique(ThriftPrimitiveType::THRIFT_I64_TYPE); module_PrimitivesService_init_param1_2_type->writeAndGenType(*module_PrimitivesService_init_param1_2.type(), metadata); func.arguments()->push_back(std::move(module_PrimitivesService_init_param1_2)); func.is_oneway() = false; service.functions()->push_back(std::move(func)); } void ServiceMetadata<::apache::thrift::ServiceHandler<::cpp2::PrimitivesService>>::gen_method_that_throws([[maybe_unused]] ThriftMetadata& metadata, ThriftService& service) { ::apache::thrift::metadata::ThriftFunction func; func.name() = "method_that_throws"; auto func_ret_type = std::make_unique>("module.Result"); func_ret_type->writeAndGenType(*func.return_type(), metadata); ::apache::thrift::metadata::ThriftField module_PrimitivesService_method_that_throws_e_1; module_PrimitivesService_method_that_throws_e_1.id() = 1; module_PrimitivesService_method_that_throws_e_1.name() = "e"; module_PrimitivesService_method_that_throws_e_1.is_optional() = false; auto module_PrimitivesService_method_that_throws_e_1_type = std::make_unique>("module.CustomException"); module_PrimitivesService_method_that_throws_e_1_type->writeAndGenType(*module_PrimitivesService_method_that_throws_e_1.type(), metadata); func.exceptions()->push_back(std::move(module_PrimitivesService_method_that_throws_e_1)); ExceptionMetadata<::cpp2::CustomException>::gen(metadata); func.is_oneway() = false; service.functions()->push_back(std::move(func)); } void ServiceMetadata<::apache::thrift::ServiceHandler<::cpp2::PrimitivesService>>::gen_return_void_method([[maybe_unused]] ThriftMetadata& metadata, ThriftService& service) { ::apache::thrift::metadata::ThriftFunction func; func.name() = "return_void_method"; auto func_ret_type = std::make_unique(ThriftPrimitiveType::THRIFT_VOID_TYPE); func_ret_type->writeAndGenType(*func.return_type(), metadata); ::apache::thrift::metadata::ThriftField module_PrimitivesService_return_void_method_id_1; module_PrimitivesService_return_void_method_id_1.id() = 1; module_PrimitivesService_return_void_method_id_1.name() = "id"; module_PrimitivesService_return_void_method_id_1.is_optional() = false; auto module_PrimitivesService_return_void_method_id_1_type = std::make_unique(ThriftPrimitiveType::THRIFT_I64_TYPE); module_PrimitivesService_return_void_method_id_1_type->writeAndGenType(*module_PrimitivesService_return_void_method_id_1.type(), metadata); func.arguments()->push_back(std::move(module_PrimitivesService_return_void_method_id_1)); func.is_oneway() = false; service.functions()->push_back(std::move(func)); } void ServiceMetadata<::apache::thrift::ServiceHandler<::cpp2::PrimitivesService>>::gen(::apache::thrift::metadata::ThriftServiceMetadataResponse& response) { const ::apache::thrift::metadata::ThriftServiceContextRef* self = genRecurse(*response.metadata(), *response.services()); DCHECK(self != nullptr); // TODO(praihan): Remove ThriftServiceContext from response. But in the meantime, we need to fill the field with the result of looking up in ThriftMetadata. ::apache::thrift::metadata::ThriftServiceContext context; context.module() = *self->module(); context.service_info() = response.metadata()->services()->at(*self->service_name()); response.context() = std::move(context); } const ThriftServiceContextRef* ServiceMetadata<::apache::thrift::ServiceHandler<::cpp2::PrimitivesService>>::genRecurse([[maybe_unused]] ThriftMetadata& metadata, std::vector& services) { ::apache::thrift::metadata::ThriftService module_PrimitivesService; module_PrimitivesService.name() = "module.PrimitivesService"; static const ThriftFunctionGenerator functions[] = { ServiceMetadata<::apache::thrift::ServiceHandler<::cpp2::PrimitivesService>>::gen_init, ServiceMetadata<::apache::thrift::ServiceHandler<::cpp2::PrimitivesService>>::gen_method_that_throws, ServiceMetadata<::apache::thrift::ServiceHandler<::cpp2::PrimitivesService>>::gen_return_void_method, }; for (auto& function_gen : functions) { function_gen(metadata, module_PrimitivesService); } // We need to keep the index around because a reference or iterator could be invalidated. auto selfIndex = services.size(); services.emplace_back(); module_PrimitivesService.structured_annotations()->push_back(*cvStruct("thrift.GenerateRuntimeSchema", { }).cv_struct_ref()); ThriftServiceContextRef& context = services[selfIndex]; metadata.services()->emplace("module.PrimitivesService", std::move(module_PrimitivesService)); context.service_name() = "module.PrimitivesService"; ::apache::thrift::metadata::ThriftModuleContext module; module.name() = "module"; context.module() = std::move(module); return &context; } } // namespace md } // namespace detail } // namespace thrift } // namespace apache