/**
 * Autogenerated by Thrift for thrift/compiler/test/fixtures/includes/src/service.thrift
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated @nocommit
 */
#include <thrift/lib/cpp2/gen/module_metadata_cpp.h>
#include "thrift/compiler/test/fixtures/includes/gen-cpp2/service_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 ServiceMetadata<::apache::thrift::ServiceHandler<::cpp2::MyService>>::gen_query([[maybe_unused]] ThriftMetadata& metadata, ThriftService& service) {
  ::apache::thrift::metadata::ThriftFunction func;
  func.name() = "query";
  auto func_ret_type = std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_VOID_TYPE);
  func_ret_type->writeAndGenType(*func.return_type(), metadata);
  ::apache::thrift::metadata::ThriftField service_MyService_query_s_1;
  service_MyService_query_s_1.id() = 1;
  service_MyService_query_s_1.name() = "s";
  service_MyService_query_s_1.is_optional() = false;
  auto service_MyService_query_s_1_type = std::make_unique<Struct<::cpp2::MyStruct>>("module.MyStruct");
  service_MyService_query_s_1_type->writeAndGenType(*service_MyService_query_s_1.type(), metadata);
  func.arguments()->push_back(std::move(service_MyService_query_s_1));
  ::apache::thrift::metadata::ThriftField service_MyService_query_i_2;
  service_MyService_query_i_2.id() = 2;
  service_MyService_query_i_2.name() = "i";
  service_MyService_query_i_2.is_optional() = false;
  auto service_MyService_query_i_2_type = std::make_unique<Struct<::cpp2::Included>>("includes.Included");
  service_MyService_query_i_2_type->writeAndGenType(*service_MyService_query_i_2.type(), metadata);
  func.arguments()->push_back(std::move(service_MyService_query_i_2));
  func.is_oneway() = false;
  service.functions()->push_back(std::move(func));
}
void ServiceMetadata<::apache::thrift::ServiceHandler<::cpp2::MyService>>::gen_has_arg_docs([[maybe_unused]] ThriftMetadata& metadata, ThriftService& service) {
  ::apache::thrift::metadata::ThriftFunction func;
  func.name() = "has_arg_docs";
  auto func_ret_type = std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_VOID_TYPE);
  func_ret_type->writeAndGenType(*func.return_type(), metadata);
  ::apache::thrift::metadata::ThriftField service_MyService_has_arg_docs_s_1;
  service_MyService_has_arg_docs_s_1.id() = 1;
  service_MyService_has_arg_docs_s_1.name() = "s";
  service_MyService_has_arg_docs_s_1.is_optional() = false;
  auto service_MyService_has_arg_docs_s_1_type = std::make_unique<Struct<::cpp2::MyStruct>>("module.MyStruct");
  service_MyService_has_arg_docs_s_1_type->writeAndGenType(*service_MyService_has_arg_docs_s_1.type(), metadata);
  func.arguments()->push_back(std::move(service_MyService_has_arg_docs_s_1));
  ::apache::thrift::metadata::ThriftField service_MyService_has_arg_docs_i_2;
  service_MyService_has_arg_docs_i_2.id() = 2;
  service_MyService_has_arg_docs_i_2.name() = "i";
  service_MyService_has_arg_docs_i_2.is_optional() = false;
  auto service_MyService_has_arg_docs_i_2_type = std::make_unique<Struct<::cpp2::Included>>("includes.Included");
  service_MyService_has_arg_docs_i_2_type->writeAndGenType(*service_MyService_has_arg_docs_i_2.type(), metadata);
  func.arguments()->push_back(std::move(service_MyService_has_arg_docs_i_2));
  func.is_oneway() = false;
  service.functions()->push_back(std::move(func));
}

void ServiceMetadata<::apache::thrift::ServiceHandler<::cpp2::MyService>>::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::MyService>>::genRecurse([[maybe_unused]] ThriftMetadata& metadata, std::vector<ThriftServiceContextRef>& services) {
  ::apache::thrift::metadata::ThriftService service_MyService;
  service_MyService.name() = "service.MyService";
  static const ThriftFunctionGenerator functions[] = {
    ServiceMetadata<::apache::thrift::ServiceHandler<::cpp2::MyService>>::gen_query,
    ServiceMetadata<::apache::thrift::ServiceHandler<::cpp2::MyService>>::gen_has_arg_docs,
  };
  for (auto& function_gen : functions) {
    function_gen(metadata, service_MyService);
  }
  // We need to keep the index around because a reference or iterator could be invalidated.
  auto selfIndex = services.size();
  services.emplace_back();
  ThriftServiceContextRef& context = services[selfIndex];
  metadata.services()->emplace("service.MyService", std::move(service_MyService));
  context.service_name() = "service.MyService";
  ::apache::thrift::metadata::ThriftModuleContext module;
  module.name() = "service";
  context.module() = std::move(module);
  return &context;
}
} // namespace md
} // namespace detail
} // namespace thrift
} // namespace apache
