diff options
author | dvshkurko <dvshkurko@yandex-team.ru> | 2022-02-10 16:45:51 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:51 +0300 |
commit | 321ee9bce31ec6e238be26dbcbe539cffa2c3309 (patch) | |
tree | 14407a2757cbf29eb97e266b7f07e851f971000c /contrib/libs/grpc/src/compiler | |
parent | 2f6ca198245aeffd5e2d82b65927c2465b68b4f5 (diff) | |
download | ydb-321ee9bce31ec6e238be26dbcbe539cffa2c3309.tar.gz |
Restoring authorship annotation for <dvshkurko@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/grpc/src/compiler')
23 files changed, 617 insertions, 617 deletions
diff --git a/contrib/libs/grpc/src/compiler/config.h b/contrib/libs/grpc/src/compiler/config.h index 95213b0f04..b115a2c0d0 100644 --- a/contrib/libs/grpc/src/compiler/config.h +++ b/contrib/libs/grpc/src/compiler/config.h @@ -19,7 +19,7 @@ #ifndef SRC_COMPILER_CONFIG_H #define SRC_COMPILER_CONFIG_H -#include "src/compiler/config_protobuf.h" +#include "src/compiler/config_protobuf.h" #include <util/generic/string.h> diff --git a/contrib/libs/grpc/src/compiler/config_protobuf.h b/contrib/libs/grpc/src/compiler/config_protobuf.h index 06d5073f43..8fea46be9d 100644 --- a/contrib/libs/grpc/src/compiler/config_protobuf.h +++ b/contrib/libs/grpc/src/compiler/config_protobuf.h @@ -1,52 +1,52 @@ -/* - * - * Copyright 2019 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef SRC_COMPILER_CONFIG_PROTOBUF_H -#define SRC_COMPILER_CONFIG_PROTOBUF_H - -#include <grpcpp/impl/codegen/config_protobuf.h> - -#ifndef GRPC_CUSTOM_CODEGENERATOR +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef SRC_COMPILER_CONFIG_PROTOBUF_H +#define SRC_COMPILER_CONFIG_PROTOBUF_H + +#include <grpcpp/impl/codegen/config_protobuf.h> + +#ifndef GRPC_CUSTOM_CODEGENERATOR #include <google/protobuf/compiler/code_generator.h> -#define GRPC_CUSTOM_CODEGENERATOR ::google::protobuf::compiler::CodeGenerator -#define GRPC_CUSTOM_GENERATORCONTEXT \ - ::google::protobuf::compiler::GeneratorContext -#endif - -#ifndef GRPC_CUSTOM_PRINTER +#define GRPC_CUSTOM_CODEGENERATOR ::google::protobuf::compiler::CodeGenerator +#define GRPC_CUSTOM_GENERATORCONTEXT \ + ::google::protobuf::compiler::GeneratorContext +#endif + +#ifndef GRPC_CUSTOM_PRINTER #include <google/protobuf/io/coded_stream.h> #include <google/protobuf/io/printer.h> #include <google/protobuf/io/zero_copy_stream_impl_lite.h> -#define GRPC_CUSTOM_PRINTER ::google::protobuf::io::Printer -#define GRPC_CUSTOM_CODEDOUTPUTSTREAM ::google::protobuf::io::CodedOutputStream -#define GRPC_CUSTOM_STRINGOUTPUTSTREAM \ - ::google::protobuf::io::StringOutputStream -#endif - -#ifndef GRPC_CUSTOM_PLUGINMAIN +#define GRPC_CUSTOM_PRINTER ::google::protobuf::io::Printer +#define GRPC_CUSTOM_CODEDOUTPUTSTREAM ::google::protobuf::io::CodedOutputStream +#define GRPC_CUSTOM_STRINGOUTPUTSTREAM \ + ::google::protobuf::io::StringOutputStream +#endif + +#ifndef GRPC_CUSTOM_PLUGINMAIN #include <google/protobuf/compiler/plugin.h> -#define GRPC_CUSTOM_PLUGINMAIN ::google::protobuf::compiler::PluginMain -#endif - -#ifndef GRPC_CUSTOM_PARSEGENERATORPARAMETER +#define GRPC_CUSTOM_PLUGINMAIN ::google::protobuf::compiler::PluginMain +#endif + +#ifndef GRPC_CUSTOM_PARSEGENERATORPARAMETER #include <google/protobuf/compiler/code_generator.h> -#define GRPC_CUSTOM_PARSEGENERATORPARAMETER \ - ::google::protobuf::compiler::ParseGeneratorParameter -#endif - -#endif // SRC_COMPILER_CONFIG_PROTOBUF_H +#define GRPC_CUSTOM_PARSEGENERATORPARAMETER \ + ::google::protobuf::compiler::ParseGeneratorParameter +#endif + +#endif // SRC_COMPILER_CONFIG_PROTOBUF_H diff --git a/contrib/libs/grpc/src/compiler/cpp_generator.cc b/contrib/libs/grpc/src/compiler/cpp_generator.cc index 5759177474..363fb5f6cb 100644 --- a/contrib/libs/grpc/src/compiler/cpp_generator.cc +++ b/contrib/libs/grpc/src/compiler/cpp_generator.cc @@ -96,9 +96,9 @@ TString GetHeaderPrologue(grpc_generator::File* file, vars["filename"] = file->filename(); vars["filename_identifier"] = FilenameIdentifier(file->filename()); vars["filename_base"] = file->filename_without_ext(); - vars["message_header_ext"] = params.message_header_extension.empty() - ? kCppGeneratorMessageHeaderExt - : params.message_header_extension; + vars["message_header_ext"] = params.message_header_extension.empty() + ? kCppGeneratorMessageHeaderExt + : params.message_header_extension; printer->Print(vars, "// Generated by the gRPC C++ plugin.\n"); printer->Print(vars, @@ -123,13 +123,13 @@ TString GetHeaderPrologue(grpc_generator::File* file, return output; } -// Convert from "a/b/c.proto" to "#include \"a/b/c$message_header_ext$\"\n" +// Convert from "a/b/c.proto" to "#include \"a/b/c$message_header_ext$\"\n" TString ImportInludeFromProtoName(const TString& proto_name) { return TString("#include \"") + - proto_name.substr(0, proto_name.size() - 6) + + proto_name.substr(0, proto_name.size() - 6) + TString("$message_header_ext$\"\n"); -} - +} + TString GetHeaderIncludes(grpc_generator::File* file, const Parameters& params) { TString output; @@ -152,38 +152,38 @@ TString GetHeaderIncludes(grpc_generator::File* file, "grpcpp/impl/codegen/async_stream.h", "grpcpp/impl/codegen/async_unary_call.h", "grpcpp/impl/codegen/client_callback.h", - "grpcpp/impl/codegen/client_context.h", - "grpcpp/impl/codegen/completion_queue.h", + "grpcpp/impl/codegen/client_context.h", + "grpcpp/impl/codegen/completion_queue.h", "grpcpp/impl/codegen/message_allocator.h", - "grpcpp/impl/codegen/method_handler.h", + "grpcpp/impl/codegen/method_handler.h", "grpcpp/impl/codegen/proto_utils.h", "grpcpp/impl/codegen/rpc_method.h", "grpcpp/impl/codegen/server_callback.h", - "grpcpp/impl/codegen/server_callback_handlers.h", - "grpcpp/impl/codegen/server_context.h", + "grpcpp/impl/codegen/server_callback_handlers.h", + "grpcpp/impl/codegen/server_context.h", "grpcpp/impl/codegen/service_type.h", "grpcpp/impl/codegen/status.h", "grpcpp/impl/codegen/stub_options.h", - "grpcpp/impl/codegen/sync_stream.h", - }; + "grpcpp/impl/codegen/sync_stream.h", + }; std::vector<TString> headers(headers_strs, array_end(headers_strs)); PrintIncludes(printer.get(), headers, params.use_system_headers, params.grpc_search_path); printer->Print(vars, "\n"); - vars["message_header_ext"] = params.message_header_extension.empty() - ? kCppGeneratorMessageHeaderExt - : params.message_header_extension; - - if (params.include_import_headers) { + vars["message_header_ext"] = params.message_header_extension.empty() + ? kCppGeneratorMessageHeaderExt + : params.message_header_extension; + + if (params.include_import_headers) { const std::vector<TString> import_names = file->GetImportNames(); - for (const auto& import_name : import_names) { + for (const auto& import_name : import_names) { const TString include_name = ImportInludeFromProtoName(import_name); - printer->Print(vars, include_name.c_str()); - } - printer->PrintRaw("\n"); - } - + printer->Print(vars, include_name.c_str()); + } + printer->PrintRaw("\n"); + } + if (!file->package().empty()) { std::vector<TString> parts = file->package_parts(); @@ -612,10 +612,10 @@ void PrintHeaderClientMethodCallbackInterfaces( "std::function<void(::grpc::Status)>) = 0;\n"); // TODO(vjpai): Remove experimental versions and macros when callback API is // fully de-experimentalized. - printer->Print(*vars, + printer->Print(*vars, "#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" - "virtual void $Method$(::grpc::ClientContext* context, " - "const $Request$* request, $Response$* response, " + "virtual void $Method$(::grpc::ClientContext* context, " + "const $Request$* request, $Response$* response, " "::grpc::ClientUnaryReactor* reactor) = 0;\n" "#else\n" "virtual void $Method$(::grpc::ClientContext* context, " @@ -708,11 +708,11 @@ void PrintHeaderClientMethodCallback(grpc_generator::Printer* printer, "void $Method$(::grpc::ClientContext* context, " "const $Request$* request, $Response$* response, " "std::function<void(::grpc::Status)>) override;\n"); - printer->Print( - *vars, + printer->Print( + *vars, "#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" - "void $Method$(::grpc::ClientContext* context, " - "const $Request$* request, $Response$* response, " + "void $Method$(::grpc::ClientContext* context, " + "const $Request$* request, $Response$* response, " "::grpc::ClientUnaryReactor* reactor) override;\n" "#else\n" "void $Method$(::grpc::ClientContext* context, " @@ -833,8 +833,8 @@ void PrintHeaderServerAsyncMethodsHelper( *vars, "// disable synchronous version of this method\n" "::grpc::Status $Method$(" - "::grpc::ServerContext* /*context*/, const $Request$* /*request*/, " - "$Response$* /*response*/) override {\n" + "::grpc::ServerContext* /*context*/, const $Request$* /*request*/, " + "$Response$* /*response*/) override {\n" " abort();\n" " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" "}\n"); @@ -854,9 +854,9 @@ void PrintHeaderServerAsyncMethodsHelper( *vars, "// disable synchronous version of this method\n" "::grpc::Status $Method$(" - "::grpc::ServerContext* /*context*/, " - "::grpc::ServerReader< $Request$>* /*reader*/, " - "$Response$* /*response*/) override {\n" + "::grpc::ServerContext* /*context*/, " + "::grpc::ServerReader< $Request$>* /*reader*/, " + "$Response$* /*response*/) override {\n" " abort();\n" " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" "}\n"); @@ -876,8 +876,8 @@ void PrintHeaderServerAsyncMethodsHelper( *vars, "// disable synchronous version of this method\n" "::grpc::Status $Method$(" - "::grpc::ServerContext* /*context*/, const $Request$* /*request*/, " - "::grpc::ServerWriter< $Response$>* /*writer*/) override " + "::grpc::ServerContext* /*context*/, const $Request$* /*request*/, " + "::grpc::ServerWriter< $Response$>* /*writer*/) override " "{\n" " abort();\n" " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" @@ -899,8 +899,8 @@ void PrintHeaderServerAsyncMethodsHelper( *vars, "// disable synchronous version of this method\n" "::grpc::Status $Method$(" - "::grpc::ServerContext* /*context*/, " - "::grpc::ServerReaderWriter< $Response$, $Request$>* /*stream*/) " + "::grpc::ServerContext* /*context*/, " + "::grpc::ServerReaderWriter< $Response$, $Request$>* /*stream*/) " " override {\n" " abort();\n" " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" @@ -935,8 +935,8 @@ void PrintHeaderServerMethodAsync(grpc_generator::Printer* printer, "class WithAsyncMethod_$Method$ : public BaseClass {\n"); printer->Print( " private:\n" - " void BaseClassMustBeDerivedFromService(const Service* /*service*/) " - "{}\n"); + " void BaseClassMustBeDerivedFromService(const Service* /*service*/) " + "{}\n"); printer->Print(" public:\n"); printer->Indent(); printer->Print(*vars, @@ -963,19 +963,19 @@ void PrintHeaderServerCallbackMethodsHelper( *vars, "// disable synchronous version of this method\n" "::grpc::Status $Method$(" - "::grpc::ServerContext* /*context*/, const $Request$* /*request*/, " - "$Response$* /*response*/) override {\n" + "::grpc::ServerContext* /*context*/, const $Request$* /*request*/, " + "$Response$* /*response*/) override {\n" " abort();\n" " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" "}\n"); - printer->Print(*vars, + printer->Print(*vars, "#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" "virtual ::grpc::ServerUnaryReactor* $Method$(\n" " ::grpc::CallbackServerContext* /*context*/, " "const $RealRequest$* /*request*/, " "$RealResponse$* /*response*/)\n" "#else\n" - "virtual ::grpc::experimental::ServerUnaryReactor* " + "virtual ::grpc::experimental::ServerUnaryReactor* " "$Method$(\n" " ::grpc::experimental::CallbackServerContext* " "/*context*/, const $RealRequest$* /*request*/, " @@ -987,9 +987,9 @@ void PrintHeaderServerCallbackMethodsHelper( *vars, "// disable synchronous version of this method\n" "::grpc::Status $Method$(" - "::grpc::ServerContext* /*context*/, " - "::grpc::ServerReader< $Request$>* /*reader*/, " - "$Response$* /*response*/) override {\n" + "::grpc::ServerContext* /*context*/, " + "::grpc::ServerReader< $Request$>* /*reader*/, " + "$Response$* /*response*/) override {\n" " abort();\n" " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" "}\n"); @@ -1011,14 +1011,14 @@ void PrintHeaderServerCallbackMethodsHelper( *vars, "// disable synchronous version of this method\n" "::grpc::Status $Method$(" - "::grpc::ServerContext* /*context*/, const $Request$* /*request*/, " - "::grpc::ServerWriter< $Response$>* /*writer*/) override " + "::grpc::ServerContext* /*context*/, const $Request$* /*request*/, " + "::grpc::ServerWriter< $Response$>* /*writer*/) override " "{\n" " abort();\n" " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" "}\n"); - printer->Print( - *vars, + printer->Print( + *vars, "#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" "virtual ::grpc::ServerWriteReactor< $RealResponse$>* $Method$(\n" " ::grpc::CallbackServerContext* " @@ -1035,21 +1035,21 @@ void PrintHeaderServerCallbackMethodsHelper( *vars, "// disable synchronous version of this method\n" "::grpc::Status $Method$(" - "::grpc::ServerContext* /*context*/, " - "::grpc::ServerReaderWriter< $Response$, $Request$>* /*stream*/) " + "::grpc::ServerContext* /*context*/, " + "::grpc::ServerReaderWriter< $Response$, $Request$>* /*stream*/) " " override {\n" " abort();\n" " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" "}\n"); - printer->Print( - *vars, + printer->Print( + *vars, "#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" "virtual ::grpc::ServerBidiReactor< $RealRequest$, $RealResponse$>* " "$Method$(\n" " ::grpc::CallbackServerContext* /*context*/)\n" "#else\n" - "virtual ::grpc::experimental::ServerBidiReactor< " - "$RealRequest$, $RealResponse$>* " + "virtual ::grpc::experimental::ServerBidiReactor< " + "$RealRequest$, $RealResponse$>* " "$Method$(\n" " ::grpc::experimental::CallbackServerContext* /*context*/)\n" "#endif\n" @@ -1073,8 +1073,8 @@ void PrintHeaderServerMethodCallback(grpc_generator::Printer* printer, "class ExperimentalWithCallbackMethod_$Method$ : public BaseClass {\n"); printer->Print( " private:\n" - " void BaseClassMustBeDerivedFromService(const Service* /*service*/) " - "{}\n"); + " void BaseClassMustBeDerivedFromService(const Service* /*service*/) " + "{}\n"); printer->Print(" public:\n"); printer->Indent(); printer->Print(*vars, "ExperimentalWithCallbackMethod_$Method$() {\n"); @@ -1096,14 +1096,14 @@ void PrintHeaderServerMethodCallback(grpc_generator::Printer* printer, " ::grpc::experimental::CallbackServerContext*\n" "#endif\n" " context, " - "const $RealRequest$* " - "request, " - "$RealResponse$* response) { " - "return this->$Method$(context, request, response); }));}\n"); - printer->Print(*vars, - "void SetMessageAllocatorFor_$Method$(\n" - " ::grpc::experimental::MessageAllocator< " - "$RealRequest$, $RealResponse$>* allocator) {\n" + "const $RealRequest$* " + "request, " + "$RealResponse$* response) { " + "return this->$Method$(context, request, response); }));}\n"); + printer->Print(*vars, + "void SetMessageAllocatorFor_$Method$(\n" + " ::grpc::experimental::MessageAllocator< " + "$RealRequest$, $RealResponse$>* allocator) {\n" "#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" " ::grpc::internal::MethodHandler* const handler = " "::grpc::Service::GetHandler($Idx$);\n" @@ -1113,7 +1113,7 @@ void PrintHeaderServerMethodCallback(grpc_generator::Printer* printer, "#endif\n" " static_cast<::grpc::internal::CallbackUnaryHandler< " "$RealRequest$, $RealResponse$>*>(handler)\n" - " ->SetMessageAllocator(allocator);\n"); + " ->SetMessageAllocator(allocator);\n"); } else if (ClientOnlyStreaming(method)) { printer->Print( *vars, @@ -1132,9 +1132,9 @@ void PrintHeaderServerMethodCallback(grpc_generator::Printer* printer, " ::grpc::experimental::CallbackServerContext*\n" "#endif\n" " context, " - "$RealResponse$* " - "response) { " - "return this->$Method$(context, response); }));\n"); + "$RealResponse$* " + "response) { " + "return this->$Method$(context, response); }));\n"); } else if (ServerOnlyStreaming(method)) { printer->Print( *vars, @@ -1153,9 +1153,9 @@ void PrintHeaderServerMethodCallback(grpc_generator::Printer* printer, " ::grpc::experimental::CallbackServerContext*\n" "#endif\n" " context, " - "const $RealRequest$* " - "request) { " - "return this->$Method$(context, request); }));\n"); + "const $RealRequest$* " + "request) { " + "return this->$Method$(context, request); }));\n"); } else if (method->BidiStreaming()) { printer->Print( *vars, @@ -1202,8 +1202,8 @@ void PrintHeaderServerMethodRawCallback( "BaseClass {\n"); printer->Print( " private:\n" - " void BaseClassMustBeDerivedFromService(const Service* /*service*/) " - "{}\n"); + " void BaseClassMustBeDerivedFromService(const Service* /*service*/) " + "{}\n"); printer->Print(" public:\n"); printer->Indent(); printer->Print(*vars, "ExperimentalWithRawCallbackMethod_$Method$() {\n"); @@ -1225,10 +1225,10 @@ void PrintHeaderServerMethodRawCallback( " ::grpc::experimental::CallbackServerContext*\n" "#endif\n" " context, " - "const $RealRequest$* " - "request, " - "$RealResponse$* response) { return " - "this->$Method$(context, request, response); }));\n"); + "const $RealRequest$* " + "request, " + "$RealResponse$* response) { return " + "this->$Method$(context, request, response); }));\n"); } else if (ClientOnlyStreaming(method)) { printer->Print( *vars, @@ -1247,8 +1247,8 @@ void PrintHeaderServerMethodRawCallback( " ::grpc::experimental::CallbackServerContext*\n" "#endif\n" " context, " - "$RealResponse$* response) " - "{ return this->$Method$(context, response); }));\n"); + "$RealResponse$* response) " + "{ return this->$Method$(context, response); }));\n"); } else if (ServerOnlyStreaming(method)) { printer->Print( *vars, @@ -1267,9 +1267,9 @@ void PrintHeaderServerMethodRawCallback( " ::grpc::experimental::CallbackServerContext*\n" "#endif\n" " context, " - "const" - "$RealRequest$* request) { return " - "this->$Method$(context, request); }));\n"); + "const" + "$RealRequest$* request) { return " + "this->$Method$(context, request); }));\n"); } else if (method->BidiStreaming()) { printer->Print( *vars, @@ -1313,7 +1313,7 @@ void PrintHeaderServerMethodStreamedUnary( "public BaseClass {\n"); printer->Print( " private:\n" - " void BaseClassMustBeDerivedFromService(const Service* /*service*/) " + " void BaseClassMustBeDerivedFromService(const Service* /*service*/) " "{}\n"); printer->Print(" public:\n"); printer->Indent(); @@ -1337,8 +1337,8 @@ void PrintHeaderServerMethodStreamedUnary( *vars, "// disable regular version of this method\n" "::grpc::Status $Method$(" - "::grpc::ServerContext* /*context*/, const $Request$* /*request*/, " - "$Response$* /*response*/) override {\n" + "::grpc::ServerContext* /*context*/, const $Request$* /*request*/, " + "$Response$* /*response*/) override {\n" " abort();\n" " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" "}\n"); @@ -1367,7 +1367,7 @@ void PrintHeaderServerMethodSplitStreaming( "public BaseClass {\n"); printer->Print( " private:\n" - " void BaseClassMustBeDerivedFromService(const Service* /*service*/) " + " void BaseClassMustBeDerivedFromService(const Service* /*service*/) " "{}\n"); printer->Print(" public:\n"); printer->Indent(); @@ -1391,8 +1391,8 @@ void PrintHeaderServerMethodSplitStreaming( *vars, "// disable regular version of this method\n" "::grpc::Status $Method$(" - "::grpc::ServerContext* /*context*/, const $Request$* /*request*/, " - "::grpc::ServerWriter< $Response$>* /*writer*/) override " + "::grpc::ServerContext* /*context*/, const $Request$* /*request*/, " + "::grpc::ServerWriter< $Response$>* /*writer*/) override " "{\n" " abort();\n" " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" @@ -1420,8 +1420,8 @@ void PrintHeaderServerMethodGeneric(grpc_generator::Printer* printer, "class WithGenericMethod_$Method$ : public BaseClass {\n"); printer->Print( " private:\n" - " void BaseClassMustBeDerivedFromService(const Service* /*service*/) " - "{}\n"); + " void BaseClassMustBeDerivedFromService(const Service* /*service*/) " + "{}\n"); printer->Print(" public:\n"); printer->Indent(); printer->Print(*vars, @@ -1437,8 +1437,8 @@ void PrintHeaderServerMethodGeneric(grpc_generator::Printer* printer, *vars, "// disable synchronous version of this method\n" "::grpc::Status $Method$(" - "::grpc::ServerContext* /*context*/, const $Request$* /*request*/, " - "$Response$* /*response*/) override {\n" + "::grpc::ServerContext* /*context*/, const $Request$* /*request*/, " + "$Response$* /*response*/) override {\n" " abort();\n" " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" "}\n"); @@ -1447,9 +1447,9 @@ void PrintHeaderServerMethodGeneric(grpc_generator::Printer* printer, *vars, "// disable synchronous version of this method\n" "::grpc::Status $Method$(" - "::grpc::ServerContext* /*context*/, " - "::grpc::ServerReader< $Request$>* /*reader*/, " - "$Response$* /*response*/) override {\n" + "::grpc::ServerContext* /*context*/, " + "::grpc::ServerReader< $Request$>* /*reader*/, " + "$Response$* /*response*/) override {\n" " abort();\n" " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" "}\n"); @@ -1458,8 +1458,8 @@ void PrintHeaderServerMethodGeneric(grpc_generator::Printer* printer, *vars, "// disable synchronous version of this method\n" "::grpc::Status $Method$(" - "::grpc::ServerContext* /*context*/, const $Request$* /*request*/, " - "::grpc::ServerWriter< $Response$>* /*writer*/) override " + "::grpc::ServerContext* /*context*/, const $Request$* /*request*/, " + "::grpc::ServerWriter< $Response$>* /*writer*/) override " "{\n" " abort();\n" " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" @@ -1469,8 +1469,8 @@ void PrintHeaderServerMethodGeneric(grpc_generator::Printer* printer, *vars, "// disable synchronous version of this method\n" "::grpc::Status $Method$(" - "::grpc::ServerContext* /*context*/, " - "::grpc::ServerReaderWriter< $Response$, $Request$>* /*stream*/) " + "::grpc::ServerContext* /*context*/, " + "::grpc::ServerReaderWriter< $Response$, $Request$>* /*stream*/) " " override {\n" " abort();\n" " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" @@ -1494,8 +1494,8 @@ void PrintHeaderServerMethodRaw(grpc_generator::Printer* printer, printer->Print(*vars, "class WithRawMethod_$Method$ : public BaseClass {\n"); printer->Print( " private:\n" - " void BaseClassMustBeDerivedFromService(const Service* /*service*/) " - "{}\n"); + " void BaseClassMustBeDerivedFromService(const Service* /*service*/) " + "{}\n"); printer->Print(" public:\n"); printer->Indent(); printer->Print(*vars, @@ -1544,7 +1544,7 @@ void PrintHeaderService(grpc_generator::Printer* printer, for (int i = 0; i < service->method_count(); ++i) { printer->Print(service->method(i)->GetLeadingComments("//").c_str()); PrintHeaderClientMethodCallbackInterfaces(printer, service->method(i).get(), - vars); + vars); printer->Print(service->method(i)->GetTrailingComments("//").c_str()); } PrintHeaderClientMethodCallbackInterfacesEnd(printer, vars); @@ -1569,7 +1569,7 @@ void PrintHeaderService(grpc_generator::Printer* printer, } PrintHeaderClientMethodCallbackStart(printer, vars); for (int i = 0; i < service->method_count(); ++i) { - PrintHeaderClientMethodCallback(printer, service->method(i).get(), vars); + PrintHeaderClientMethodCallback(printer, service->method(i).get(), vars); } PrintHeaderClientMethodCallbackEnd(printer, vars); printer->Outdent(); @@ -1816,9 +1816,9 @@ TString GetSourcePrologue(grpc_generator::File* file, vars["filename"] = file->filename(); vars["filename_base"] = file->filename_without_ext(); - vars["message_header_ext"] = params.message_header_extension.empty() - ? kCppGeneratorMessageHeaderExt - : params.message_header_extension; + vars["message_header_ext"] = params.message_header_extension.empty() + ? kCppGeneratorMessageHeaderExt + : params.message_header_extension; vars["service_header_ext"] = kCppGeneratorServiceHeaderExt; printer->Print(vars, "// Generated by the gRPC C++ plugin.\n"); @@ -1848,11 +1848,11 @@ TString GetSourceIncludes(grpc_generator::File* file, "grpcpp/impl/codegen/client_unary_call.h", "grpcpp/impl/codegen/client_callback.h", "grpcpp/impl/codegen/message_allocator.h", - "grpcpp/impl/codegen/method_handler.h", + "grpcpp/impl/codegen/method_handler.h", "grpcpp/impl/codegen/rpc_service_method.h", "grpcpp/impl/codegen/server_callback.h", - "grpcpp/impl/codegen/server_callback_handlers.h", - "grpcpp/impl/codegen/server_context.h", + "grpcpp/impl/codegen/server_callback_handlers.h", + "grpcpp/impl/codegen/server_context.h", "grpcpp/impl/codegen/service_type.h", "grpcpp/impl/codegen/sync_stream.h"}; std::vector<TString> headers(headers_strs, array_end(headers_strs)); @@ -1906,23 +1906,23 @@ void PrintSourceClientMethod(grpc_generator::Printer* printer, "(stub_->channel_.get(), stub_->rpcmethod_$Method$_, " "context, request, response, std::move(f));\n}\n\n"); - printer->Print(*vars, - "void $ns$$Service$::Stub::experimental_async::$Method$(" - "::grpc::ClientContext* context, " - "const $Request$* request, $Response$* response, " - "::grpc::experimental::ClientUnaryReactor* reactor) {\n"); - printer->Print(*vars, + printer->Print(*vars, + "void $ns$$Service$::Stub::experimental_async::$Method$(" + "::grpc::ClientContext* context, " + "const $Request$* request, $Response$* response, " + "::grpc::experimental::ClientUnaryReactor* reactor) {\n"); + printer->Print(*vars, " ::grpc::internal::ClientCallbackUnaryFactory::Create" - "(stub_->channel_.get(), stub_->rpcmethod_$Method$_, " - "context, request, response, reactor);\n}\n\n"); - - printer->Print(*vars, + "(stub_->channel_.get(), stub_->rpcmethod_$Method$_, " + "context, request, response, reactor);\n}\n\n"); + + printer->Print(*vars, "::grpc::ClientAsyncResponseReader< $Response$>* " "$ns$$Service$::Stub::PrepareAsync$Method$Raw(::grpc::" "ClientContext* context, " "const $Request$& request, " "::grpc::CompletionQueue* cq) {\n"); - printer->Print(*vars, + printer->Print(*vars, " return " "::grpc::internal::ClientAsyncResponseReaderFactory" "< $Response$>::Create(channel_.get(), cq, " @@ -1946,13 +1946,13 @@ void PrintSourceClientMethod(grpc_generator::Printer* printer, "::grpc::ClientWriter< $Request$>* " "$ns$$Service$::Stub::$Method$Raw(" "::grpc::ClientContext* context, $Response$* response) {\n"); - printer->Print(*vars, + printer->Print(*vars, " return ::grpc::internal::ClientWriterFactory< " - "$Request$>::Create(" - "channel_.get(), " - "rpcmethod_$Method$_, " - "context, response);\n" - "}\n\n"); + "$Request$>::Create(" + "channel_.get(), " + "rpcmethod_$Method$_, " + "context, response);\n" + "}\n\n"); printer->Print( *vars, @@ -1992,13 +1992,13 @@ void PrintSourceClientMethod(grpc_generator::Printer* printer, "::grpc::ClientReader< $Response$>* " "$ns$$Service$::Stub::$Method$Raw(" "::grpc::ClientContext* context, const $Request$& request) {\n"); - printer->Print(*vars, + printer->Print(*vars, " return ::grpc::internal::ClientReaderFactory< " - "$Response$>::Create(" - "channel_.get(), " - "rpcmethod_$Method$_, " - "context, request);\n" - "}\n\n"); + "$Response$>::Create(" + "channel_.get(), " + "rpcmethod_$Method$_, " + "context, request);\n" + "}\n\n"); printer->Print( *vars, @@ -2336,9 +2336,9 @@ TString GetMockPrologue(grpc_generator::File* file, vars["filename"] = file->filename(); vars["filename_base"] = file->filename_without_ext(); - vars["message_header_ext"] = params.message_header_extension.empty() - ? kCppGeneratorMessageHeaderExt - : params.message_header_extension; + vars["message_header_ext"] = params.message_header_extension.empty() + ? kCppGeneratorMessageHeaderExt + : params.message_header_extension; vars["service_header_ext"] = kCppGeneratorServiceHeaderExt; printer->Print(vars, "// Generated by the gRPC C++ plugin.\n"); @@ -2348,14 +2348,14 @@ TString GetMockPrologue(grpc_generator::File* file, printer->Print(vars, "#include \"$filename_base$$message_header_ext$\"\n"); printer->Print(vars, "#include \"$filename_base$$service_header_ext$\"\n"); - if (params.include_import_headers) { + if (params.include_import_headers) { const std::vector<TString> import_names = file->GetImportNames(); - for (const auto& import_name : import_names) { + for (const auto& import_name : import_names) { const TString include_name = ImportInludeFromProtoName(import_name); - printer->Print(vars, include_name.c_str()); - } - printer->PrintRaw("\n"); - } + printer->Print(vars, include_name.c_str()); + } + printer->PrintRaw("\n"); + } printer->Print(vars, file->additional_headers().c_str()); printer->Print(vars, "\n"); } @@ -2481,8 +2481,8 @@ void PrintMockClientMethods(grpc_generator::Printer* printer, printer->Print( *vars, "MOCK_METHOD$MockArgs$($AsyncPrefix$$Method$Raw, " - "::grpc::ClientAsyncReaderWriterInterface<$Request$, " - "$Response$>*" + "::grpc::ClientAsyncReaderWriterInterface<$Request$, " + "$Response$>*" "(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq" "$AsyncMethodParams$));\n"); } diff --git a/contrib/libs/grpc/src/compiler/cpp_generator.h b/contrib/libs/grpc/src/compiler/cpp_generator.h index 606b850a87..07166e4a1c 100644 --- a/contrib/libs/grpc/src/compiler/cpp_generator.h +++ b/contrib/libs/grpc/src/compiler/cpp_generator.h @@ -59,10 +59,10 @@ struct Parameters { TString gmock_search_path; // *EXPERIMENTAL* Additional include files in grpc.pb.h std::vector<TString> additional_header_includes; - // By default, use "pb.h" + // By default, use "pb.h" TString message_header_extension; - // Whether to include headers corresponding to imports in source file. - bool include_import_headers; + // Whether to include headers corresponding to imports in source file. + bool include_import_headers; }; // Return the prologue of the generated header file. diff --git a/contrib/libs/grpc/src/compiler/cpp_generator_helpers.h b/contrib/libs/grpc/src/compiler/cpp_generator_helpers.h index 2e34d53a65..773f6501c0 100644 --- a/contrib/libs/grpc/src/compiler/cpp_generator_helpers.h +++ b/contrib/libs/grpc/src/compiler/cpp_generator_helpers.h @@ -52,7 +52,7 @@ inline TString ClassName(const grpc::protobuf::Descriptor* descriptor, } // Get leading or trailing comments in a string. Comment lines start with "// ". -// Leading detached comments are put in front of leading comments. +// Leading detached comments are put in front of leading comments. template <typename DescriptorType> inline TString GetCppComments(const DescriptorType* desc, bool leading) { return grpc_generator::GetPrefixedComments(desc, leading, "//"); diff --git a/contrib/libs/grpc/src/compiler/cpp_plugin.cc b/contrib/libs/grpc/src/compiler/cpp_plugin.cc index 2de2745445..a234b1be70 100644 --- a/contrib/libs/grpc/src/compiler/cpp_plugin.cc +++ b/contrib/libs/grpc/src/compiler/cpp_plugin.cc @@ -18,7 +18,7 @@ // Generates cpp gRPC service interface out of Protobuf IDL. // -#include "src/compiler/cpp_plugin.h" +#include "src/compiler/cpp_plugin.h" int main(int argc, char* argv[]) { CppGrpcGenerator generator; diff --git a/contrib/libs/grpc/src/compiler/cpp_plugin.h b/contrib/libs/grpc/src/compiler/cpp_plugin.h index 0c289a7395..f0044a2e08 100644 --- a/contrib/libs/grpc/src/compiler/cpp_plugin.h +++ b/contrib/libs/grpc/src/compiler/cpp_plugin.h @@ -1,158 +1,158 @@ -/* - * - * Copyright 2019 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPC_INTERNAL_COMPILER_CPP_PLUGIN_H -#define GRPC_INTERNAL_COMPILER_CPP_PLUGIN_H - -#include <memory> -#include <sstream> - -#include "src/compiler/config.h" - -#include "src/compiler/cpp_generator.h" -#include "src/compiler/generator_helpers.h" -#include "src/compiler/protobuf_plugin.h" - -// Cpp Generator for Protobug IDL -class CppGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { - public: - CppGrpcGenerator() {} - virtual ~CppGrpcGenerator() {} - +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPC_INTERNAL_COMPILER_CPP_PLUGIN_H +#define GRPC_INTERNAL_COMPILER_CPP_PLUGIN_H + +#include <memory> +#include <sstream> + +#include "src/compiler/config.h" + +#include "src/compiler/cpp_generator.h" +#include "src/compiler/generator_helpers.h" +#include "src/compiler/protobuf_plugin.h" + +// Cpp Generator for Protobug IDL +class CppGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { + public: + CppGrpcGenerator() {} + virtual ~CppGrpcGenerator() {} + uint64_t GetSupportedFeatures() const override { return FEATURE_PROTO3_OPTIONAL; } - virtual bool Generate(const grpc::protobuf::FileDescriptor* file, + virtual bool Generate(const grpc::protobuf::FileDescriptor* file, const TString& parameter, - grpc::protobuf::compiler::GeneratorContext* context, + grpc::protobuf::compiler::GeneratorContext* context, TString* error) const override { - if (file->options().cc_generic_services()) { - *error = - "cpp grpc proto compiler plugin does not work with generic " - "services. To generate cpp grpc APIs, please set \"" - "cc_generic_service = false\"."; - return false; - } - - grpc_cpp_generator::Parameters generator_parameters; - generator_parameters.use_system_headers = true; - generator_parameters.generate_mock_code = false; - generator_parameters.include_import_headers = false; - - ProtoBufFile pbfile(file); - - if (!parameter.empty()) { + if (file->options().cc_generic_services()) { + *error = + "cpp grpc proto compiler plugin does not work with generic " + "services. To generate cpp grpc APIs, please set \"" + "cc_generic_service = false\"."; + return false; + } + + grpc_cpp_generator::Parameters generator_parameters; + generator_parameters.use_system_headers = true; + generator_parameters.generate_mock_code = false; + generator_parameters.include_import_headers = false; + + ProtoBufFile pbfile(file); + + if (!parameter.empty()) { std::vector<TString> parameters_list = - grpc_generator::tokenize(parameter, ","); - for (auto parameter_string = parameters_list.begin(); - parameter_string != parameters_list.end(); parameter_string++) { + grpc_generator::tokenize(parameter, ","); + for (auto parameter_string = parameters_list.begin(); + parameter_string != parameters_list.end(); parameter_string++) { std::vector<TString> param = - grpc_generator::tokenize(*parameter_string, "="); - if (param[0] == "services_namespace") { - generator_parameters.services_namespace = param[1]; - } else if (param[0] == "use_system_headers") { - if (param[1] == "true") { - generator_parameters.use_system_headers = true; - } else if (param[1] == "false") { - generator_parameters.use_system_headers = false; - } else { + grpc_generator::tokenize(*parameter_string, "="); + if (param[0] == "services_namespace") { + generator_parameters.services_namespace = param[1]; + } else if (param[0] == "use_system_headers") { + if (param[1] == "true") { + generator_parameters.use_system_headers = true; + } else if (param[1] == "false") { + generator_parameters.use_system_headers = false; + } else { *error = TString("Invalid parameter: ") + *parameter_string; - return false; - } - } else if (param[0] == "grpc_search_path") { - generator_parameters.grpc_search_path = param[1]; - } else if (param[0] == "generate_mock_code") { - if (param[1] == "true") { - generator_parameters.generate_mock_code = true; - } else if (param[1] != "false") { + return false; + } + } else if (param[0] == "grpc_search_path") { + generator_parameters.grpc_search_path = param[1]; + } else if (param[0] == "generate_mock_code") { + if (param[1] == "true") { + generator_parameters.generate_mock_code = true; + } else if (param[1] != "false") { *error = TString("Invalid parameter: ") + *parameter_string; - return false; - } - } else if (param[0] == "gmock_search_path") { - generator_parameters.gmock_search_path = param[1]; - } else if (param[0] == "additional_header_includes") { - generator_parameters.additional_header_includes = - grpc_generator::tokenize(param[1], ":"); - } else if (param[0] == "message_header_extension") { - generator_parameters.message_header_extension = param[1]; - } else if (param[0] == "include_import_headers") { - if (param[1] == "true") { - generator_parameters.include_import_headers = true; - } else if (param[1] != "false") { + return false; + } + } else if (param[0] == "gmock_search_path") { + generator_parameters.gmock_search_path = param[1]; + } else if (param[0] == "additional_header_includes") { + generator_parameters.additional_header_includes = + grpc_generator::tokenize(param[1], ":"); + } else if (param[0] == "message_header_extension") { + generator_parameters.message_header_extension = param[1]; + } else if (param[0] == "include_import_headers") { + if (param[1] == "true") { + generator_parameters.include_import_headers = true; + } else if (param[1] != "false") { *error = TString("Invalid parameter: ") + *parameter_string; - return false; - } - } else { + return false; + } + } else { *error = TString("Unknown parameter: ") + *parameter_string; - return false; - } - } - } - + return false; + } + } + } + TString file_name = grpc_generator::StripProto(file->name()); - + TString header_code = - grpc_cpp_generator::GetHeaderPrologue(&pbfile, generator_parameters) + - grpc_cpp_generator::GetHeaderIncludes(&pbfile, generator_parameters) + - grpc_cpp_generator::GetHeaderServices(&pbfile, generator_parameters) + - grpc_cpp_generator::GetHeaderEpilogue(&pbfile, generator_parameters); - std::unique_ptr<grpc::protobuf::io::ZeroCopyOutputStream> header_output( - context->Open(file_name + ".grpc.pb.h")); - grpc::protobuf::io::CodedOutputStream header_coded_out(header_output.get()); - header_coded_out.WriteRaw(header_code.data(), header_code.size()); - + grpc_cpp_generator::GetHeaderPrologue(&pbfile, generator_parameters) + + grpc_cpp_generator::GetHeaderIncludes(&pbfile, generator_parameters) + + grpc_cpp_generator::GetHeaderServices(&pbfile, generator_parameters) + + grpc_cpp_generator::GetHeaderEpilogue(&pbfile, generator_parameters); + std::unique_ptr<grpc::protobuf::io::ZeroCopyOutputStream> header_output( + context->Open(file_name + ".grpc.pb.h")); + grpc::protobuf::io::CodedOutputStream header_coded_out(header_output.get()); + header_coded_out.WriteRaw(header_code.data(), header_code.size()); + TString source_code = - grpc_cpp_generator::GetSourcePrologue(&pbfile, generator_parameters) + - grpc_cpp_generator::GetSourceIncludes(&pbfile, generator_parameters) + - grpc_cpp_generator::GetSourceServices(&pbfile, generator_parameters) + - grpc_cpp_generator::GetSourceEpilogue(&pbfile, generator_parameters); - std::unique_ptr<grpc::protobuf::io::ZeroCopyOutputStream> source_output( - context->Open(file_name + ".grpc.pb.cc")); - grpc::protobuf::io::CodedOutputStream source_coded_out(source_output.get()); - source_coded_out.WriteRaw(source_code.data(), source_code.size()); - - if (!generator_parameters.generate_mock_code) { - return true; - } + grpc_cpp_generator::GetSourcePrologue(&pbfile, generator_parameters) + + grpc_cpp_generator::GetSourceIncludes(&pbfile, generator_parameters) + + grpc_cpp_generator::GetSourceServices(&pbfile, generator_parameters) + + grpc_cpp_generator::GetSourceEpilogue(&pbfile, generator_parameters); + std::unique_ptr<grpc::protobuf::io::ZeroCopyOutputStream> source_output( + context->Open(file_name + ".grpc.pb.cc")); + grpc::protobuf::io::CodedOutputStream source_coded_out(source_output.get()); + source_coded_out.WriteRaw(source_code.data(), source_code.size()); + + if (!generator_parameters.generate_mock_code) { + return true; + } TString mock_code = - grpc_cpp_generator::GetMockPrologue(&pbfile, generator_parameters) + - grpc_cpp_generator::GetMockIncludes(&pbfile, generator_parameters) + - grpc_cpp_generator::GetMockServices(&pbfile, generator_parameters) + - grpc_cpp_generator::GetMockEpilogue(&pbfile, generator_parameters); - std::unique_ptr<grpc::protobuf::io::ZeroCopyOutputStream> mock_output( - context->Open(file_name + "_mock.grpc.pb.h")); - grpc::protobuf::io::CodedOutputStream mock_coded_out(mock_output.get()); - mock_coded_out.WriteRaw(mock_code.data(), mock_code.size()); - - return true; - } - - private: - // Insert the given code into the given file at the given insertion point. - void Insert(grpc::protobuf::compiler::GeneratorContext* context, + grpc_cpp_generator::GetMockPrologue(&pbfile, generator_parameters) + + grpc_cpp_generator::GetMockIncludes(&pbfile, generator_parameters) + + grpc_cpp_generator::GetMockServices(&pbfile, generator_parameters) + + grpc_cpp_generator::GetMockEpilogue(&pbfile, generator_parameters); + std::unique_ptr<grpc::protobuf::io::ZeroCopyOutputStream> mock_output( + context->Open(file_name + "_mock.grpc.pb.h")); + grpc::protobuf::io::CodedOutputStream mock_coded_out(mock_output.get()); + mock_coded_out.WriteRaw(mock_code.data(), mock_code.size()); + + return true; + } + + private: + // Insert the given code into the given file at the given insertion point. + void Insert(grpc::protobuf::compiler::GeneratorContext* context, const TString& filename, const TString& insertion_point, const TString& code) const { - std::unique_ptr<grpc::protobuf::io::ZeroCopyOutputStream> output( - context->OpenForInsert(filename, insertion_point)); - grpc::protobuf::io::CodedOutputStream coded_out(output.get()); - coded_out.WriteRaw(code.data(), code.size()); - } -}; - -#endif // GRPC_INTERNAL_COMPILER_CPP_PLUGIN_H + std::unique_ptr<grpc::protobuf::io::ZeroCopyOutputStream> output( + context->OpenForInsert(filename, insertion_point)); + grpc::protobuf::io::CodedOutputStream coded_out(output.get()); + coded_out.WriteRaw(code.data(), code.size()); + } +}; + +#endif // GRPC_INTERNAL_COMPILER_CPP_PLUGIN_H diff --git a/contrib/libs/grpc/src/compiler/csharp_generator.cc b/contrib/libs/grpc/src/compiler/csharp_generator.cc index 3b7107c4c4..89973adc8b 100644 --- a/contrib/libs/grpc/src/compiler/csharp_generator.cc +++ b/contrib/libs/grpc/src/compiler/csharp_generator.cc @@ -445,10 +445,10 @@ void GenerateServerClass(Printer* out, const ServiceDescriptor* service) { "/// <summary>Base class for server-side implementations of " "$servicename$</summary>\n", "servicename", GetServiceClassName(service)); - out->Print( - "[grpc::BindServiceMethod(typeof($classname$), " - "\"BindService\")]\n", - "classname", GetServiceClassName(service)); + out->Print( + "[grpc::BindServiceMethod(typeof($classname$), " + "\"BindService\")]\n", + "classname", GetServiceClassName(service)); out->Print("public abstract partial class $name$\n", "name", GetServerClassName(service)); out->Print("{\n"); @@ -491,8 +491,8 @@ void GenerateClientStub(Printer* out, const ServiceDescriptor* service) { "/// <param name=\"channel\">The channel to use to make remote " "calls.</param>\n", "servicename", GetServiceClassName(service)); - out->Print("public $name$(grpc::ChannelBase channel) : base(channel)\n", - "name", GetClientClassName(service)); + out->Print("public $name$(grpc::ChannelBase channel) : base(channel)\n", + "name", GetClientClassName(service)); out->Print("{\n"); out->Print("}\n"); out->Print( diff --git a/contrib/libs/grpc/src/compiler/csharp_generator_helpers.h b/contrib/libs/grpc/src/compiler/csharp_generator_helpers.h index a8af7f3ccd..ec2e449d8e 100644 --- a/contrib/libs/grpc/src/compiler/csharp_generator_helpers.h +++ b/contrib/libs/grpc/src/compiler/csharp_generator_helpers.h @@ -32,7 +32,7 @@ inline bool ServicesFilename(const grpc::protobuf::FileDescriptor* file, } // Get leading or trailing comments in a string. Comment lines start with "// ". -// Leading detached comments are put in front of leading comments. +// Leading detached comments are put in front of leading comments. template <typename DescriptorType> inline TString GetCsharpComments(const DescriptorType* desc, bool leading) { return grpc_generator::GetPrefixedComments(desc, leading, "//"); diff --git a/contrib/libs/grpc/src/compiler/grpc_cpp_plugin/ya.make b/contrib/libs/grpc/src/compiler/grpc_cpp_plugin/ya.make index a4b7e363a3..4dc845bede 100644 --- a/contrib/libs/grpc/src/compiler/grpc_cpp_plugin/ya.make +++ b/contrib/libs/grpc/src/compiler/grpc_cpp_plugin/ya.make @@ -1,37 +1,37 @@ -# Generated by devtools/yamaker. - -PROGRAM() - +# Generated by devtools/yamaker. + +PROGRAM() + WITHOUT_LICENSE_TEXTS() OWNER(g:cpp-contrib) - -LICENSE(Apache-2.0) - -PEERDIR( - contrib/libs/grpc/src/compiler/grpc_plugin_support + +LICENSE(Apache-2.0) + +PEERDIR( + contrib/libs/grpc/src/compiler/grpc_plugin_support contrib/libs/protobuf contrib/libs/protoc -) - -ADDINCL( +) + +ADDINCL( ${ARCADIA_BUILD_ROOT}/contrib/libs/grpc - contrib/libs/grpc - contrib/libs/grpc/include -) - -NO_COMPILER_WARNINGS() - -SRCDIR(contrib/libs/grpc/src/compiler) - -IF (OS_LINUX OR OS_DARWIN) + contrib/libs/grpc + contrib/libs/grpc/include +) + +NO_COMPILER_WARNINGS() + +SRCDIR(contrib/libs/grpc/src/compiler) + +IF (OS_LINUX OR OS_DARWIN) CFLAGS( -DGRPC_POSIX_FORK_ALLOW_PTHREAD_ATFORK=1 ) -ENDIF() - -SRCS( - cpp_plugin.cc -) - -END() +ENDIF() + +SRCS( + cpp_plugin.cc +) + +END() diff --git a/contrib/libs/grpc/src/compiler/grpc_plugin_support/ya.make b/contrib/libs/grpc/src/compiler/grpc_plugin_support/ya.make index 068ae1ead6..1d1a812b8d 100644 --- a/contrib/libs/grpc/src/compiler/grpc_plugin_support/ya.make +++ b/contrib/libs/grpc/src/compiler/grpc_plugin_support/ya.make @@ -1,37 +1,37 @@ -# Generated by devtools/yamaker. - -LIBRARY() - +# Generated by devtools/yamaker. + +LIBRARY() + WITHOUT_LICENSE_TEXTS() OWNER(g:cpp-contrib) LICENSE(Apache-2.0) -PEERDIR( +PEERDIR( contrib/libs/protobuf contrib/libs/protoc -) - -ADDINCL( - GLOBAL contrib/libs/grpc/include +) + +ADDINCL( + GLOBAL contrib/libs/grpc/include ${ARCADIA_BUILD_ROOT}/contrib/libs/grpc - contrib/libs/grpc -) - -NO_COMPILER_WARNINGS() - -SRCDIR(contrib/libs/grpc/src/compiler) - -IF (OS_LINUX OR OS_DARWIN) + contrib/libs/grpc +) + +NO_COMPILER_WARNINGS() + +SRCDIR(contrib/libs/grpc/src/compiler) + +IF (OS_LINUX OR OS_DARWIN) CFLAGS( -DGRPC_POSIX_FORK_ALLOW_PTHREAD_ATFORK=1 ) -ENDIF() - -SRCS( - cpp_generator.cc - python_generator.cc -) - -END() +ENDIF() + +SRCS( + cpp_generator.cc + python_generator.cc +) + +END() diff --git a/contrib/libs/grpc/src/compiler/grpc_python_plugin/ya.make b/contrib/libs/grpc/src/compiler/grpc_python_plugin/ya.make index cf2a106c91..66a25d1613 100644 --- a/contrib/libs/grpc/src/compiler/grpc_python_plugin/ya.make +++ b/contrib/libs/grpc/src/compiler/grpc_python_plugin/ya.make @@ -1,36 +1,36 @@ -# Generated by devtools/yamaker. - -PROGRAM() - +# Generated by devtools/yamaker. + +PROGRAM() + WITHOUT_LICENSE_TEXTS() OWNER(g:cpp-contrib) - -LICENSE(Apache-2.0) - -PEERDIR( - contrib/libs/grpc/src/compiler/grpc_plugin_support + +LICENSE(Apache-2.0) + +PEERDIR( + contrib/libs/grpc/src/compiler/grpc_plugin_support contrib/libs/protoc -) - -ADDINCL( +) + +ADDINCL( ${ARCADIA_BUILD_ROOT}/contrib/libs/grpc - contrib/libs/grpc - contrib/libs/grpc/include -) - -NO_COMPILER_WARNINGS() - -SRCDIR(contrib/libs/grpc/src/compiler) - -IF (OS_LINUX OR OS_DARWIN) + contrib/libs/grpc + contrib/libs/grpc/include +) + +NO_COMPILER_WARNINGS() + +SRCDIR(contrib/libs/grpc/src/compiler) + +IF (OS_LINUX OR OS_DARWIN) CFLAGS( -DGRPC_POSIX_FORK_ALLOW_PTHREAD_ATFORK=1 ) -ENDIF() - -SRCS( - python_plugin.cc -) - -END() +ENDIF() + +SRCS( + python_plugin.cc +) + +END() diff --git a/contrib/libs/grpc/src/compiler/node_generator_helpers.h b/contrib/libs/grpc/src/compiler/node_generator_helpers.h index ccf57ec8a6..7c56eb6a99 100644 --- a/contrib/libs/grpc/src/compiler/node_generator_helpers.h +++ b/contrib/libs/grpc/src/compiler/node_generator_helpers.h @@ -31,7 +31,7 @@ inline TString GetJSServiceFilename(const TString& filename) { } // Get leading or trailing comments in a string. Comment lines start with "// ". -// Leading detached comments are put in front of leading comments. +// Leading detached comments are put in front of leading comments. template <typename DescriptorType> inline TString GetNodeComments(const DescriptorType* desc, bool leading) { return grpc_generator::GetPrefixedComments(desc, leading, "//"); diff --git a/contrib/libs/grpc/src/compiler/objective_c_generator.cc b/contrib/libs/grpc/src/compiler/objective_c_generator.cc index 07826b6a8d..6ae14d6c76 100644 --- a/contrib/libs/grpc/src/compiler/objective_c_generator.cc +++ b/contrib/libs/grpc/src/compiler/objective_c_generator.cc @@ -49,8 +49,8 @@ void PrintProtoRpcDeclarationAsPragma(Printer* printer, } template <typename DescriptorType> -static void PrintAllComments(const DescriptorType* desc, Printer* printer, - bool deprecated = false) { +static void PrintAllComments(const DescriptorType* desc, Printer* printer, + bool deprecated = false) { std::vector<TString> comments; grpc_generator::GetComment(desc, grpc_generator::COMMENTTYPE_LEADING_DETACHED, &comments); @@ -70,20 +70,20 @@ static void PrintAllComments(const DescriptorType* desc, Printer* printer, } printer->Print("\n"); } - if (deprecated) { - printer->Print(" *\n"); - printer->Print( - " * This method belongs to a set of APIs that have been deprecated. " - "Using" - " the v2 API is recommended.\n"); - } + if (deprecated) { + printer->Print(" *\n"); + printer->Print( + " * This method belongs to a set of APIs that have been deprecated. " + "Using" + " the v2 API is recommended.\n"); + } printer->Print(" */\n"); } void PrintMethodSignature(Printer* printer, const MethodDescriptor* method, const map< ::TString, ::TString>& vars) { // Print comment - PrintAllComments(method, printer, true); + PrintAllComments(method, printer, true); printer->Print(vars, "- ($return_type$)$method_name$With"); if (method->client_streaming()) { @@ -237,21 +237,21 @@ void PrintV2Implementation(Printer* printer, const MethodDescriptor* method, } void PrintMethodImplementations(Printer* printer, - const MethodDescriptor* method, - const Parameters& generator_params) { + const MethodDescriptor* method, + const Parameters& generator_params) { map< ::TString, ::TString> vars = GetMethodVars(method); PrintProtoRpcDeclarationAsPragma(printer, method, vars); - if (!generator_params.no_v1_compatibility) { - // TODO(jcanizales): Print documentation from the method. - PrintSimpleSignature(printer, method, vars); - PrintSimpleImplementation(printer, method, vars); + if (!generator_params.no_v1_compatibility) { + // TODO(jcanizales): Print documentation from the method. + PrintSimpleSignature(printer, method, vars); + PrintSimpleImplementation(printer, method, vars); - printer->Print("// Returns a not-yet-started RPC object.\n"); - PrintAdvancedSignature(printer, method, vars); - PrintAdvancedImplementation(printer, method, vars); - } + printer->Print("// Returns a not-yet-started RPC object.\n"); + PrintAdvancedSignature(printer, method, vars); + PrintAdvancedImplementation(printer, method, vars); + } PrintV2Signature(printer, method, vars); PrintV2Implementation(printer, method, vars); @@ -281,8 +281,8 @@ void PrintMethodImplementations(Printer* printer, const Parameters& generator_params) { ::TString output; - if (generator_params.no_v1_compatibility) return output; - + if (generator_params.no_v1_compatibility) return output; + // Scope the output stream so it closes and finalizes output to the string. grpc::protobuf::io::StringOutputStream output_stream(&output); Printer printer(&output_stream, '$'); @@ -290,13 +290,13 @@ void PrintMethodImplementations(Printer* printer, map< ::TString, ::TString> vars = { {"service_class", ServiceClassName(service)}}; - printer.Print(vars, - "/**\n" - " * The methods in this protocol belong to a set of old APIs " - "that have been deprecated. They do not\n" - " * recognize call options provided in the initializer. Using " - "the v2 protocol is recommended.\n" - " */\n"); + printer.Print(vars, + "/**\n" + " * The methods in this protocol belong to a set of old APIs " + "that have been deprecated. They do not\n" + " * recognize call options provided in the initializer. Using " + "the v2 protocol is recommended.\n" + " */\n"); printer.Print(vars, "@protocol $service_class$ <NSObject>\n\n"); for (int i = 0; i < service->method_count(); i++) { PrintMethodDeclarations(&printer, service->method(i)); @@ -343,11 +343,11 @@ void PrintMethodImplementations(Printer* printer, " */\n"); printer.Print(vars, "@interface $service_class$ :" - " GRPCProtoService<$service_class$2"); - if (!generator_params.no_v1_compatibility) { - printer.Print(vars, ", $service_class$"); - } - printer.Print(">\n"); + " GRPCProtoService<$service_class$2"); + if (!generator_params.no_v1_compatibility) { + printer.Print(vars, ", $service_class$"); + } + printer.Print(">\n"); printer.Print( "- (instancetype)initWithHost:(NSString *)host " "callOptions:(GRPCCallOptions " @@ -356,13 +356,13 @@ void PrintMethodImplementations(Printer* printer, printer.Print( "+ (instancetype)serviceWithHost:(NSString *)host " "callOptions:(GRPCCallOptions *_Nullable)callOptions;\n"); - if (!generator_params.no_v1_compatibility) { - printer.Print( - "// The following methods belong to a set of old APIs that have been " - "deprecated.\n"); - printer.Print("- (instancetype)initWithHost:(NSString *)host;\n"); - printer.Print("+ (instancetype)serviceWithHost:(NSString *)host;\n"); - } + if (!generator_params.no_v1_compatibility) { + printer.Print( + "// The following methods belong to a set of old APIs that have been " + "deprecated.\n"); + printer.Print("- (instancetype)initWithHost:(NSString *)host;\n"); + printer.Print("+ (instancetype)serviceWithHost:(NSString *)host;\n"); + } printer.Print("@end\n"); return output; @@ -393,27 +393,27 @@ void PrintMethodImplementations(Printer* printer, " packageName:@\"$package$\"\n" " serviceName:@\"$service_name$\"\n" " callOptions:callOptions];\n" - "}\n\n"); - if (!generator_params.no_v1_compatibility) { - printer.Print(vars, - "- (instancetype)initWithHost:(NSString *)host {\n" - " return [super initWithHost:host\n" - " packageName:@\"$package$\"\n" - " serviceName:@\"$service_name$\"];\n" - "}\n\n"); - } - printer.Print("#pragma clang diagnostic pop\n\n"); - - if (!generator_params.no_v1_compatibility) { - printer.Print( - "// Override superclass initializer to disallow different" - " package and service names.\n" - "- (instancetype)initWithHost:(NSString *)host\n" - " packageName:(NSString *)packageName\n" - " serviceName:(NSString *)serviceName {\n" - " return [self initWithHost:host];\n" - "}\n\n"); - } + "}\n\n"); + if (!generator_params.no_v1_compatibility) { + printer.Print(vars, + "- (instancetype)initWithHost:(NSString *)host {\n" + " return [super initWithHost:host\n" + " packageName:@\"$package$\"\n" + " serviceName:@\"$service_name$\"];\n" + "}\n\n"); + } + printer.Print("#pragma clang diagnostic pop\n\n"); + + if (!generator_params.no_v1_compatibility) { + printer.Print( + "// Override superclass initializer to disallow different" + " package and service names.\n" + "- (instancetype)initWithHost:(NSString *)host\n" + " packageName:(NSString *)packageName\n" + " serviceName:(NSString *)serviceName {\n" + " return [self initWithHost:host];\n" + "}\n\n"); + } printer.Print( "- (instancetype)initWithHost:(NSString *)host\n" " packageName:(NSString *)packageName\n" @@ -422,13 +422,13 @@ void PrintMethodImplementations(Printer* printer, " return [self initWithHost:host callOptions:callOptions];\n" "}\n\n"); - printer.Print("#pragma mark - Class Methods\n\n"); - if (!generator_params.no_v1_compatibility) { - printer.Print( - "+ (instancetype)serviceWithHost:(NSString *)host {\n" - " return [[self alloc] initWithHost:host];\n" - "}\n\n"); - } + printer.Print("#pragma mark - Class Methods\n\n"); + if (!generator_params.no_v1_compatibility) { + printer.Print( + "+ (instancetype)serviceWithHost:(NSString *)host {\n" + " return [[self alloc] initWithHost:host];\n" + "}\n\n"); + } printer.Print( "+ (instancetype)serviceWithHost:(NSString *)host " "callOptions:(GRPCCallOptions *_Nullable)callOptions {\n" @@ -438,8 +438,8 @@ void PrintMethodImplementations(Printer* printer, printer.Print("#pragma mark - Method Implementations\n\n"); for (int i = 0; i < service->method_count(); i++) { - PrintMethodImplementations(&printer, service->method(i), - generator_params); + PrintMethodImplementations(&printer, service->method(i), + generator_params); } printer.Print("@end\n"); diff --git a/contrib/libs/grpc/src/compiler/objective_c_generator.h b/contrib/libs/grpc/src/compiler/objective_c_generator.h index 9770f65436..c51a1b81fa 100644 --- a/contrib/libs/grpc/src/compiler/objective_c_generator.h +++ b/contrib/libs/grpc/src/compiler/objective_c_generator.h @@ -23,11 +23,11 @@ namespace grpc_objective_c_generator { -struct Parameters { - // Do not generate V1 interface and implementation - bool no_v1_compatibility; -}; - +struct Parameters { + // Do not generate V1 interface and implementation + bool no_v1_compatibility; +}; + using ::grpc::protobuf::FileDescriptor; using ::grpc::protobuf::ServiceDescriptor; using ::TString; @@ -38,8 +38,8 @@ string GetAllMessageClasses(const FileDescriptor* file); // Returns the content to be included defining the @protocol segment at the // insertion point of the generated implementation file. This interface is // legacy and for backwards compatibility. -string GetProtocol(const ServiceDescriptor* service, - const Parameters& generator_params); +string GetProtocol(const ServiceDescriptor* service, + const Parameters& generator_params); // Returns the content to be included defining the @protocol segment at the // insertion point of the generated implementation file. @@ -47,13 +47,13 @@ string GetV2Protocol(const ServiceDescriptor* service); // Returns the content to be included defining the @interface segment at the // insertion point of the generated implementation file. -string GetInterface(const ServiceDescriptor* service, - const Parameters& generator_params); +string GetInterface(const ServiceDescriptor* service, + const Parameters& generator_params); // Returns the content to be included in the "global_scope" insertion point of // the generated implementation file. -string GetSource(const ServiceDescriptor* service, - const Parameters& generator_params); +string GetSource(const ServiceDescriptor* service, + const Parameters& generator_params); } // namespace grpc_objective_c_generator diff --git a/contrib/libs/grpc/src/compiler/objective_c_generator_helpers.h b/contrib/libs/grpc/src/compiler/objective_c_generator_helpers.h index ae296741ce..b9be5a53dd 100644 --- a/contrib/libs/grpc/src/compiler/objective_c_generator_helpers.h +++ b/contrib/libs/grpc/src/compiler/objective_c_generator_helpers.h @@ -47,14 +47,14 @@ inline ::TString LocalImport(const ::TString& import) { inline ::TString FrameworkImport(const ::TString& import, const ::TString& framework) { - // Flattens the directory structure: grab the file name only - std::size_t pos = import.rfind("/"); - // If pos is npos, pos + 1 is 0, which gives us the entire string, - // so there's no need to check that + // Flattens the directory structure: grab the file name only + std::size_t pos = import.rfind("/"); + // If pos is npos, pos + 1 is 0, which gives us the entire string, + // so there's no need to check that ::TString filename = import.substr(pos + 1, import.size() - (pos + 1)); return ::TString("#import <" + framework + "/" + filename + ">\n"); -} - +} + inline ::TString SystemImport(const ::TString& import) { return ::TString("#import <" + import + ">\n"); } diff --git a/contrib/libs/grpc/src/compiler/php_generator_helpers.h b/contrib/libs/grpc/src/compiler/php_generator_helpers.h index 70a31eaf75..964bf00dff 100644 --- a/contrib/libs/grpc/src/compiler/php_generator_helpers.h +++ b/contrib/libs/grpc/src/compiler/php_generator_helpers.h @@ -63,7 +63,7 @@ inline TString GetPHPServiceFilename( } // Get leading or trailing comments in a string. Comment lines start with "// ". -// Leading detached comments are put in front of leading comments. +// Leading detached comments are put in front of leading comments. template <typename DescriptorType> inline TString GetPHPComments(const DescriptorType* desc, TString prefix) { diff --git a/contrib/libs/grpc/src/compiler/protobuf_plugin.h b/contrib/libs/grpc/src/compiler/protobuf_plugin.h index ef844ea055..f3edcd0413 100644 --- a/contrib/libs/grpc/src/compiler/protobuf_plugin.h +++ b/contrib/libs/grpc/src/compiler/protobuf_plugin.h @@ -55,23 +55,23 @@ class ProtoBufMethod : public grpc_generator::Method { return method_->output_type()->file()->name(); } - // TODO(https://github.com/grpc/grpc/issues/18800): Clean this up. - bool get_module_and_message_path_input( + // TODO(https://github.com/grpc/grpc/issues/18800): Clean this up. + bool get_module_and_message_path_input( TString* str, TString generator_file_name, bool generate_in_pb2_grpc, TString import_prefix, const std::vector<TString>& prefixes_to_filter) const final { return grpc_python_generator::GetModuleAndMessagePath( method_->input_type(), str, generator_file_name, generate_in_pb2_grpc, - import_prefix, prefixes_to_filter); + import_prefix, prefixes_to_filter); } - bool get_module_and_message_path_output( + bool get_module_and_message_path_output( TString* str, TString generator_file_name, bool generate_in_pb2_grpc, TString import_prefix, const std::vector<TString>& prefixes_to_filter) const final { return grpc_python_generator::GetModuleAndMessagePath( method_->output_type(), str, generator_file_name, generate_in_pb2_grpc, - import_prefix, prefixes_to_filter); + import_prefix, prefixes_to_filter); } bool NoStreaming() const { @@ -109,11 +109,11 @@ class ProtoBufService : public grpc_generator::Service { TString name() const { return service_->name(); } - int method_count() const { return service_->method_count(); } + int method_count() const { return service_->method_count(); } std::unique_ptr<const grpc_generator::Method> method(int i) const { return std::unique_ptr<const grpc_generator::Method>( new ProtoBufMethod(service_->method(i))); - } + } TString GetLeadingComments(const TString prefix) const { return GetCommentsHelper(service_, true, prefix); @@ -167,7 +167,7 @@ class ProtoBufFile : public grpc_generator::File { TString additional_headers() const { return ""; } - int service_count() const { return file_->service_count(); } + int service_count() const { return file_->service_count(); } std::unique_ptr<const grpc_generator::Service> service(int i) const { return std::unique_ptr<const grpc_generator::Service>( new ProtoBufService(file_->service(i))); @@ -192,13 +192,13 @@ class ProtoBufFile : public grpc_generator::File { vector<TString> GetImportNames() const { vector<TString> proto_names; - for (int i = 0; i < file_->dependency_count(); ++i) { - const auto& dep = *file_->dependency(i); - proto_names.push_back(dep.name()); - } - return proto_names; - } - + for (int i = 0; i < file_->dependency_count(); ++i) { + const auto& dep = *file_->dependency(i); + proto_names.push_back(dep.name()); + } + return proto_names; + } + private: const grpc::protobuf::FileDescriptor* file_; }; diff --git a/contrib/libs/grpc/src/compiler/python_generator.cc b/contrib/libs/grpc/src/compiler/python_generator.cc index d083d19f0b..49adf20e2a 100644 --- a/contrib/libs/grpc/src/compiler/python_generator.cc +++ b/contrib/libs/grpc/src/compiler/python_generator.cc @@ -221,15 +221,15 @@ bool PrivateGenerator::PrintBetaServerFactory( TString input_message_module_and_class; if (!method->get_module_and_message_path_input( &input_message_module_and_class, generator_file_name, - generate_in_pb2_grpc, config.import_prefix, - config.prefixes_to_filter)) { + generate_in_pb2_grpc, config.import_prefix, + config.prefixes_to_filter)) { return false; } TString output_message_module_and_class; if (!method->get_module_and_message_path_output( &output_message_module_and_class, generator_file_name, - generate_in_pb2_grpc, config.import_prefix, - config.prefixes_to_filter)) { + generate_in_pb2_grpc, config.import_prefix, + config.prefixes_to_filter)) { return false; } method_implementation_constructors.insert( @@ -329,15 +329,15 @@ bool PrivateGenerator::PrintBetaStubFactory( TString input_message_module_and_class; if (!method->get_module_and_message_path_input( &input_message_module_and_class, generator_file_name, - generate_in_pb2_grpc, config.import_prefix, - config.prefixes_to_filter)) { + generate_in_pb2_grpc, config.import_prefix, + config.prefixes_to_filter)) { return false; } TString output_message_module_and_class; if (!method->get_module_and_message_path_output( &output_message_module_and_class, generator_file_name, - generate_in_pb2_grpc, config.import_prefix, - config.prefixes_to_filter)) { + generate_in_pb2_grpc, config.import_prefix, + config.prefixes_to_filter)) { return false; } method_cardinalities.insert( @@ -436,15 +436,15 @@ bool PrivateGenerator::PrintStub( TString request_module_and_class; if (!method->get_module_and_message_path_input( &request_module_and_class, generator_file_name, - generate_in_pb2_grpc, config.import_prefix, - config.prefixes_to_filter)) { + generate_in_pb2_grpc, config.import_prefix, + config.prefixes_to_filter)) { return false; } TString response_module_and_class; if (!method->get_module_and_message_path_output( &response_module_and_class, generator_file_name, - generate_in_pb2_grpc, config.import_prefix, - config.prefixes_to_filter)) { + generate_in_pb2_grpc, config.import_prefix, + config.prefixes_to_filter)) { return false; } StringMap method_dict; @@ -529,15 +529,15 @@ bool PrivateGenerator::PrintAddServicerToServer( TString request_module_and_class; if (!method->get_module_and_message_path_input( &request_module_and_class, generator_file_name, - generate_in_pb2_grpc, config.import_prefix, - config.prefixes_to_filter)) { + generate_in_pb2_grpc, config.import_prefix, + config.prefixes_to_filter)) { return false; } TString response_module_and_class; if (!method->get_module_and_message_path_output( &response_module_and_class, generator_file_name, - generate_in_pb2_grpc, config.import_prefix, - config.prefixes_to_filter)) { + generate_in_pb2_grpc, config.import_prefix, + config.prefixes_to_filter)) { return false; } StringMap method_dict; @@ -693,20 +693,20 @@ bool PrivateGenerator::PrintPreamble(grpc_generator::Printer* out) { TString input_type_file_name = method->get_input_type_name(); TString input_module_name = ModuleName(input_type_file_name, config.import_prefix, - config.prefixes_to_filter); + config.prefixes_to_filter); TString input_module_alias = ModuleAlias(input_type_file_name, config.import_prefix, - config.prefixes_to_filter); + config.prefixes_to_filter); imports_set.insert( std::make_tuple(input_module_name, input_module_alias)); TString output_type_file_name = method->get_output_type_name(); TString output_module_name = ModuleName(output_type_file_name, config.import_prefix, - config.prefixes_to_filter); + config.prefixes_to_filter); TString output_module_alias = ModuleAlias(output_type_file_name, config.import_prefix, - config.prefixes_to_filter); + config.prefixes_to_filter); imports_set.insert( std::make_tuple(output_module_name, output_module_alias)); } @@ -860,24 +860,24 @@ static bool ParseParameters(const TString& parameter, std::vector<TString>* strip_prefixes, TString* error) { std::vector<TString> comma_delimited_parameters; - grpc_python_generator::Split(parameter, ',', &comma_delimited_parameters); - if (comma_delimited_parameters.size() == 1 && - comma_delimited_parameters[0].empty()) { - *grpc_version = "grpc_2_0"; - } else if (comma_delimited_parameters.size() == 1) { - *grpc_version = comma_delimited_parameters[0]; - } else if (comma_delimited_parameters.size() == 2) { - *grpc_version = comma_delimited_parameters[0]; - std::copy(comma_delimited_parameters.begin() + 1, - comma_delimited_parameters.end(), - std::back_inserter(*strip_prefixes)); - } else { - *error = "--grpc_python_out received too many comma-delimited parameters."; - return false; - } - return true; -} - + grpc_python_generator::Split(parameter, ',', &comma_delimited_parameters); + if (comma_delimited_parameters.size() == 1 && + comma_delimited_parameters[0].empty()) { + *grpc_version = "grpc_2_0"; + } else if (comma_delimited_parameters.size() == 1) { + *grpc_version = comma_delimited_parameters[0]; + } else if (comma_delimited_parameters.size() == 2) { + *grpc_version = comma_delimited_parameters[0]; + std::copy(comma_delimited_parameters.begin() + 1, + comma_delimited_parameters.end(), + std::back_inserter(*strip_prefixes)); + } else { + *error = "--grpc_python_out received too many comma-delimited parameters."; + return false; + } + return true; +} + uint64_t PythonGrpcGenerator::GetSupportedFeatures() const { return FEATURE_PROTO3_OPTIONAL; } @@ -904,18 +904,18 @@ bool PythonGrpcGenerator::Generate(const FileDescriptor* file, ProtoBufFile pbfile(file); TString grpc_version; - GeneratorConfiguration extended_config(config_); - bool success = ParseParameters(parameter, &grpc_version, - &(extended_config.prefixes_to_filter), error); - PrivateGenerator generator(extended_config, &pbfile); - if (!success) return false; - if (grpc_version == "grpc_2_0") { + GeneratorConfiguration extended_config(config_); + bool success = ParseParameters(parameter, &grpc_version, + &(extended_config.prefixes_to_filter), error); + PrivateGenerator generator(extended_config, &pbfile); + if (!success) return false; + if (grpc_version == "grpc_2_0") { return GenerateGrpc(context, generator, pb2_grpc_file_name, true); - } else if (grpc_version == "grpc_1_0") { + } else if (grpc_version == "grpc_1_0") { return GenerateGrpc(context, generator, pb2_grpc_file_name, true) && GenerateGrpc(context, generator, pb2_file_name, false); } else { - *error = "Invalid grpc version '" + grpc_version + "'."; + *error = "Invalid grpc version '" + grpc_version + "'."; return false; } } diff --git a/contrib/libs/grpc/src/compiler/python_generator.h b/contrib/libs/grpc/src/compiler/python_generator.h index bcde0a5e35..2e26a0315d 100644 --- a/contrib/libs/grpc/src/compiler/python_generator.h +++ b/contrib/libs/grpc/src/compiler/python_generator.h @@ -20,7 +20,7 @@ #define GRPC_INTERNAL_COMPILER_PYTHON_GENERATOR_H #include <utility> -#include <vector> +#include <vector> #include "src/compiler/config.h" #include "src/compiler/schema_interface.h" diff --git a/contrib/libs/grpc/src/compiler/python_generator_helpers.h b/contrib/libs/grpc/src/compiler/python_generator_helpers.h index 78e7efd7e0..c14b1bc3da 100644 --- a/contrib/libs/grpc/src/compiler/python_generator_helpers.h +++ b/contrib/libs/grpc/src/compiler/python_generator_helpers.h @@ -52,15 +52,15 @@ typedef vector<TString> StringVector; static TString StripModulePrefixes( const TString& raw_module_name, const std::vector<TString>& prefixes_to_filter) { - for (const auto& prefix : prefixes_to_filter) { - if (raw_module_name.rfind(prefix, 0) == 0) { - return raw_module_name.substr(prefix.size(), - raw_module_name.size() - prefix.size()); - } - } - return raw_module_name; -} - + for (const auto& prefix : prefixes_to_filter) { + if (raw_module_name.rfind(prefix, 0) == 0) { + return raw_module_name.substr(prefix.size(), + raw_module_name.size() - prefix.size()); + } + } + return raw_module_name; +} + // TODO(https://github.com/google/protobuf/issues/888): // Export `ModuleName` from protobuf's // `src/google/protobuf/compiler/python/python_generator.cc` file. @@ -70,8 +70,8 @@ TString ModuleName(const TString& filename, TString basename = StripProto(filename); basename = StringReplace(basename, "-", "_"); basename = StringReplace(basename, "/", "."); - return StripModulePrefixes(import_prefix + basename + "_pb2", - prefixes_to_filter); + return StripModulePrefixes(import_prefix + basename + "_pb2", + prefixes_to_filter); } // TODO(https://github.com/google/protobuf/issues/888): @@ -90,7 +90,7 @@ TString ModuleAlias(const TString& filename, return module_name; } -bool GetModuleAndMessagePath( +bool GetModuleAndMessagePath( const Descriptor* type, TString* out, TString generator_file_name, bool generate_in_pb2_grpc, TString& import_prefix, const std::vector<TString>& prefixes_to_filter) { @@ -138,14 +138,14 @@ StringVector get_all_comments(const DescriptorType* descriptor) { inline void Split(const TString& s, char delim, std::vector<TString>* append_to) { - auto current = s.begin(); - while (current <= s.end()) { - auto next = std::find(current, s.end(), delim); - append_to->emplace_back(current, next); - current = next + 1; - } -} - + auto current = s.begin(); + while (current <= s.end()) { + auto next = std::find(current, s.end(), delim); + append_to->emplace_back(current, next); + current = next + 1; + } +} + } // namespace } // namespace grpc_python_generator diff --git a/contrib/libs/grpc/src/compiler/ruby_generator_helpers-inl.h b/contrib/libs/grpc/src/compiler/ruby_generator_helpers-inl.h index 9a10976619..6b659e17a4 100644 --- a/contrib/libs/grpc/src/compiler/ruby_generator_helpers-inl.h +++ b/contrib/libs/grpc/src/compiler/ruby_generator_helpers-inl.h @@ -47,7 +47,7 @@ inline TString MessagesRequireName( } // Get leading or trailing comments in a string. Comment lines start with "# ". -// Leading detached comments are put in front of leading comments. +// Leading detached comments are put in front of leading comments. template <typename DescriptorType> inline TString GetRubyComments(const DescriptorType* desc, bool leading) { return grpc_generator::GetPrefixedComments(desc, leading, "#"); diff --git a/contrib/libs/grpc/src/compiler/ruby_generator_string-inl.h b/contrib/libs/grpc/src/compiler/ruby_generator_string-inl.h index 956539f392..b5109d0d2f 100644 --- a/contrib/libs/grpc/src/compiler/ruby_generator_string-inl.h +++ b/contrib/libs/grpc/src/compiler/ruby_generator_string-inl.h @@ -100,30 +100,30 @@ inline TString Modularize(TString s) { return new_string; } -// RubyPackage gets the ruby package in either proto or ruby_package format +// RubyPackage gets the ruby package in either proto or ruby_package format inline TString RubyPackage(const grpc::protobuf::FileDescriptor* file) { TString package_name = file->package(); - if (file->options().has_ruby_package()) { - package_name = file->options().ruby_package(); - - // If :: is in the package convert the Ruby formatted name - // -> A::B::C - // to use the dot seperator notation - // -> A.B.C - package_name = ReplaceAll(package_name, "::", "."); - } - return package_name; -} - + if (file->options().has_ruby_package()) { + package_name = file->options().ruby_package(); + + // If :: is in the package convert the Ruby formatted name + // -> A::B::C + // to use the dot seperator notation + // -> A.B.C + package_name = ReplaceAll(package_name, "::", "."); + } + return package_name; +} + // RubyTypeOf updates a proto type to the required ruby equivalent. inline TString RubyTypeOf(const grpc::protobuf::Descriptor* descriptor) { TString proto_type = descriptor->full_name(); - if (descriptor->file()->options().has_ruby_package()) { + if (descriptor->file()->options().has_ruby_package()) { // remove the leading package if present ReplacePrefix(&proto_type, descriptor->file()->package(), ""); ReplacePrefix(&proto_type, ".", ""); // remove the leading . (no package) proto_type = RubyPackage(descriptor->file()) + "." + proto_type; - } + } TString res("." + proto_type); if (res.find('.') == TString::npos) { return res; |