From 53b0ee96cd9de22d5acaf070cebe0db900f4dbb8 Mon Sep 17 00:00:00 2001 From: wangguibao Date: Thu, 28 Mar 2019 20:14:35 +0800 Subject: [PATCH] Fix pdcodegen --- pdcodegen/src/pdcodegen.cpp | 62 ++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 32 deletions(-) diff --git a/pdcodegen/src/pdcodegen.cpp b/pdcodegen/src/pdcodegen.cpp index 5d16c0e9..ba22738a 100644 --- a/pdcodegen/src/pdcodegen.cpp +++ b/pdcodegen/src/pdcodegen.cpp @@ -95,40 +95,38 @@ class PdsCodeGenerator : public CodeGenerator { const string body = strip_proto(file->name()) + ".pb.cc"; bool include_inserted = false; for (int i = 0; i < file->service_count(); ++i) { - const ServiceDescriptor* descriptor = file->service(i); - if (!descriptor) { - *error = "get descriptor failed"; - return false; - } - pds::PaddleServiceOption options = - descriptor->options().GetExtension(pds::options); - bool generate_impl = options.generate_impl(); - bool generate_stub = options.generate_stub(); - if (!generate_impl && !generate_stub) { - return true; + const ServiceDescriptor* descriptor = file->service(i); + if (!descriptor) { + *error = "get descriptor failed"; + return false; + } + pds::PaddleServiceOption options = + descriptor->options().GetExtension(pds::options); + bool generate_impl = options.generate_impl(); + bool generate_stub = options.generate_stub(); + if (!generate_impl && !generate_stub) { + return true; + } + if (!include_inserted) { + boost::scoped_ptr output( + context->OpenForInsert(header, "includes")); + google::protobuf::io::Printer printer(output.get(), '$'); + if (generate_impl) { + printer.Print("#include \"predictor/common/inner_common.h\"\n"); + printer.Print("#include \"predictor/framework/service.h\"\n"); + printer.Print("#include \"predictor/framework/manager.h\"\n"); + printer.Print("#include \"predictor/framework/service_manager.h\"\n"); } - - if (!include_inserted) { - boost::scoped_ptr output( - context->OpenForInsert(header, "includes")); - google::protobuf::io::Printer printer(output.get(), '$'); - if (generate_impl) { - printer.Print("#include \"predictor/common/inner_common.h\"\n"); - printer.Print("#include \"predictor/framework/service.h\"\n"); - printer.Print("#include \"predictor/framework/manager.h\"\n"); - printer.Print("#include \"predictor/framework/service_manager.h\"\n"); - } - if (generate_stub) { - printer.Print("#include \n"); - printer.Print("#include \"sdk-cpp/include/factory.h\"\n"); - printer.Print("#include \"sdk-cpp/include/stub.h\"\n"); - printer.Print("#include \"sdk-cpp/include/stub_impl.h\"\n"); - } - include_inserted = true; + if (generate_stub) { + printer.Print("#include \n"); + printer.Print("#include \"sdk-cpp/include/factory.h\"\n"); + printer.Print("#include \"sdk-cpp/include/stub.h\"\n"); + printer.Print("#include \"sdk-cpp/include/stub_impl.h\"\n"); } - - const std::string& class_name = descriptor->name(); - const std::string& service_name = descriptor->name(); + include_inserted = true; + } + const std::string& class_name = descriptor->name(); + const std::string& service_name = descriptor->name(); // xxx.ph.h { if (generate_impl) { -- GitLab