diff options
author | heretic <[email protected]> | 2022-02-10 16:45:43 +0300 |
---|---|---|
committer | Daniil Cherednik <[email protected]> | 2022-02-10 16:45:43 +0300 |
commit | 397cbe258b9e064f49c4ca575279f02f39fef76e (patch) | |
tree | a0b0eb3cca6a14e4e8ea715393637672fa651284 /contrib/libs/grpc/src/compiler | |
parent | 43f5a35593ebc9f6bcea619bb170394ea7ae468e (diff) |
Restoring authorship annotation for <[email protected]>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/grpc/src/compiler')
31 files changed, 1172 insertions, 1172 deletions
diff --git a/contrib/libs/grpc/src/compiler/config.h b/contrib/libs/grpc/src/compiler/config.h index 95213b0f045..bee4077bcd0 100644 --- a/contrib/libs/grpc/src/compiler/config.h +++ b/contrib/libs/grpc/src/compiler/config.h @@ -21,18 +21,18 @@ #include "src/compiler/config_protobuf.h" -#include <util/generic/string.h> - -#ifdef GRPC_CUSTOM_STRING -#warning GRPC_CUSTOM_STRING is no longer supported. Please use TString. +#include <util/generic/string.h> + +#ifdef GRPC_CUSTOM_STRING +#warning GRPC_CUSTOM_STRING is no longer supported. Please use TString. #endif namespace grpc { -// Using grpc::string and grpc::to_string is discouraged in favor of -// TString and ToString. This is only for legacy code using -// them explictly. -typedef TString string; // deprecated +// Using grpc::string and grpc::to_string is discouraged in favor of +// TString and ToString. This is only for legacy code using +// them explictly. +typedef TString string; // deprecated namespace protobuf { diff --git a/contrib/libs/grpc/src/compiler/cpp_generator.cc b/contrib/libs/grpc/src/compiler/cpp_generator.cc index 57591774745..dad9c485892 100644 --- a/contrib/libs/grpc/src/compiler/cpp_generator.cc +++ b/contrib/libs/grpc/src/compiler/cpp_generator.cc @@ -22,16 +22,16 @@ #include <sstream> -#include <util/string/cast.h> - +#include <util/string/cast.h> + namespace grpc_cpp_generator { namespace { template <class T> -TString as_string(T x) { +TString as_string(T x) { std::ostringstream out; out << x; - return out.str(); + return out.str(); } inline bool ClientOnlyStreaming(const grpc_generator::Method* method) { @@ -42,8 +42,8 @@ inline bool ServerOnlyStreaming(const grpc_generator::Method* method) { return !method->ClientStreaming() && method->ServerStreaming(); } -TString FilenameIdentifier(const TString& filename) { - TString result; +TString FilenameIdentifier(const TString& filename) { + TString result; for (unsigned i = 0; i < filename.size(); i++) { char c = filename[i]; if (isalnum(c)) { @@ -65,9 +65,9 @@ T* array_end(T (&array)[N]) { } void PrintIncludes(grpc_generator::Printer* printer, - const std::vector<TString>& headers, - bool use_system_headers, const TString& search_path) { - std::map<TString, TString> vars; + const std::vector<TString>& headers, + bool use_system_headers, const TString& search_path) { + std::map<TString, TString> vars; vars["l"] = use_system_headers ? '<' : '"'; vars["r"] = use_system_headers ? '>' : '"'; @@ -85,13 +85,13 @@ void PrintIncludes(grpc_generator::Printer* printer, } } -TString GetHeaderPrologue(grpc_generator::File* file, - const Parameters& params) { - TString output; +TString GetHeaderPrologue(grpc_generator::File* file, + const Parameters& params) { + TString output; { // Scope the output stream so it closes and finalizes output to the string. auto printer = file->CreatePrinter(&output); - std::map<TString, TString> vars; + std::map<TString, TString> vars; vars["filename"] = file->filename(); vars["filename_identifier"] = FilenameIdentifier(file->filename()); @@ -104,7 +104,7 @@ TString GetHeaderPrologue(grpc_generator::File* file, printer->Print(vars, "// If you make any local change, they will be lost.\n"); printer->Print(vars, "// source: $filename$\n"); - TString leading_comments = file->GetLeadingComments("//"); + TString leading_comments = file->GetLeadingComments("//"); if (!leading_comments.empty()) { printer->Print(vars, "// Original file comments:\n"); printer->PrintRaw(leading_comments.c_str()); @@ -124,37 +124,37 @@ TString GetHeaderPrologue(grpc_generator::File* file, } // Convert from "a/b/c.proto" to "#include \"a/b/c$message_header_ext$\"\n" -TString ImportInludeFromProtoName(const TString& proto_name) { - return TString("#include \"") + +TString ImportInludeFromProtoName(const TString& proto_name) { + return TString("#include \"") + proto_name.substr(0, proto_name.size() - 6) + - TString("$message_header_ext$\"\n"); + TString("$message_header_ext$\"\n"); } -TString GetHeaderIncludes(grpc_generator::File* file, - const Parameters& params) { - TString output; +TString GetHeaderIncludes(grpc_generator::File* file, + const Parameters& params) { + TString output; { // Scope the output stream so it closes and finalizes output to the string. auto printer = file->CreatePrinter(&output); - std::map<TString, TString> vars; + std::map<TString, TString> vars; if (!params.additional_header_includes.empty()) { PrintIncludes(printer.get(), params.additional_header_includes, false, ""); } - // TODO(vjpai): Remove port_platform.h from header list when callback API is - // fully de-experimentalized since we will no longer be using - // macros from it. + // TODO(vjpai): Remove port_platform.h from header list when callback API is + // fully de-experimentalized since we will no longer be using + // macros from it. static const char* headers_strs[] = { "functional", - "grpc/impl/codegen/port_platform.h", + "grpc/impl/codegen/port_platform.h", "grpcpp/impl/codegen/async_generic_service.h", "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/message_allocator.h", + "grpcpp/impl/codegen/message_allocator.h", "grpcpp/impl/codegen/method_handler.h", "grpcpp/impl/codegen/proto_utils.h", "grpcpp/impl/codegen/rpc_method.h", @@ -166,7 +166,7 @@ TString GetHeaderIncludes(grpc_generator::File* file, "grpcpp/impl/codegen/stub_options.h", "grpcpp/impl/codegen/sync_stream.h", }; - std::vector<TString> headers(headers_strs, array_end(headers_strs)); + 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"); @@ -176,16 +176,16 @@ TString GetHeaderIncludes(grpc_generator::File* file, : params.message_header_extension; if (params.include_import_headers) { - const std::vector<TString> import_names = file->GetImportNames(); + const std::vector<TString> import_names = file->GetImportNames(); for (const auto& import_name : import_names) { - const TString include_name = ImportInludeFromProtoName(import_name); + const TString include_name = ImportInludeFromProtoName(import_name); printer->Print(vars, include_name.c_str()); } printer->PrintRaw("\n"); } if (!file->package().empty()) { - std::vector<TString> parts = file->package_parts(); + std::vector<TString> parts = file->package_parts(); for (auto part = parts.begin(); part != parts.end(); part++) { vars["part"] = *part; @@ -197,18 +197,18 @@ TString GetHeaderIncludes(grpc_generator::File* file, return output; } -void PrintHeaderClientMethodInterfaces(grpc_generator::Printer* printer, - const grpc_generator::Method* method, - std::map<TString, TString>* vars, - bool is_public) { +void PrintHeaderClientMethodInterfaces(grpc_generator::Printer* printer, + const grpc_generator::Method* method, + std::map<TString, TString>* vars, + bool is_public) { (*vars)["Method"] = method->name(); (*vars)["Request"] = method->input_type_name(); (*vars)["Response"] = method->output_type_name(); struct { - TString prefix; - TString method_params; // extra arguments to method - TString raw_args; // extra arguments to raw version of method + TString prefix; + TString method_params; // extra arguments to method + TString raw_args; // extra arguments to raw version of method } async_prefixes[] = {{"Async", ", void* tag", ", tag"}, {"PrepareAsync", "", ""}}; @@ -282,7 +282,7 @@ void PrintHeaderClientMethodInterfaces(grpc_generator::Printer* printer, "($Method$Raw(context, request));\n"); printer->Outdent(); printer->Print("}\n"); - for (auto& async_prefix : async_prefixes) { + for (auto& async_prefix : async_prefixes) { (*vars)["AsyncPrefix"] = async_prefix.prefix; (*vars)["AsyncMethodParams"] = async_prefix.method_params; (*vars)["AsyncRawArgs"] = async_prefix.raw_args; @@ -398,15 +398,15 @@ void PrintHeaderClientMethodInterfaces(grpc_generator::Printer* printer, void PrintHeaderClientMethod(grpc_generator::Printer* printer, const grpc_generator::Method* method, - std::map<TString, TString>* vars, + std::map<TString, TString>* vars, bool is_public) { (*vars)["Method"] = method->name(); (*vars)["Request"] = method->input_type_name(); (*vars)["Response"] = method->output_type_name(); struct { - TString prefix; - TString method_params; // extra arguments to method - TString raw_args; // extra arguments to raw version of method + TString prefix; + TString method_params; // extra arguments to method + TString raw_args; // extra arguments to raw version of method } async_prefixes[] = {{"Async", ", void* tag", ", tag"}, {"PrepareAsync", "", ""}}; @@ -585,7 +585,7 @@ void PrintHeaderClientMethod(grpc_generator::Printer* printer, void PrintHeaderClientMethodCallbackInterfacesStart( grpc_generator::Printer* printer, - std::map<TString, TString>* /*vars*/) { + std::map<TString, TString>* /*vars*/) { // This declares the interface for the callback-based API. The components // are pure; even though this is new (post-1.0) API, it can be pure because // it is an entirely new interface that happens to be scoped within @@ -600,7 +600,7 @@ void PrintHeaderClientMethodCallbackInterfacesStart( void PrintHeaderClientMethodCallbackInterfaces( grpc_generator::Printer* printer, const grpc_generator::Method* method, - std::map<TString, TString>* vars) { + std::map<TString, TString>* vars) { (*vars)["Method"] = method->name(); (*vars)["Request"] = method->input_type_name(); (*vars)["Response"] = method->output_type_name(); @@ -610,67 +610,67 @@ void PrintHeaderClientMethodCallbackInterfaces( "virtual void $Method$(::grpc::ClientContext* context, " "const $Request$* request, $Response$* response, " "std::function<void(::grpc::Status)>) = 0;\n"); - // TODO(vjpai): Remove experimental versions and macros when callback API is - // fully de-experimentalized. + // TODO(vjpai): Remove experimental versions and macros when callback API is + // fully de-experimentalized. printer->Print(*vars, - "#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" - "virtual void $Method$(::grpc::ClientContext* context, " - "const $Request$* request, $Response$* response, " - "::grpc::ClientUnaryReactor* reactor) = 0;\n" - "#else\n" + "#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" "virtual void $Method$(::grpc::ClientContext* context, " "const $Request$* request, $Response$* response, " - "::grpc::experimental::ClientUnaryReactor* reactor) = 0;\n" - "#endif\n"); + "::grpc::ClientUnaryReactor* reactor) = 0;\n" + "#else\n" + "virtual void $Method$(::grpc::ClientContext* context, " + "const $Request$* request, $Response$* response, " + "::grpc::experimental::ClientUnaryReactor* reactor) = 0;\n" + "#endif\n"); } else if (ClientOnlyStreaming(method)) { printer->Print(*vars, - "#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" - "virtual void $Method$(::grpc::ClientContext* context, " - "$Response$* response, " - "::grpc::ClientWriteReactor< $Request$>* " - "reactor) = 0;\n" - "#else\n" + "#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" "virtual void $Method$(::grpc::ClientContext* context, " "$Response$* response, " + "::grpc::ClientWriteReactor< $Request$>* " + "reactor) = 0;\n" + "#else\n" + "virtual void $Method$(::grpc::ClientContext* context, " + "$Response$* response, " "::grpc::experimental::ClientWriteReactor< $Request$>* " - "reactor) = 0;\n" - "#endif\n"); + "reactor) = 0;\n" + "#endif\n"); } else if (ServerOnlyStreaming(method)) { printer->Print(*vars, - "#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" - "virtual void $Method$(::grpc::ClientContext* context, " - "$Request$* request, " - "::grpc::ClientReadReactor< $Response$>* " - "reactor) = 0;\n" - "#else\n" + "#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" "virtual void $Method$(::grpc::ClientContext* context, " "$Request$* request, " + "::grpc::ClientReadReactor< $Response$>* " + "reactor) = 0;\n" + "#else\n" + "virtual void $Method$(::grpc::ClientContext* context, " + "$Request$* request, " "::grpc::experimental::ClientReadReactor< $Response$>* " - "reactor) = 0;\n" - "#endif\n"); + "reactor) = 0;\n" + "#endif\n"); } else if (method->BidiStreaming()) { printer->Print(*vars, - "#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" - "virtual void $Method$(::grpc::ClientContext* context, " - "::grpc::ClientBidiReactor< " - "$Request$,$Response$>* reactor) = 0;\n" - "#else\n" + "#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" "virtual void $Method$(::grpc::ClientContext* context, " + "::grpc::ClientBidiReactor< " + "$Request$,$Response$>* reactor) = 0;\n" + "#else\n" + "virtual void $Method$(::grpc::ClientContext* context, " "::grpc::experimental::ClientBidiReactor< " - "$Request$,$Response$>* reactor) = 0;\n" - "#endif\n"); + "$Request$,$Response$>* reactor) = 0;\n" + "#endif\n"); } } void PrintHeaderClientMethodCallbackInterfacesEnd( grpc_generator::Printer* printer, - std::map<TString, TString>* /*vars*/) { + std::map<TString, TString>* /*vars*/) { printer->Outdent(); printer->Print("};\n"); - printer->Print( - "#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" - "typedef class experimental_async_interface async_interface;\n" - "#endif\n"); + printer->Print( + "#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" + "typedef class experimental_async_interface async_interface;\n" + "#endif\n"); // Declare a function to give the async stub contents. It can't be pure // since this is a new API in StubInterface, but it is meaningless by default @@ -678,17 +678,17 @@ void PrintHeaderClientMethodCallbackInterfacesEnd( // the callback functions therein), so make the default return value nullptr. // Intentionally include the word "class" to avoid possible shadowing. printer->Print( - "#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" - "async_interface* async() { return experimental_async(); }\n" - "#endif\n"); - printer->Print( + "#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" + "async_interface* async() { return experimental_async(); }\n" + "#endif\n"); + printer->Print( "virtual class experimental_async_interface* experimental_async() { " "return nullptr; }\n"); } void PrintHeaderClientMethodCallbackStart( grpc_generator::Printer* printer, - std::map<TString, TString>* /*vars*/) { + std::map<TString, TString>* /*vars*/) { // This declares the stub entry for the callback-based API. printer->Print("class experimental_async final :\n"); printer->Print(" public StubInterface::experimental_async_interface {\n"); @@ -696,9 +696,9 @@ void PrintHeaderClientMethodCallbackStart( printer->Indent(); } -void PrintHeaderClientMethodCallback(grpc_generator::Printer* printer, - const grpc_generator::Method* method, - std::map<TString, TString>* vars) { +void PrintHeaderClientMethodCallback(grpc_generator::Printer* printer, + const grpc_generator::Method* method, + std::map<TString, TString>* vars) { (*vars)["Method"] = method->name(); (*vars)["Request"] = method->input_type_name(); (*vars)["Response"] = method->output_type_name(); @@ -710,59 +710,59 @@ void PrintHeaderClientMethodCallback(grpc_generator::Printer* printer, "std::function<void(::grpc::Status)>) override;\n"); printer->Print( *vars, - "#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" - "void $Method$(::grpc::ClientContext* context, " - "const $Request$* request, $Response$* response, " - "::grpc::ClientUnaryReactor* reactor) override;\n" - "#else\n" + "#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" "void $Method$(::grpc::ClientContext* context, " "const $Request$* request, $Response$* response, " - "::grpc::experimental::ClientUnaryReactor* reactor) override;\n" - "#endif\n"); + "::grpc::ClientUnaryReactor* reactor) override;\n" + "#else\n" + "void $Method$(::grpc::ClientContext* context, " + "const $Request$* request, $Response$* response, " + "::grpc::experimental::ClientUnaryReactor* reactor) override;\n" + "#endif\n"); } else if (ClientOnlyStreaming(method)) { printer->Print(*vars, - "#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" - "void $Method$(::grpc::ClientContext* context, " - "$Response$* response, " - "::grpc::ClientWriteReactor< $Request$>* " - "reactor) override;\n" - "#else\n" + "#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" "void $Method$(::grpc::ClientContext* context, " "$Response$* response, " + "::grpc::ClientWriteReactor< $Request$>* " + "reactor) override;\n" + "#else\n" + "void $Method$(::grpc::ClientContext* context, " + "$Response$* response, " "::grpc::experimental::ClientWriteReactor< $Request$>* " - "reactor) override;\n" - "#endif\n"); + "reactor) override;\n" + "#endif\n"); } else if (ServerOnlyStreaming(method)) { printer->Print(*vars, - "#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" - "void $Method$(::grpc::ClientContext* context, " - "$Request$* request, " - "::grpc::ClientReadReactor< $Response$>* " - "reactor) override;\n" - "#else\n" + "#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" "void $Method$(::grpc::ClientContext* context, " "$Request$* request, " + "::grpc::ClientReadReactor< $Response$>* " + "reactor) override;\n" + "#else\n" + "void $Method$(::grpc::ClientContext* context, " + "$Request$* request, " "::grpc::experimental::ClientReadReactor< $Response$>* " - "reactor) override;\n" - "#endif\n"); + "reactor) override;\n" + "#endif\n"); } else if (method->BidiStreaming()) { printer->Print(*vars, - "#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" - "void $Method$(::grpc::ClientContext* context, " - "::grpc::ClientBidiReactor< " - "$Request$,$Response$>* reactor) override;\n" - "#else\n" + "#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" "void $Method$(::grpc::ClientContext* context, " + "::grpc::ClientBidiReactor< " + "$Request$,$Response$>* reactor) override;\n" + "#else\n" + "void $Method$(::grpc::ClientContext* context, " "::grpc::experimental::ClientBidiReactor< " - "$Request$,$Response$>* reactor) override;\n" - "#endif\n"); + "$Request$,$Response$>* reactor) override;\n" + "#endif\n"); } } void PrintHeaderClientMethodCallbackEnd( grpc_generator::Printer* printer, - std::map<TString, TString>* /*vars*/) { + std::map<TString, TString>* /*vars*/) { printer->Outdent(); printer->Print(" private:\n"); printer->Indent(); @@ -782,7 +782,7 @@ void PrintHeaderClientMethodCallbackEnd( void PrintHeaderClientMethodData(grpc_generator::Printer* printer, const grpc_generator::Method* method, - std::map<TString, TString>* vars) { + std::map<TString, TString>* vars) { (*vars)["Method"] = method->name(); printer->Print(*vars, "const ::grpc::internal::RpcMethod rpcmethod_$Method$_;\n"); @@ -790,7 +790,7 @@ void PrintHeaderClientMethodData(grpc_generator::Printer* printer, void PrintHeaderServerMethodSync(grpc_generator::Printer* printer, const grpc_generator::Method* method, - std::map<TString, TString>* vars) { + std::map<TString, TString>* vars) { (*vars)["Method"] = method->name(); (*vars)["Request"] = method->input_type_name(); (*vars)["Response"] = method->output_type_name(); @@ -827,7 +827,7 @@ void PrintHeaderServerMethodSync(grpc_generator::Printer* printer, // to generate async and raw async APIs. void PrintHeaderServerAsyncMethodsHelper( grpc_generator::Printer* printer, const grpc_generator::Method* method, - std::map<TString, TString>* vars) { + std::map<TString, TString>* vars) { if (method->NoStreaming()) { printer->Print( *vars, @@ -922,7 +922,7 @@ void PrintHeaderServerAsyncMethodsHelper( void PrintHeaderServerMethodAsync(grpc_generator::Printer* printer, const grpc_generator::Method* method, - std::map<TString, TString>* vars) { + std::map<TString, TString>* vars) { (*vars)["Method"] = method->name(); // These will be disabled (*vars)["Request"] = method->input_type_name(); @@ -957,7 +957,7 @@ void PrintHeaderServerMethodAsync(grpc_generator::Printer* printer, // to generate callback and raw callback APIs. void PrintHeaderServerCallbackMethodsHelper( grpc_generator::Printer* printer, const grpc_generator::Method* method, - std::map<TString, TString>* vars) { + std::map<TString, TString>* vars) { if (method->NoStreaming()) { printer->Print( *vars, @@ -969,19 +969,19 @@ void PrintHeaderServerCallbackMethodsHelper( " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" "}\n"); 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" + "#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* " - "$Method$(\n" - " ::grpc::experimental::CallbackServerContext* " - "/*context*/, const $RealRequest$* /*request*/, " - "$RealResponse$* /*response*/)\n" - "#endif\n" - " { return nullptr; }\n"); + "$Method$(\n" + " ::grpc::experimental::CallbackServerContext* " + "/*context*/, const $RealRequest$* /*request*/, " + "$RealResponse$* /*response*/)\n" + "#endif\n" + " { return nullptr; }\n"); } else if (ClientOnlyStreaming(method)) { printer->Print( *vars, @@ -994,18 +994,18 @@ void PrintHeaderServerCallbackMethodsHelper( " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" "}\n"); printer->Print(*vars, - "#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" - "virtual ::grpc::ServerReadReactor< " - "$RealRequest$>* $Method$(\n" - " ::grpc::CallbackServerContext* " - "/*context*/, $RealResponse$* /*response*/)\n" - "#else\n" + "#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" + "virtual ::grpc::ServerReadReactor< " + "$RealRequest$>* $Method$(\n" + " ::grpc::CallbackServerContext* " + "/*context*/, $RealResponse$* /*response*/)\n" + "#else\n" "virtual ::grpc::experimental::ServerReadReactor< " - "$RealRequest$>* $Method$(\n" - " ::grpc::experimental::CallbackServerContext* " - "/*context*/, $RealResponse$* /*response*/)\n" - "#endif\n" - " { return nullptr; }\n"); + "$RealRequest$>* $Method$(\n" + " ::grpc::experimental::CallbackServerContext* " + "/*context*/, $RealResponse$* /*response*/)\n" + "#endif\n" + " { return nullptr; }\n"); } else if (ServerOnlyStreaming(method)) { printer->Print( *vars, @@ -1019,17 +1019,17 @@ void PrintHeaderServerCallbackMethodsHelper( "}\n"); printer->Print( *vars, - "#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" - "virtual ::grpc::ServerWriteReactor< $RealResponse$>* $Method$(\n" - " ::grpc::CallbackServerContext* " - "/*context*/, const $RealRequest$* /*request*/)\n" - "#else\n" - "virtual ::grpc::experimental::ServerWriteReactor< $RealResponse$>* " - "$Method$(\n" - " ::grpc::experimental::CallbackServerContext* " - "/*context*/, const $RealRequest$* /*request*/)\n" - "#endif\n" - " { return nullptr; }\n"); + "#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" + "virtual ::grpc::ServerWriteReactor< $RealResponse$>* $Method$(\n" + " ::grpc::CallbackServerContext* " + "/*context*/, const $RealRequest$* /*request*/)\n" + "#else\n" + "virtual ::grpc::experimental::ServerWriteReactor< $RealResponse$>* " + "$Method$(\n" + " ::grpc::experimental::CallbackServerContext* " + "/*context*/, const $RealRequest$* /*request*/)\n" + "#endif\n" + " { return nullptr; }\n"); } else if (method->BidiStreaming()) { printer->Print( *vars, @@ -1043,23 +1043,23 @@ void PrintHeaderServerCallbackMethodsHelper( "}\n"); printer->Print( *vars, - "#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" - "virtual ::grpc::ServerBidiReactor< $RealRequest$, $RealResponse$>* " - "$Method$(\n" - " ::grpc::CallbackServerContext* /*context*/)\n" - "#else\n" + "#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$>* " - "$Method$(\n" - " ::grpc::experimental::CallbackServerContext* /*context*/)\n" - "#endif\n" - " { return nullptr; }\n"); + "$Method$(\n" + " ::grpc::experimental::CallbackServerContext* /*context*/)\n" + "#endif\n" + " { return nullptr; }\n"); } } -void PrintHeaderServerMethodCallback(grpc_generator::Printer* printer, - const grpc_generator::Method* method, - std::map<TString, TString>* vars) { +void PrintHeaderServerMethodCallback(grpc_generator::Printer* printer, + const grpc_generator::Method* method, + std::map<TString, TString>* vars) { (*vars)["Method"] = method->name(); // These will be disabled (*vars)["Request"] = method->input_type_name(); @@ -1081,21 +1081,21 @@ void PrintHeaderServerMethodCallback(grpc_generator::Printer* printer, if (method->NoStreaming()) { printer->Print( *vars, - "#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" - " ::grpc::Service::\n" - "#else\n" - " ::grpc::Service::experimental().\n" - "#endif\n" - " MarkMethodCallback($Idx$,\n" - " new ::grpc::internal::CallbackUnaryHandler< " + "#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" + " ::grpc::Service::\n" + "#else\n" + " ::grpc::Service::experimental().\n" + "#endif\n" + " MarkMethodCallback($Idx$,\n" + " new ::grpc::internal::CallbackUnaryHandler< " "$RealRequest$, $RealResponse$>(\n" - " [this](\n" - "#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" - " ::grpc::CallbackServerContext*\n" - "#else\n" - " ::grpc::experimental::CallbackServerContext*\n" - "#endif\n" - " context, " + " [this](\n" + "#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" + " ::grpc::CallbackServerContext*\n" + "#else\n" + " ::grpc::experimental::CallbackServerContext*\n" + "#endif\n" + " context, " "const $RealRequest$* " "request, " "$RealResponse$* response) { " @@ -1104,77 +1104,77 @@ void PrintHeaderServerMethodCallback(grpc_generator::Printer* printer, "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" - "#else\n" - " ::grpc::internal::MethodHandler* const handler = " - "::grpc::Service::experimental().GetHandler($Idx$);\n" - "#endif\n" - " static_cast<::grpc::internal::CallbackUnaryHandler< " - "$RealRequest$, $RealResponse$>*>(handler)\n" + "#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" + " ::grpc::internal::MethodHandler* const handler = " + "::grpc::Service::GetHandler($Idx$);\n" + "#else\n" + " ::grpc::internal::MethodHandler* const handler = " + "::grpc::Service::experimental().GetHandler($Idx$);\n" + "#endif\n" + " static_cast<::grpc::internal::CallbackUnaryHandler< " + "$RealRequest$, $RealResponse$>*>(handler)\n" " ->SetMessageAllocator(allocator);\n"); } else if (ClientOnlyStreaming(method)) { printer->Print( *vars, - "#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" - " ::grpc::Service::\n" - "#else\n" - " ::grpc::Service::experimental().\n" - "#endif\n" - " MarkMethodCallback($Idx$,\n" - " new ::grpc::internal::CallbackClientStreamingHandler< " + "#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" + " ::grpc::Service::\n" + "#else\n" + " ::grpc::Service::experimental().\n" + "#endif\n" + " MarkMethodCallback($Idx$,\n" + " new ::grpc::internal::CallbackClientStreamingHandler< " "$RealRequest$, $RealResponse$>(\n" - " [this](\n" - "#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" - " ::grpc::CallbackServerContext*\n" - "#else\n" - " ::grpc::experimental::CallbackServerContext*\n" - "#endif\n" - " context, " + " [this](\n" + "#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" + " ::grpc::CallbackServerContext*\n" + "#else\n" + " ::grpc::experimental::CallbackServerContext*\n" + "#endif\n" + " context, " "$RealResponse$* " "response) { " "return this->$Method$(context, response); }));\n"); } else if (ServerOnlyStreaming(method)) { printer->Print( *vars, - "#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" - " ::grpc::Service::\n" - "#else\n" - " ::grpc::Service::experimental().\n" - "#endif\n" - " MarkMethodCallback($Idx$,\n" - " new ::grpc::internal::CallbackServerStreamingHandler< " + "#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" + " ::grpc::Service::\n" + "#else\n" + " ::grpc::Service::experimental().\n" + "#endif\n" + " MarkMethodCallback($Idx$,\n" + " new ::grpc::internal::CallbackServerStreamingHandler< " "$RealRequest$, $RealResponse$>(\n" - " [this](\n" - "#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" - " ::grpc::CallbackServerContext*\n" - "#else\n" - " ::grpc::experimental::CallbackServerContext*\n" - "#endif\n" - " context, " + " [this](\n" + "#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" + " ::grpc::CallbackServerContext*\n" + "#else\n" + " ::grpc::experimental::CallbackServerContext*\n" + "#endif\n" + " context, " "const $RealRequest$* " "request) { " "return this->$Method$(context, request); }));\n"); } else if (method->BidiStreaming()) { printer->Print( *vars, - "#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" - " ::grpc::Service::\n" - "#else\n" - " ::grpc::Service::experimental().\n" - "#endif\n" - " MarkMethodCallback($Idx$,\n" - " new ::grpc::internal::CallbackBidiHandler< " + "#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" + " ::grpc::Service::\n" + "#else\n" + " ::grpc::Service::experimental().\n" + "#endif\n" + " MarkMethodCallback($Idx$,\n" + " new ::grpc::internal::CallbackBidiHandler< " "$RealRequest$, $RealResponse$>(\n" - " [this](\n" - "#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" - " ::grpc::CallbackServerContext*\n" - "#else\n" - " ::grpc::experimental::CallbackServerContext*\n" - "#endif\n" - " context) " - "{ return this->$Method$(context); }));\n"); + " [this](\n" + "#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" + " ::grpc::CallbackServerContext*\n" + "#else\n" + " ::grpc::experimental::CallbackServerContext*\n" + "#endif\n" + " context) " + "{ return this->$Method$(context); }));\n"); } printer->Print(*vars, "}\n"); printer->Print(*vars, @@ -1188,7 +1188,7 @@ void PrintHeaderServerMethodCallback(grpc_generator::Printer* printer, void PrintHeaderServerMethodRawCallback( grpc_generator::Printer* printer, const grpc_generator::Method* method, - std::map<TString, TString>* vars) { + std::map<TString, TString>* vars) { (*vars)["Method"] = method->name(); // These will be disabled (*vars)["Request"] = method->input_type_name(); @@ -1210,21 +1210,21 @@ void PrintHeaderServerMethodRawCallback( if (method->NoStreaming()) { printer->Print( *vars, - "#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" - " ::grpc::Service::\n" - "#else\n" - " ::grpc::Service::experimental().\n" - "#endif\n" - " MarkMethodRawCallback($Idx$,\n" - " new ::grpc::internal::CallbackUnaryHandler< " + "#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" + " ::grpc::Service::\n" + "#else\n" + " ::grpc::Service::experimental().\n" + "#endif\n" + " MarkMethodRawCallback($Idx$,\n" + " new ::grpc::internal::CallbackUnaryHandler< " "$RealRequest$, $RealResponse$>(\n" - " [this](\n" - "#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" - " ::grpc::CallbackServerContext*\n" - "#else\n" - " ::grpc::experimental::CallbackServerContext*\n" - "#endif\n" - " context, " + " [this](\n" + "#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" + " ::grpc::CallbackServerContext*\n" + "#else\n" + " ::grpc::experimental::CallbackServerContext*\n" + "#endif\n" + " context, " "const $RealRequest$* " "request, " "$RealResponse$* response) { return " @@ -1232,63 +1232,63 @@ void PrintHeaderServerMethodRawCallback( } else if (ClientOnlyStreaming(method)) { printer->Print( *vars, - "#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" - " ::grpc::Service::\n" - "#else\n" - " ::grpc::Service::experimental().\n" - "#endif\n" - " MarkMethodRawCallback($Idx$,\n" - " new ::grpc::internal::CallbackClientStreamingHandler< " + "#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" + " ::grpc::Service::\n" + "#else\n" + " ::grpc::Service::experimental().\n" + "#endif\n" + " MarkMethodRawCallback($Idx$,\n" + " new ::grpc::internal::CallbackClientStreamingHandler< " "$RealRequest$, $RealResponse$>(\n" - " [this](\n" - "#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" - " ::grpc::CallbackServerContext*\n" - "#else\n" - " ::grpc::experimental::CallbackServerContext*\n" - "#endif\n" - " context, " + " [this](\n" + "#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" + " ::grpc::CallbackServerContext*\n" + "#else\n" + " ::grpc::experimental::CallbackServerContext*\n" + "#endif\n" + " context, " "$RealResponse$* response) " "{ return this->$Method$(context, response); }));\n"); } else if (ServerOnlyStreaming(method)) { printer->Print( *vars, - "#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" - " ::grpc::Service::\n" - "#else\n" - " ::grpc::Service::experimental().\n" - "#endif\n" - " MarkMethodRawCallback($Idx$,\n" - " new ::grpc::internal::CallbackServerStreamingHandler< " + "#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" + " ::grpc::Service::\n" + "#else\n" + " ::grpc::Service::experimental().\n" + "#endif\n" + " MarkMethodRawCallback($Idx$,\n" + " new ::grpc::internal::CallbackServerStreamingHandler< " "$RealRequest$, $RealResponse$>(\n" - " [this](\n" - "#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" - " ::grpc::CallbackServerContext*\n" - "#else\n" - " ::grpc::experimental::CallbackServerContext*\n" - "#endif\n" - " context, " + " [this](\n" + "#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" + " ::grpc::CallbackServerContext*\n" + "#else\n" + " ::grpc::experimental::CallbackServerContext*\n" + "#endif\n" + " context, " "const" "$RealRequest$* request) { return " "this->$Method$(context, request); }));\n"); } else if (method->BidiStreaming()) { printer->Print( *vars, - "#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" - " ::grpc::Service::\n" - "#else\n" - " ::grpc::Service::experimental().\n" - "#endif\n" - " MarkMethodRawCallback($Idx$,\n" - " new ::grpc::internal::CallbackBidiHandler< " + "#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" + " ::grpc::Service::\n" + "#else\n" + " ::grpc::Service::experimental().\n" + "#endif\n" + " MarkMethodRawCallback($Idx$,\n" + " new ::grpc::internal::CallbackBidiHandler< " "$RealRequest$, $RealResponse$>(\n" - " [this](\n" - "#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" - " ::grpc::CallbackServerContext*\n" - "#else\n" - " ::grpc::experimental::CallbackServerContext*\n" - "#endif\n" - " context) " - "{ return this->$Method$(context); }));\n"); + " [this](\n" + "#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" + " ::grpc::CallbackServerContext*\n" + "#else\n" + " ::grpc::experimental::CallbackServerContext*\n" + "#endif\n" + " context) " + "{ return this->$Method$(context); }));\n"); } printer->Print(*vars, "}\n"); printer->Print(*vars, @@ -1302,7 +1302,7 @@ void PrintHeaderServerMethodRawCallback( void PrintHeaderServerMethodStreamedUnary( grpc_generator::Printer* printer, const grpc_generator::Method* method, - std::map<TString, TString>* vars) { + std::map<TString, TString>* vars) { (*vars)["Method"] = method->name(); (*vars)["Request"] = method->input_type_name(); (*vars)["Response"] = method->output_type_name(); @@ -1320,14 +1320,14 @@ void PrintHeaderServerMethodStreamedUnary( printer->Print(*vars, "WithStreamedUnaryMethod_$Method$() {\n" " ::grpc::Service::MarkMethodStreamed($Idx$,\n" - " new ::grpc::internal::StreamedUnaryHandler<\n" - " $Request$, $Response$>(\n" - " [this](::grpc::ServerContext* context,\n" - " ::grpc::ServerUnaryStreamer<\n" - " $Request$, $Response$>* streamer) {\n" - " return this->Streamed$Method$(context,\n" - " streamer);\n" - " }));\n" + " new ::grpc::internal::StreamedUnaryHandler<\n" + " $Request$, $Response$>(\n" + " [this](::grpc::ServerContext* context,\n" + " ::grpc::ServerUnaryStreamer<\n" + " $Request$, $Response$>* streamer) {\n" + " return this->Streamed$Method$(context,\n" + " streamer);\n" + " }));\n" "}\n"); printer->Print(*vars, "~WithStreamedUnaryMethod_$Method$() override {\n" @@ -1356,7 +1356,7 @@ void PrintHeaderServerMethodStreamedUnary( void PrintHeaderServerMethodSplitStreaming( grpc_generator::Printer* printer, const grpc_generator::Method* method, - std::map<TString, TString>* vars) { + std::map<TString, TString>* vars) { (*vars)["Method"] = method->name(); (*vars)["Request"] = method->input_type_name(); (*vars)["Response"] = method->output_type_name(); @@ -1372,18 +1372,18 @@ void PrintHeaderServerMethodSplitStreaming( printer->Print(" public:\n"); printer->Indent(); printer->Print(*vars, - "WithSplitStreamingMethod_$Method$() {\n" - " ::grpc::Service::MarkMethodStreamed($Idx$,\n" - " new ::grpc::internal::SplitServerStreamingHandler<\n" - " $Request$, $Response$>(\n" - " [this](::grpc::ServerContext* context,\n" - " ::grpc::ServerSplitStreamer<\n" - " $Request$, $Response$>* streamer) {\n" - " return this->Streamed$Method$(context,\n" - " streamer);\n" - " }));\n" - "}\n"); - printer->Print(*vars, + "WithSplitStreamingMethod_$Method$() {\n" + " ::grpc::Service::MarkMethodStreamed($Idx$,\n" + " new ::grpc::internal::SplitServerStreamingHandler<\n" + " $Request$, $Response$>(\n" + " [this](::grpc::ServerContext* context,\n" + " ::grpc::ServerSplitStreamer<\n" + " $Request$, $Response$>* streamer) {\n" + " return this->Streamed$Method$(context,\n" + " streamer);\n" + " }));\n" + "}\n"); + printer->Print(*vars, "~WithSplitStreamingMethod_$Method$() override {\n" " BaseClassMustBeDerivedFromService(this);\n" "}\n"); @@ -1409,9 +1409,9 @@ void PrintHeaderServerMethodSplitStreaming( } } -void PrintHeaderServerMethodGeneric(grpc_generator::Printer* printer, - const grpc_generator::Method* method, - std::map<TString, TString>* vars) { +void PrintHeaderServerMethodGeneric(grpc_generator::Printer* printer, + const grpc_generator::Method* method, + std::map<TString, TString>* vars) { (*vars)["Method"] = method->name(); (*vars)["Request"] = method->input_type_name(); (*vars)["Response"] = method->output_type_name(); @@ -1482,7 +1482,7 @@ void PrintHeaderServerMethodGeneric(grpc_generator::Printer* printer, void PrintHeaderServerMethodRaw(grpc_generator::Printer* printer, const grpc_generator::Method* method, - std::map<TString, TString>* vars) { + std::map<TString, TString>* vars) { (*vars)["Method"] = method->name(); // These will be disabled (*vars)["Request"] = method->input_type_name(); @@ -1513,7 +1513,7 @@ void PrintHeaderServerMethodRaw(grpc_generator::Printer* printer, void PrintHeaderService(grpc_generator::Printer* printer, const grpc_generator::Service* service, - std::map<TString, TString>* vars) { + std::map<TString, TString>* vars) { (*vars)["Service"] = service->name(); printer->Print(service->GetLeadingComments("//").c_str()); @@ -1629,20 +1629,7 @@ void PrintHeaderService(grpc_generator::Printer* printer, PrintHeaderServerMethodCallback(printer, service->method(i).get(), vars); } - printer->Print("#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n"); - printer->Print("typedef "); - - for (int i = 0; i < service->method_count(); ++i) { - (*vars)["method_name"] = service->method(i)->name(); - printer->Print(*vars, "ExperimentalWithCallbackMethod_$method_name$<"); - } - printer->Print("Service"); - for (int i = 0; i < service->method_count(); ++i) { - printer->Print(" >"); - } - printer->Print(" CallbackService;\n"); - printer->Print("#endif\n\n"); - + printer->Print("#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n"); printer->Print("typedef "); for (int i = 0; i < service->method_count(); ++i) { @@ -1653,6 +1640,19 @@ void PrintHeaderService(grpc_generator::Printer* printer, for (int i = 0; i < service->method_count(); ++i) { printer->Print(" >"); } + printer->Print(" CallbackService;\n"); + printer->Print("#endif\n\n"); + + printer->Print("typedef "); + + for (int i = 0; i < service->method_count(); ++i) { + (*vars)["method_name"] = service->method(i)->name(); + printer->Print(*vars, "ExperimentalWithCallbackMethod_$method_name$<"); + } + printer->Print("Service"); + for (int i = 0; i < service->method_count(); ++i) { + printer->Print(" >"); + } printer->Print(" ExperimentalCallbackService;\n"); // Server side - Generic @@ -1746,13 +1746,13 @@ void PrintHeaderService(grpc_generator::Printer* printer, printer->Print(service->GetTrailingComments("//").c_str()); } -TString GetHeaderServices(grpc_generator::File* file, - const Parameters& params) { - TString output; +TString GetHeaderServices(grpc_generator::File* file, + const Parameters& params) { + TString output; { // Scope the output stream so it closes and finalizes output to the string. auto printer = file->CreatePrinter(&output); - std::map<TString, TString> vars; + std::map<TString, TString> vars; // Package string is empty or ends with a dot. It is used to fully qualify // method names. vars["Package"] = file->package(); @@ -1777,19 +1777,19 @@ TString GetHeaderServices(grpc_generator::File* file, return output; } -TString GetHeaderEpilogue(grpc_generator::File* file, - const Parameters& /*params*/) { - TString output; +TString GetHeaderEpilogue(grpc_generator::File* file, + const Parameters& /*params*/) { + TString output; { // Scope the output stream so it closes and finalizes output to the string. auto printer = file->CreatePrinter(&output); - std::map<TString, TString> vars; + std::map<TString, TString> vars; vars["filename"] = file->filename(); vars["filename_identifier"] = FilenameIdentifier(file->filename()); if (!file->package().empty()) { - std::vector<TString> parts = file->package_parts(); + std::vector<TString> parts = file->package_parts(); for (auto part = parts.rbegin(); part != parts.rend(); part++) { vars["part"] = *part; @@ -1806,13 +1806,13 @@ TString GetHeaderEpilogue(grpc_generator::File* file, return output; } -TString GetSourcePrologue(grpc_generator::File* file, - const Parameters& params) { - TString output; +TString GetSourcePrologue(grpc_generator::File* file, + const Parameters& params) { + TString output; { // Scope the output stream so it closes and finalizes output to the string. auto printer = file->CreatePrinter(&output); - std::map<TString, TString> vars; + std::map<TString, TString> vars; vars["filename"] = file->filename(); vars["filename_base"] = file->filename_without_ext(); @@ -1833,13 +1833,13 @@ TString GetSourcePrologue(grpc_generator::File* file, return output; } -TString GetSourceIncludes(grpc_generator::File* file, - const Parameters& params) { - TString output; +TString GetSourceIncludes(grpc_generator::File* file, + const Parameters& params) { + TString output; { // Scope the output stream so it closes and finalizes output to the string. auto printer = file->CreatePrinter(&output); - std::map<TString, TString> vars; + std::map<TString, TString> vars; static const char* headers_strs[] = { "functional", "grpcpp/impl/codegen/async_stream.h", @@ -1847,7 +1847,7 @@ TString GetSourceIncludes(grpc_generator::File* file, "grpcpp/impl/codegen/channel_interface.h", "grpcpp/impl/codegen/client_unary_call.h", "grpcpp/impl/codegen/client_callback.h", - "grpcpp/impl/codegen/message_allocator.h", + "grpcpp/impl/codegen/message_allocator.h", "grpcpp/impl/codegen/method_handler.h", "grpcpp/impl/codegen/rpc_service_method.h", "grpcpp/impl/codegen/server_callback.h", @@ -1855,12 +1855,12 @@ TString GetSourceIncludes(grpc_generator::File* file, "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)); + std::vector<TString> headers(headers_strs, array_end(headers_strs)); PrintIncludes(printer.get(), headers, params.use_system_headers, params.grpc_search_path); if (!file->package().empty()) { - std::vector<TString> parts = file->package_parts(); + std::vector<TString> parts = file->package_parts(); for (auto part = parts.begin(); part != parts.end(); part++) { vars["part"] = *part; @@ -1875,15 +1875,15 @@ TString GetSourceIncludes(grpc_generator::File* file, void PrintSourceClientMethod(grpc_generator::Printer* printer, const grpc_generator::Method* method, - std::map<TString, TString>* vars) { + std::map<TString, TString>* vars) { (*vars)["Method"] = method->name(); (*vars)["Request"] = method->input_type_name(); (*vars)["Response"] = method->output_type_name(); struct { - TString prefix; - TString start; // bool literal expressed as string - TString method_params; // extra arguments to method - TString create_args; // extra arguments to creator + TString prefix; + TString start; // bool literal expressed as string + TString method_params; // extra arguments to method + TString create_args; // extra arguments to creator } async_prefixes[] = {{"Async", "true", ", void* tag", ", tag"}, {"PrepareAsync", "false", "", ", nullptr"}}; if (method->NoStreaming()) { @@ -1902,7 +1902,7 @@ void PrintSourceClientMethod(grpc_generator::Printer* printer, "const $Request$* request, $Response$* response, " "std::function<void(::grpc::Status)> f) {\n"); printer->Print(*vars, - " ::grpc::internal::CallbackUnaryCall" + " ::grpc::internal::CallbackUnaryCall" "(stub_->channel_.get(), stub_->rpcmethod_$Method$_, " "context, request, response, std::move(f));\n}\n\n"); @@ -1912,42 +1912,42 @@ void PrintSourceClientMethod(grpc_generator::Printer* printer, "const $Request$* request, $Response$* response, " "::grpc::experimental::ClientUnaryReactor* reactor) {\n"); printer->Print(*vars, - " ::grpc::internal::ClientCallbackUnaryFactory::Create" + " ::grpc::internal::ClientCallbackUnaryFactory::Create" "(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, - " return " - "::grpc::internal::ClientAsyncResponseReaderFactory" - "< $Response$>::Create(channel_.get(), cq, " - "rpcmethod_$Method$_, " - "context, request, false);\n" - "}\n\n"); - printer->Print(*vars, - "::grpc::ClientAsyncResponseReader< $Response$>* " - "$ns$$Service$::Stub::Async$Method$Raw(::grpc::" - "ClientContext* context, " - "const $Request$& request, " - "::grpc::CompletionQueue* cq) {\n"); + "::grpc::ClientAsyncResponseReader< $Response$>* " + "$ns$$Service$::Stub::PrepareAsync$Method$Raw(::grpc::" + "ClientContext* context, " + "const $Request$& request, " + "::grpc::CompletionQueue* cq) {\n"); printer->Print(*vars, - " auto* result =\n" - " this->PrepareAsync$Method$Raw(context, request, cq);\n" - " result->StartCall();\n" - " return result;\n" - "}\n\n"); + " return " + "::grpc::internal::ClientAsyncResponseReaderFactory" + "< $Response$>::Create(channel_.get(), cq, " + "rpcmethod_$Method$_, " + "context, request, false);\n" + "}\n\n"); + printer->Print(*vars, + "::grpc::ClientAsyncResponseReader< $Response$>* " + "$ns$$Service$::Stub::Async$Method$Raw(::grpc::" + "ClientContext* context, " + "const $Request$& request, " + "::grpc::CompletionQueue* cq) {\n"); + printer->Print(*vars, + " auto* result =\n" + " this->PrepareAsync$Method$Raw(context, request, cq);\n" + " result->StartCall();\n" + " return result;\n" + "}\n\n"); } else if (ClientOnlyStreaming(method)) { printer->Print(*vars, "::grpc::ClientWriter< $Request$>* " "$ns$$Service$::Stub::$Method$Raw(" "::grpc::ClientContext* context, $Response$* response) {\n"); printer->Print(*vars, - " return ::grpc::internal::ClientWriterFactory< " + " return ::grpc::internal::ClientWriterFactory< " "$Request$>::Create(" "channel_.get(), " "rpcmethod_$Method$_, " @@ -1961,7 +1961,7 @@ void PrintSourceClientMethod(grpc_generator::Printer* printer, "$Response$* response, " "::grpc::experimental::ClientWriteReactor< $Request$>* reactor) {\n"); printer->Print(*vars, - " ::grpc::internal::ClientCallbackWriterFactory< " + " ::grpc::internal::ClientCallbackWriterFactory< " "$Request$>::Create(" "stub_->channel_.get(), " "stub_->rpcmethod_$Method$_, " @@ -1980,7 +1980,7 @@ void PrintSourceClientMethod(grpc_generator::Printer* printer, "::grpc::CompletionQueue* cq$AsyncMethodParams$) {\n"); printer->Print( *vars, - " return ::grpc::internal::ClientAsyncWriterFactory< $Request$>" + " return ::grpc::internal::ClientAsyncWriterFactory< $Request$>" "::Create(channel_.get(), cq, " "rpcmethod_$Method$_, " "context, response, $AsyncStart$$AsyncCreateArgs$);\n" @@ -1993,7 +1993,7 @@ void PrintSourceClientMethod(grpc_generator::Printer* printer, "$ns$$Service$::Stub::$Method$Raw(" "::grpc::ClientContext* context, const $Request$& request) {\n"); printer->Print(*vars, - " return ::grpc::internal::ClientReaderFactory< " + " return ::grpc::internal::ClientReaderFactory< " "$Response$>::Create(" "channel_.get(), " "rpcmethod_$Method$_, " @@ -2007,7 +2007,7 @@ void PrintSourceClientMethod(grpc_generator::Printer* printer, "$Request$* request, " "::grpc::experimental::ClientReadReactor< $Response$>* reactor) {\n"); printer->Print(*vars, - " ::grpc::internal::ClientCallbackReaderFactory< " + " ::grpc::internal::ClientCallbackReaderFactory< " "$Response$>::Create(" "stub_->channel_.get(), " "stub_->rpcmethod_$Method$_, " @@ -2025,13 +2025,13 @@ void PrintSourceClientMethod(grpc_generator::Printer* printer, "$ns$$Service$::Stub::$AsyncPrefix$$Method$Raw(" "::grpc::ClientContext* context, const $Request$& request, " "::grpc::CompletionQueue* cq$AsyncMethodParams$) {\n"); - printer->Print(*vars, - " return ::grpc::internal::ClientAsyncReaderFactory< " - "$Response$>" - "::Create(channel_.get(), cq, " - "rpcmethod_$Method$_, " - "context, request, $AsyncStart$$AsyncCreateArgs$);\n" - "}\n\n"); + printer->Print(*vars, + " return ::grpc::internal::ClientAsyncReaderFactory< " + "$Response$>" + "::Create(channel_.get(), cq, " + "rpcmethod_$Method$_, " + "context, request, $AsyncStart$$AsyncCreateArgs$);\n" + "}\n\n"); } } else if (method->BidiStreaming()) { printer->Print( @@ -2039,7 +2039,7 @@ void PrintSourceClientMethod(grpc_generator::Printer* printer, "::grpc::ClientReaderWriter< $Request$, $Response$>* " "$ns$$Service$::Stub::$Method$Raw(::grpc::ClientContext* context) {\n"); printer->Print(*vars, - " return ::grpc::internal::ClientReaderWriterFactory< " + " return ::grpc::internal::ClientReaderWriterFactory< " "$Request$, $Response$>::Create(" "channel_.get(), " "rpcmethod_$Method$_, " @@ -2052,13 +2052,13 @@ void PrintSourceClientMethod(grpc_generator::Printer* printer, "ClientContext* context, " "::grpc::experimental::ClientBidiReactor< $Request$,$Response$>* " "reactor) {\n"); - printer->Print(*vars, - " ::grpc::internal::ClientCallbackReaderWriterFactory< " - "$Request$,$Response$>::Create(" - "stub_->channel_.get(), " - "stub_->rpcmethod_$Method$_, " - "context, reactor);\n" - "}\n\n"); + printer->Print(*vars, + " ::grpc::internal::ClientCallbackReaderWriterFactory< " + "$Request$,$Response$>::Create(" + "stub_->channel_.get(), " + "stub_->rpcmethod_$Method$_, " + "context, reactor);\n" + "}\n\n"); for (auto async_prefix : async_prefixes) { (*vars)["AsyncPrefix"] = async_prefix.prefix; @@ -2072,7 +2072,7 @@ void PrintSourceClientMethod(grpc_generator::Printer* printer, "::grpc::CompletionQueue* cq$AsyncMethodParams$) {\n"); printer->Print(*vars, " return " - "::grpc::internal::ClientAsyncReaderWriterFactory< " + "::grpc::internal::ClientAsyncReaderWriterFactory< " "$Request$, $Response$>::Create(" "channel_.get(), cq, " "rpcmethod_$Method$_, " @@ -2084,7 +2084,7 @@ void PrintSourceClientMethod(grpc_generator::Printer* printer, void PrintSourceServerMethod(grpc_generator::Printer* printer, const grpc_generator::Method* method, - std::map<TString, TString>* vars) { + std::map<TString, TString>* vars) { (*vars)["Method"] = method->name(); (*vars)["Request"] = method->input_type_name(); (*vars)["Response"] = method->output_type_name(); @@ -2143,7 +2143,7 @@ void PrintSourceServerMethod(grpc_generator::Printer* printer, void PrintSourceService(grpc_generator::Printer* printer, const grpc_generator::Service* service, - std::map<TString, TString>* vars) { + std::map<TString, TString>* vars) { (*vars)["Service"] = service->name(); if (service->method_count() > 0) { @@ -2218,12 +2218,12 @@ void PrintSourceService(grpc_generator::Printer* printer, " new ::grpc::internal::RpcMethodHandler< $ns$$Service$::Service, " "$Request$, " "$Response$>(\n" - " []($ns$$Service$::Service* service,\n" - " ::grpc::ServerContext* ctx,\n" - " const $Request$* req,\n" - " $Response$* resp) {\n" - " return service->$Method$(ctx, req, resp);\n" - " }, this)));\n"); + " []($ns$$Service$::Service* service,\n" + " ::grpc::ServerContext* ctx,\n" + " const $Request$* req,\n" + " $Response$* resp) {\n" + " return service->$Method$(ctx, req, resp);\n" + " }, this)));\n"); } else if (ClientOnlyStreaming(method.get())) { printer->Print( *vars, @@ -2232,12 +2232,12 @@ void PrintSourceService(grpc_generator::Printer* printer, " ::grpc::internal::RpcMethod::CLIENT_STREAMING,\n" " new ::grpc::internal::ClientStreamingHandler< " "$ns$$Service$::Service, $Request$, $Response$>(\n" - " []($ns$$Service$::Service* service,\n" - " ::grpc::ServerContext* ctx,\n" - " ::grpc::ServerReader<$Request$>* reader,\n" - " $Response$* resp) {\n" - " return service->$Method$(ctx, reader, resp);\n" - " }, this)));\n"); + " []($ns$$Service$::Service* service,\n" + " ::grpc::ServerContext* ctx,\n" + " ::grpc::ServerReader<$Request$>* reader,\n" + " $Response$* resp) {\n" + " return service->$Method$(ctx, reader, resp);\n" + " }, this)));\n"); } else if (ServerOnlyStreaming(method.get())) { printer->Print( *vars, @@ -2246,25 +2246,25 @@ void PrintSourceService(grpc_generator::Printer* printer, " ::grpc::internal::RpcMethod::SERVER_STREAMING,\n" " new ::grpc::internal::ServerStreamingHandler< " "$ns$$Service$::Service, $Request$, $Response$>(\n" - " []($ns$$Service$::Service* service,\n" - " ::grpc::ServerContext* ctx,\n" - " const $Request$* req,\n" - " ::grpc::ServerWriter<$Response$>* writer) {\n" - " return service->$Method$(ctx, req, writer);\n" - " }, this)));\n"); + " []($ns$$Service$::Service* service,\n" + " ::grpc::ServerContext* ctx,\n" + " const $Request$* req,\n" + " ::grpc::ServerWriter<$Response$>* writer) {\n" + " return service->$Method$(ctx, req, writer);\n" + " }, this)));\n"); } else if (method->BidiStreaming()) { - printer->Print(*vars, - "AddMethod(new ::grpc::internal::RpcServiceMethod(\n" - " $prefix$$Service$_method_names[$Idx$],\n" - " ::grpc::internal::RpcMethod::BIDI_STREAMING,\n" - " new ::grpc::internal::BidiStreamingHandler< " - "$ns$$Service$::Service, $Request$, $Response$>(\n" - " []($ns$$Service$::Service* service,\n" - " ::grpc::ServerContext* ctx,\n" - " ::grpc::ServerReaderWriter<$Response$,\n" - " $Request$>* stream) {\n" - " return service->$Method$(ctx, stream);\n" - " }, this)));\n"); + printer->Print(*vars, + "AddMethod(new ::grpc::internal::RpcServiceMethod(\n" + " $prefix$$Service$_method_names[$Idx$],\n" + " ::grpc::internal::RpcMethod::BIDI_STREAMING,\n" + " new ::grpc::internal::BidiStreamingHandler< " + "$ns$$Service$::Service, $Request$, $Response$>(\n" + " []($ns$$Service$::Service* service,\n" + " ::grpc::ServerContext* ctx,\n" + " ::grpc::ServerReaderWriter<$Response$,\n" + " $Request$>* stream) {\n" + " return service->$Method$(ctx, stream);\n" + " }, this)));\n"); } } printer->Outdent(); @@ -2278,13 +2278,13 @@ void PrintSourceService(grpc_generator::Printer* printer, } } -TString GetSourceServices(grpc_generator::File* file, - const Parameters& params) { - TString output; +TString GetSourceServices(grpc_generator::File* file, + const Parameters& params) { + TString output; { // Scope the output stream so it closes and finalizes output to the string. auto printer = file->CreatePrinter(&output); - std::map<TString, TString> vars; + std::map<TString, TString> vars; // Package string is empty or ends with a dot. It is used to fully qualify // method names. vars["Package"] = file->package(); @@ -2307,12 +2307,12 @@ TString GetSourceServices(grpc_generator::File* file, return output; } -TString GetSourceEpilogue(grpc_generator::File* file, - const Parameters& /*params*/) { - TString temp; +TString GetSourceEpilogue(grpc_generator::File* file, + const Parameters& /*params*/) { + TString temp; if (!file->package().empty()) { - std::vector<TString> parts = file->package_parts(); + std::vector<TString> parts = file->package_parts(); for (auto part = parts.begin(); part != parts.end(); part++) { temp.append("} // namespace "); @@ -2326,13 +2326,13 @@ TString GetSourceEpilogue(grpc_generator::File* file, } // TODO(mmukhi): Make sure we need parameters or not. -TString GetMockPrologue(grpc_generator::File* file, - const Parameters& params) { - TString output; +TString GetMockPrologue(grpc_generator::File* file, + const Parameters& params) { + TString output; { // Scope the output stream so it closes and finalizes output to the string. auto printer = file->CreatePrinter(&output); - std::map<TString, TString> vars; + std::map<TString, TString> vars; vars["filename"] = file->filename(); vars["filename_base"] = file->filename_without_ext(); @@ -2349,9 +2349,9 @@ 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) { - const std::vector<TString> import_names = file->GetImportNames(); + const std::vector<TString> import_names = file->GetImportNames(); for (const auto& import_name : import_names) { - const TString include_name = ImportInludeFromProtoName(import_name); + const TString include_name = ImportInludeFromProtoName(import_name); printer->Print(vars, include_name.c_str()); } printer->PrintRaw("\n"); @@ -2363,23 +2363,23 @@ TString GetMockPrologue(grpc_generator::File* file, } // TODO(mmukhi): Add client-stream and completion-queue headers. -TString GetMockIncludes(grpc_generator::File* file, - const Parameters& params) { - TString output; +TString GetMockIncludes(grpc_generator::File* file, + const Parameters& params) { + TString output; { // Scope the output stream so it closes and finalizes output to the string. auto printer = file->CreatePrinter(&output); - std::map<TString, TString> vars; + std::map<TString, TString> vars; static const char* headers_strs[] = { "grpcpp/impl/codegen/async_stream.h", "grpcpp/impl/codegen/sync_stream.h", }; - std::vector<TString> headers(headers_strs, array_end(headers_strs)); + std::vector<TString> headers(headers_strs, array_end(headers_strs)); PrintIncludes(printer.get(), headers, params.use_system_headers, params.grpc_search_path); - std::vector<TString> gmock_header; + std::vector<TString> gmock_header; if (params.gmock_search_path.empty()) { gmock_header.push_back("gmock/gmock.h"); PrintIncludes(printer.get(), gmock_header, params.use_system_headers, @@ -2392,7 +2392,7 @@ TString GetMockIncludes(grpc_generator::File* file, } if (!file->package().empty()) { - std::vector<TString> parts = file->package_parts(); + std::vector<TString> parts = file->package_parts(); for (auto part = parts.begin(); part != parts.end(); part++) { vars["part"] = *part; @@ -2407,14 +2407,14 @@ TString GetMockIncludes(grpc_generator::File* file, void PrintMockClientMethods(grpc_generator::Printer* printer, const grpc_generator::Method* method, - std::map<TString, TString>* vars) { + std::map<TString, TString>* vars) { (*vars)["Method"] = method->name(); (*vars)["Request"] = method->input_type_name(); (*vars)["Response"] = method->output_type_name(); struct { - TString prefix; - TString method_params; // extra arguments to method + TString prefix; + TString method_params; // extra arguments to method int extra_method_param_count; } async_prefixes[] = {{"Async", ", void* tag", 1}, {"PrepareAsync", "", 0}}; @@ -2442,7 +2442,7 @@ void PrintMockClientMethods(grpc_generator::Printer* printer, (*vars)["AsyncPrefix"] = async_prefix.prefix; (*vars)["AsyncMethodParams"] = async_prefix.method_params; (*vars)["MockArgs"] = - ToString(3 + async_prefix.extra_method_param_count); + ToString(3 + async_prefix.extra_method_param_count); printer->Print(*vars, "MOCK_METHOD$MockArgs$($AsyncPrefix$$Method$Raw, " "::grpc::ClientAsyncWriterInterface< $Request$>*" @@ -2459,7 +2459,7 @@ void PrintMockClientMethods(grpc_generator::Printer* printer, (*vars)["AsyncPrefix"] = async_prefix.prefix; (*vars)["AsyncMethodParams"] = async_prefix.method_params; (*vars)["MockArgs"] = - ToString(3 + async_prefix.extra_method_param_count); + ToString(3 + async_prefix.extra_method_param_count); printer->Print( *vars, "MOCK_METHOD$MockArgs$($AsyncPrefix$$Method$Raw, " @@ -2477,7 +2477,7 @@ void PrintMockClientMethods(grpc_generator::Printer* printer, (*vars)["AsyncPrefix"] = async_prefix.prefix; (*vars)["AsyncMethodParams"] = async_prefix.method_params; (*vars)["MockArgs"] = - ToString(2 + async_prefix.extra_method_param_count); + ToString(2 + async_prefix.extra_method_param_count); printer->Print( *vars, "MOCK_METHOD$MockArgs$($AsyncPrefix$$Method$Raw, " @@ -2491,7 +2491,7 @@ void PrintMockClientMethods(grpc_generator::Printer* printer, void PrintMockService(grpc_generator::Printer* printer, const grpc_generator::Service* service, - std::map<TString, TString>* vars) { + std::map<TString, TString>* vars) { (*vars)["Service"] = service->name(); printer->Print(*vars, @@ -2505,13 +2505,13 @@ void PrintMockService(grpc_generator::Printer* printer, printer->Print("};\n"); } -TString GetMockServices(grpc_generator::File* file, - const Parameters& params) { - TString output; +TString GetMockServices(grpc_generator::File* file, + const Parameters& params) { + TString output; { // Scope the output stream so it closes and finalizes output to the string. auto printer = file->CreatePrinter(&output); - std::map<TString, TString> vars; + std::map<TString, TString> vars; // Package string is empty or ends with a dot. It is used to fully qualify // method names. vars["Package"] = file->package(); @@ -2536,12 +2536,12 @@ TString GetMockServices(grpc_generator::File* file, return output; } -TString GetMockEpilogue(grpc_generator::File* file, - const Parameters& /*params*/) { - TString temp; +TString GetMockEpilogue(grpc_generator::File* file, + const Parameters& /*params*/) { + TString temp; if (!file->package().empty()) { - std::vector<TString> parts = file->package_parts(); + std::vector<TString> parts = file->package_parts(); for (auto part = parts.begin(); part != parts.end(); part++) { temp.append("} // namespace "); diff --git a/contrib/libs/grpc/src/compiler/cpp_generator.h b/contrib/libs/grpc/src/compiler/cpp_generator.h index 606b850a874..7ace6f270f1 100644 --- a/contrib/libs/grpc/src/compiler/cpp_generator.h +++ b/contrib/libs/grpc/src/compiler/cpp_generator.h @@ -24,22 +24,22 @@ // FlatBuffers. #include <memory> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <vector> #include "src/compiler/config.h" #include "src/compiler/schema_interface.h" -#ifdef GRPC_CUSTOM_STRING -#warning GRPC_CUSTOM_STRING is no longer supported. Please use TString. +#ifdef GRPC_CUSTOM_STRING +#warning GRPC_CUSTOM_STRING is no longer supported. Please use TString. #endif namespace grpc { -// Using grpc::string and grpc::to_string is discouraged in favor of -// TString and ToString. This is only for legacy code using -// them explictly. -typedef TString string; // deprecated +// Using grpc::string and grpc::to_string is discouraged in favor of +// TString and ToString. This is only for legacy code using +// them explictly. +typedef TString string; // deprecated } // namespace grpc @@ -48,86 +48,86 @@ namespace grpc_cpp_generator { // Contains all the parameters that are parsed from the command line. struct Parameters { // Puts the service into a namespace - TString services_namespace; + TString services_namespace; // Use system includes (<>) or local includes ("") bool use_system_headers; // Prefix to any grpc include - TString grpc_search_path; + TString grpc_search_path; // Generate Google Mock code to facilitate unit testing. bool generate_mock_code; // Google Mock search path, when non-empty, local includes will be used. - TString gmock_search_path; + TString gmock_search_path; // *EXPERIMENTAL* Additional include files in grpc.pb.h - std::vector<TString> additional_header_includes; + std::vector<TString> additional_header_includes; // By default, use "pb.h" - TString message_header_extension; + TString message_header_extension; // Whether to include headers corresponding to imports in source file. bool include_import_headers; }; // Return the prologue of the generated header file. -TString GetHeaderPrologue(grpc_generator::File* file, - const Parameters& params); +TString GetHeaderPrologue(grpc_generator::File* file, + const Parameters& params); // Return the includes needed for generated header file. -TString GetHeaderIncludes(grpc_generator::File* file, - const Parameters& params); +TString GetHeaderIncludes(grpc_generator::File* file, + const Parameters& params); // Return the includes needed for generated source file. -TString GetSourceIncludes(grpc_generator::File* file, - const Parameters& params); +TString GetSourceIncludes(grpc_generator::File* file, + const Parameters& params); // Return the epilogue of the generated header file. -TString GetHeaderEpilogue(grpc_generator::File* file, - const Parameters& params); +TString GetHeaderEpilogue(grpc_generator::File* file, + const Parameters& params); // Return the prologue of the generated source file. -TString GetSourcePrologue(grpc_generator::File* file, - const Parameters& params); +TString GetSourcePrologue(grpc_generator::File* file, + const Parameters& params); // Return the services for generated header file. -TString GetHeaderServices(grpc_generator::File* file, - const Parameters& params); +TString GetHeaderServices(grpc_generator::File* file, + const Parameters& params); // Return the services for generated source file. -TString GetSourceServices(grpc_generator::File* file, - const Parameters& params); +TString GetSourceServices(grpc_generator::File* file, + const Parameters& params); // Return the epilogue of the generated source file. -TString GetSourceEpilogue(grpc_generator::File* file, - const Parameters& params); +TString GetSourceEpilogue(grpc_generator::File* file, + const Parameters& params); // Return the prologue of the generated mock file. -TString GetMockPrologue(grpc_generator::File* file, - const Parameters& params); +TString GetMockPrologue(grpc_generator::File* file, + const Parameters& params); // Return the includes needed for generated mock file. -TString GetMockIncludes(grpc_generator::File* file, - const Parameters& params); +TString GetMockIncludes(grpc_generator::File* file, + const Parameters& params); // Return the services for generated mock file. -TString GetMockServices(grpc_generator::File* file, - const Parameters& params); +TString GetMockServices(grpc_generator::File* file, + const Parameters& params); // Return the epilogue of generated mock file. -TString GetMockEpilogue(grpc_generator::File* file, - const Parameters& params); +TString GetMockEpilogue(grpc_generator::File* file, + const Parameters& params); // Return the prologue of the generated mock file. -TString GetMockPrologue(grpc_generator::File* file, - const Parameters& params); +TString GetMockPrologue(grpc_generator::File* file, + const Parameters& params); // Return the includes needed for generated mock file. -TString GetMockIncludes(grpc_generator::File* file, - const Parameters& params); +TString GetMockIncludes(grpc_generator::File* file, + const Parameters& params); // Return the services for generated mock file. -TString GetMockServices(grpc_generator::File* file, - const Parameters& params); +TString GetMockServices(grpc_generator::File* file, + const Parameters& params); // Return the epilogue of generated mock file. -TString GetMockEpilogue(grpc_generator::File* file, - const Parameters& params); +TString GetMockEpilogue(grpc_generator::File* file, + const Parameters& params); } // namespace grpc_cpp_generator diff --git a/contrib/libs/grpc/src/compiler/cpp_generator_helpers.h b/contrib/libs/grpc/src/compiler/cpp_generator_helpers.h index 2e34d53a65d..b50c75ef1bb 100644 --- a/contrib/libs/grpc/src/compiler/cpp_generator_helpers.h +++ b/contrib/libs/grpc/src/compiler/cpp_generator_helpers.h @@ -26,23 +26,23 @@ namespace grpc_cpp_generator { -inline TString DotsToColons(const TString& name) { +inline TString DotsToColons(const TString& name) { return grpc_generator::StringReplace(name, ".", "::"); } -inline TString DotsToUnderscores(const TString& name) { +inline TString DotsToUnderscores(const TString& name) { return grpc_generator::StringReplace(name, ".", "_"); } -inline TString ClassName(const grpc::protobuf::Descriptor* descriptor, - bool qualified) { +inline TString ClassName(const grpc::protobuf::Descriptor* descriptor, + bool qualified) { // Find "outer", the descriptor of the top-level message in which // "descriptor" is embedded. const grpc::protobuf::Descriptor* outer = descriptor; while (outer->containing_type() != NULL) outer = outer->containing_type(); - const TString& outer_name = outer->full_name(); - TString inner_name = descriptor->full_name().substr(outer_name.size()); + const TString& outer_name = outer->full_name(); + TString inner_name = descriptor->full_name().substr(outer_name.size()); if (qualified) { return "::" + DotsToColons(outer_name) + DotsToUnderscores(inner_name); @@ -54,7 +54,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. template <typename DescriptorType> -inline TString GetCppComments(const DescriptorType* desc, bool leading) { +inline TString GetCppComments(const DescriptorType* desc, bool leading) { return grpc_generator::GetPrefixedComments(desc, leading, "//"); } diff --git a/contrib/libs/grpc/src/compiler/cpp_plugin.h b/contrib/libs/grpc/src/compiler/cpp_plugin.h index 0c289a7395b..bb48ed0388e 100644 --- a/contrib/libs/grpc/src/compiler/cpp_plugin.h +++ b/contrib/libs/grpc/src/compiler/cpp_plugin.h @@ -34,14 +34,14 @@ class CppGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { CppGrpcGenerator() {} virtual ~CppGrpcGenerator() {} - uint64_t GetSupportedFeatures() const override { - return FEATURE_PROTO3_OPTIONAL; - } - + uint64_t GetSupportedFeatures() const override { + return FEATURE_PROTO3_OPTIONAL; + } + virtual bool Generate(const grpc::protobuf::FileDescriptor* file, - const TString& parameter, + const TString& parameter, grpc::protobuf::compiler::GeneratorContext* context, - TString* error) const override { + TString* error) const override { if (file->options().cc_generic_services()) { *error = "cpp grpc proto compiler plugin does not work with generic " @@ -58,11 +58,11 @@ class CppGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { ProtoBufFile pbfile(file); if (!parameter.empty()) { - std::vector<TString> parameters_list = + std::vector<TString> parameters_list = grpc_generator::tokenize(parameter, ","); for (auto parameter_string = parameters_list.begin(); parameter_string != parameters_list.end(); parameter_string++) { - std::vector<TString> param = + std::vector<TString> param = grpc_generator::tokenize(*parameter_string, "="); if (param[0] == "services_namespace") { generator_parameters.services_namespace = param[1]; @@ -72,7 +72,7 @@ class CppGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { } else if (param[1] == "false") { generator_parameters.use_system_headers = false; } else { - *error = TString("Invalid parameter: ") + *parameter_string; + *error = TString("Invalid parameter: ") + *parameter_string; return false; } } else if (param[0] == "grpc_search_path") { @@ -81,7 +81,7 @@ class CppGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { if (param[1] == "true") { generator_parameters.generate_mock_code = true; } else if (param[1] != "false") { - *error = TString("Invalid parameter: ") + *parameter_string; + *error = TString("Invalid parameter: ") + *parameter_string; return false; } } else if (param[0] == "gmock_search_path") { @@ -95,19 +95,19 @@ class CppGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { if (param[1] == "true") { generator_parameters.include_import_headers = true; } else if (param[1] != "false") { - *error = TString("Invalid parameter: ") + *parameter_string; + *error = TString("Invalid parameter: ") + *parameter_string; return false; } } else { - *error = TString("Unknown parameter: ") + *parameter_string; + *error = TString("Unknown parameter: ") + *parameter_string; return false; } } } - TString file_name = grpc_generator::StripProto(file->name()); + TString file_name = grpc_generator::StripProto(file->name()); - TString header_code = + TString header_code = grpc_cpp_generator::GetHeaderPrologue(&pbfile, generator_parameters) + grpc_cpp_generator::GetHeaderIncludes(&pbfile, generator_parameters) + grpc_cpp_generator::GetHeaderServices(&pbfile, generator_parameters) + @@ -117,7 +117,7 @@ class CppGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { grpc::protobuf::io::CodedOutputStream header_coded_out(header_output.get()); header_coded_out.WriteRaw(header_code.data(), header_code.size()); - TString source_code = + TString source_code = grpc_cpp_generator::GetSourcePrologue(&pbfile, generator_parameters) + grpc_cpp_generator::GetSourceIncludes(&pbfile, generator_parameters) + grpc_cpp_generator::GetSourceServices(&pbfile, generator_parameters) + @@ -130,7 +130,7 @@ class CppGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { if (!generator_parameters.generate_mock_code) { return true; } - TString mock_code = + TString mock_code = grpc_cpp_generator::GetMockPrologue(&pbfile, generator_parameters) + grpc_cpp_generator::GetMockIncludes(&pbfile, generator_parameters) + grpc_cpp_generator::GetMockServices(&pbfile, generator_parameters) + @@ -146,8 +146,8 @@ class CppGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { 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 { + 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()); diff --git a/contrib/libs/grpc/src/compiler/csharp_generator.cc b/contrib/libs/grpc/src/compiler/csharp_generator.cc index 3b7107c4c48..430be335ca2 100644 --- a/contrib/libs/grpc/src/compiler/csharp_generator.cc +++ b/contrib/libs/grpc/src/compiler/csharp_generator.cc @@ -35,7 +35,7 @@ using grpc::protobuf::ServiceDescriptor; using grpc::protobuf::io::Printer; using grpc::protobuf::io::StringOutputStream; using grpc_generator::GetMethodType; -using grpc_generator::MethodType; +using grpc_generator::MethodType; using grpc_generator::METHODTYPE_BIDI_STREAMING; using grpc_generator::METHODTYPE_CLIENT_STREAMING; using grpc_generator::METHODTYPE_NO_STREAMING; @@ -54,9 +54,9 @@ namespace { // TODO(jtattermusch): reuse the functionality from google/protobuf. bool GenerateDocCommentBodyImpl(grpc::protobuf::io::Printer* printer, grpc::protobuf::SourceLocation location) { - TString comments = location.leading_comments.empty() - ? location.trailing_comments - : location.leading_comments; + TString comments = location.leading_comments.empty() + ? location.trailing_comments + : location.leading_comments; if (comments.empty()) { return false; } @@ -66,7 +66,7 @@ bool GenerateDocCommentBodyImpl(grpc::protobuf::io::Printer* printer, comments = grpc_generator::StringReplace(comments, "&", "&", true); comments = grpc_generator::StringReplace(comments, "<", "<", true); - std::vector<TString> lines; + std::vector<TString> lines; grpc_generator::Split(comments, '\n', &lines); // TODO: We really should work out which part to put in the summary and which // to put in the remarks... @@ -81,9 +81,9 @@ bool GenerateDocCommentBodyImpl(grpc::protobuf::io::Printer* printer, // Note that we can't remove leading or trailing whitespace as *that's* // relevant in markdown too. // (We don't skip "just whitespace" lines, either.) - for (std::vector<TString>::iterator it = lines.begin(); it != lines.end(); - ++it) { - TString line = *it; + for (std::vector<TString>::iterator it = lines.begin(); it != lines.end(); + ++it) { + TString line = *it; if (line.empty()) { last_was_empty = true; } else { @@ -172,19 +172,19 @@ void GenerateDocCommentClientMethod(grpc::protobuf::io::Printer* printer, } } -TString GetServiceClassName(const ServiceDescriptor* service) { +TString GetServiceClassName(const ServiceDescriptor* service) { return service->name(); } -TString GetClientClassName(const ServiceDescriptor* service) { +TString GetClientClassName(const ServiceDescriptor* service) { return service->name() + "Client"; } -TString GetServerClassName(const ServiceDescriptor* service) { +TString GetServerClassName(const ServiceDescriptor* service) { return service->name() + "Base"; } -TString GetCSharpMethodType(MethodType method_type) { +TString GetCSharpMethodType(MethodType method_type) { switch (method_type) { case METHODTYPE_NO_STREAMING: return "grpc::MethodType.Unary"; @@ -199,7 +199,7 @@ TString GetCSharpMethodType(MethodType method_type) { return ""; } -TString GetCSharpServerMethodType(MethodType method_type) { +TString GetCSharpServerMethodType(MethodType method_type) { switch (method_type) { case METHODTYPE_NO_STREAMING: return "grpc::UnaryServerMethod"; @@ -214,18 +214,18 @@ TString GetCSharpServerMethodType(MethodType method_type) { return ""; } -TString GetServiceNameFieldName() { return "__ServiceName"; } +TString GetServiceNameFieldName() { return "__ServiceName"; } -TString GetMarshallerFieldName(const Descriptor* message) { +TString GetMarshallerFieldName(const Descriptor* message) { return "__Marshaller_" + grpc_generator::StringReplace(message->full_name(), ".", "_", true); } -TString GetMethodFieldName(const MethodDescriptor* method) { +TString GetMethodFieldName(const MethodDescriptor* method) { return "__Method_" + method->name(); } -TString GetMethodRequestParamMaybe(const MethodDescriptor* method, +TString GetMethodRequestParamMaybe(const MethodDescriptor* method, bool invocation_param = false) { if (method->client_streaming()) { return ""; @@ -236,11 +236,11 @@ TString GetMethodRequestParamMaybe(const MethodDescriptor* method, return GetClassName(method->input_type()) + " request, "; } -TString GetAccessLevel(bool internal_access) { +TString GetAccessLevel(bool internal_access) { return internal_access ? "internal" : "public"; } -TString GetMethodReturnTypeClient(const MethodDescriptor* method) { +TString GetMethodReturnTypeClient(const MethodDescriptor* method) { switch (GetMethodType(method)) { case METHODTYPE_NO_STREAMING: return "grpc::AsyncUnaryCall<" + GetClassName(method->output_type()) + @@ -261,7 +261,7 @@ TString GetMethodReturnTypeClient(const MethodDescriptor* method) { return ""; } -TString GetMethodRequestParamServer(const MethodDescriptor* method) { +TString GetMethodRequestParamServer(const MethodDescriptor* method) { switch (GetMethodType(method)) { case METHODTYPE_NO_STREAMING: case METHODTYPE_SERVER_STREAMING: @@ -275,7 +275,7 @@ TString GetMethodRequestParamServer(const MethodDescriptor* method) { return ""; } -TString GetMethodReturnTypeServer(const MethodDescriptor* method) { +TString GetMethodReturnTypeServer(const MethodDescriptor* method) { switch (GetMethodType(method)) { case METHODTYPE_NO_STREAMING: case METHODTYPE_CLIENT_STREAMING: @@ -289,7 +289,7 @@ TString GetMethodReturnTypeServer(const MethodDescriptor* method) { return ""; } -TString GetMethodResponseStreamMaybe(const MethodDescriptor* method) { +TString GetMethodResponseStreamMaybe(const MethodDescriptor* method) { switch (GetMethodType(method)) { case METHODTYPE_NO_STREAMING: case METHODTYPE_CLIENT_STREAMING: @@ -325,76 +325,76 @@ std::vector<const Descriptor*> GetUsedMessages( void GenerateMarshallerFields(Printer* out, const ServiceDescriptor* service) { std::vector<const Descriptor*> used_messages = GetUsedMessages(service); - if (used_messages.size() != 0) { - // Generate static helper methods for serialization/deserialization - out->Print( - "static void __Helper_SerializeMessage(" - "global::Google.Protobuf.IMessage message, " - "grpc::SerializationContext context)\n" - "{\n"); - out->Indent(); - out->Print( - "#if !GRPC_DISABLE_PROTOBUF_BUFFER_SERIALIZATION\n" - "if (message is global::Google.Protobuf.IBufferMessage)\n" - "{\n"); - out->Indent(); - out->Print( - "context.SetPayloadLength(message.CalculateSize());\n" - "global::Google.Protobuf.MessageExtensions.WriteTo(message, " - "context.GetBufferWriter());\n" - "context.Complete();\n" - "return;\n"); - out->Outdent(); - out->Print( - "}\n" - "#endif\n"); - out->Print( - "context.Complete(" - "global::Google.Protobuf.MessageExtensions.ToByteArray(message));\n"); - out->Outdent(); - out->Print("}\n\n"); - - out->Print( - "static class __Helper_MessageCache<T>\n" - "{\n"); - out->Indent(); - out->Print( - "public static readonly bool IsBufferMessage = " - "global::System.Reflection.IntrospectionExtensions.GetTypeInfo(typeof(" - "global::Google.Protobuf.IBufferMessage)).IsAssignableFrom(typeof(T));" - "\n"); - out->Outdent(); - out->Print("}\n\n"); - - out->Print( - "static T __Helper_DeserializeMessage<T>(" - "grpc::DeserializationContext context, " - "global::Google.Protobuf.MessageParser<T> parser) " - "where T : global::Google.Protobuf.IMessage<T>\n" - "{\n"); - out->Indent(); - out->Print( - "#if !GRPC_DISABLE_PROTOBUF_BUFFER_SERIALIZATION\n" - "if (__Helper_MessageCache<T>.IsBufferMessage)\n" - "{\n"); - out->Indent(); - out->Print( - "return parser.ParseFrom(context.PayloadAsReadOnlySequence());\n"); - out->Outdent(); - out->Print( - "}\n" - "#endif\n"); - out->Print("return parser.ParseFrom(context.PayloadAsNewBuffer());\n"); - out->Outdent(); - out->Print("}\n\n"); - } - + if (used_messages.size() != 0) { + // Generate static helper methods for serialization/deserialization + out->Print( + "static void __Helper_SerializeMessage(" + "global::Google.Protobuf.IMessage message, " + "grpc::SerializationContext context)\n" + "{\n"); + out->Indent(); + out->Print( + "#if !GRPC_DISABLE_PROTOBUF_BUFFER_SERIALIZATION\n" + "if (message is global::Google.Protobuf.IBufferMessage)\n" + "{\n"); + out->Indent(); + out->Print( + "context.SetPayloadLength(message.CalculateSize());\n" + "global::Google.Protobuf.MessageExtensions.WriteTo(message, " + "context.GetBufferWriter());\n" + "context.Complete();\n" + "return;\n"); + out->Outdent(); + out->Print( + "}\n" + "#endif\n"); + out->Print( + "context.Complete(" + "global::Google.Protobuf.MessageExtensions.ToByteArray(message));\n"); + out->Outdent(); + out->Print("}\n\n"); + + out->Print( + "static class __Helper_MessageCache<T>\n" + "{\n"); + out->Indent(); + out->Print( + "public static readonly bool IsBufferMessage = " + "global::System.Reflection.IntrospectionExtensions.GetTypeInfo(typeof(" + "global::Google.Protobuf.IBufferMessage)).IsAssignableFrom(typeof(T));" + "\n"); + out->Outdent(); + out->Print("}\n\n"); + + out->Print( + "static T __Helper_DeserializeMessage<T>(" + "grpc::DeserializationContext context, " + "global::Google.Protobuf.MessageParser<T> parser) " + "where T : global::Google.Protobuf.IMessage<T>\n" + "{\n"); + out->Indent(); + out->Print( + "#if !GRPC_DISABLE_PROTOBUF_BUFFER_SERIALIZATION\n" + "if (__Helper_MessageCache<T>.IsBufferMessage)\n" + "{\n"); + out->Indent(); + out->Print( + "return parser.ParseFrom(context.PayloadAsReadOnlySequence());\n"); + out->Outdent(); + out->Print( + "}\n" + "#endif\n"); + out->Print("return parser.ParseFrom(context.PayloadAsNewBuffer());\n"); + out->Outdent(); + out->Print("}\n\n"); + } + for (size_t i = 0; i < used_messages.size(); i++) { const Descriptor* message = used_messages[i]; out->Print( "static readonly grpc::Marshaller<$type$> $fieldname$ = " - "grpc::Marshallers.Create(__Helper_SerializeMessage, " - "context => __Helper_DeserializeMessage(context, $type$.Parser));\n", + "grpc::Marshallers.Create(__Helper_SerializeMessage, " + "context => __Helper_DeserializeMessage(context, $type$.Parser));\n", "fieldname", GetMarshallerFieldName(message), "type", GetClassName(message)); } @@ -569,7 +569,7 @@ void GenerateClientStub(Printer* out, const ServiceDescriptor* service) { out->Print("}\n"); } - TString method_name = method->name(); + TString method_name = method->name(); if (method_type == METHODTYPE_NO_STREAMING) { method_name += "Async"; // prevent name clash with synchronous method. } @@ -769,9 +769,9 @@ void GenerateService(Printer* out, const ServiceDescriptor* service, } // anonymous namespace -TString GetServices(const FileDescriptor* file, bool generate_client, - bool generate_server, bool internal_access) { - TString output; +TString GetServices(const FileDescriptor* file, bool generate_client, + bool generate_server, bool internal_access) { + TString output; { // Scope the output stream so it closes and finalizes output to the string. @@ -792,7 +792,7 @@ TString GetServices(const FileDescriptor* file, bool generate_client, out.Print("// </auto-generated>\n"); // use C++ style as there are no file-level XML comments in .NET - TString leading_comments = GetCsharpComments(file, true); + TString leading_comments = GetCsharpComments(file, true); if (!leading_comments.empty()) { out.Print("// Original file comments:\n"); out.PrintRaw(leading_comments.c_str()); @@ -805,7 +805,7 @@ TString GetServices(const FileDescriptor* file, bool generate_client, out.Print("using grpc = global::Grpc.Core;\n"); out.Print("\n"); - TString file_namespace = GetFileNamespace(file); + TString file_namespace = GetFileNamespace(file); if (file_namespace != "") { out.Print("namespace $namespace$ {\n", "namespace", file_namespace); out.Indent(); diff --git a/contrib/libs/grpc/src/compiler/csharp_generator.h b/contrib/libs/grpc/src/compiler/csharp_generator.h index c13da4657f3..53ba561f24b 100644 --- a/contrib/libs/grpc/src/compiler/csharp_generator.h +++ b/contrib/libs/grpc/src/compiler/csharp_generator.h @@ -25,9 +25,9 @@ namespace grpc_csharp_generator { -TString GetServices(const grpc::protobuf::FileDescriptor* file, - bool generate_client, bool generate_server, - bool internal_access); +TString GetServices(const grpc::protobuf::FileDescriptor* file, + bool generate_client, bool generate_server, + bool internal_access); } // namespace grpc_csharp_generator diff --git a/contrib/libs/grpc/src/compiler/csharp_generator_helpers.h b/contrib/libs/grpc/src/compiler/csharp_generator_helpers.h index a8af7f3ccd1..8b65536251c 100644 --- a/contrib/libs/grpc/src/compiler/csharp_generator_helpers.h +++ b/contrib/libs/grpc/src/compiler/csharp_generator_helpers.h @@ -25,7 +25,7 @@ namespace grpc_csharp_generator { inline bool ServicesFilename(const grpc::protobuf::FileDescriptor* file, - TString* file_name_or_error) { + TString* file_name_or_error) { *file_name_or_error = grpc_generator::FileNameInUpperCamel(file, false) + "Grpc.cs"; return true; @@ -34,7 +34,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. template <typename DescriptorType> -inline TString GetCsharpComments(const DescriptorType* desc, bool leading) { +inline TString GetCsharpComments(const DescriptorType* desc, bool leading) { return grpc_generator::GetPrefixedComments(desc, leading, "//"); } diff --git a/contrib/libs/grpc/src/compiler/generator_helpers.h b/contrib/libs/grpc/src/compiler/generator_helpers.h index 265713a16b3..149529a7728 100644 --- a/contrib/libs/grpc/src/compiler/generator_helpers.h +++ b/contrib/libs/grpc/src/compiler/generator_helpers.h @@ -22,21 +22,21 @@ #include <iostream> #include <map> #include <sstream> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <vector> #include <util/generic/string.h> #include <util/string/split.h> #include <util/stream/str.h> -#include "src/compiler/config.h" - +#include "src/compiler/config.h" + namespace grpc_generator { -inline bool StripSuffix(TString* filename, const TString& suffix) { +inline bool StripSuffix(TString* filename, const TString& suffix) { if (filename->length() >= suffix.length()) { size_t suffix_pos = filename->length() - suffix.length(); - if (filename->compare(suffix_pos, TString::npos, suffix) == 0) { + if (filename->compare(suffix_pos, TString::npos, suffix) == 0) { filename->resize(filename->size() - suffix.size()); return true; } @@ -45,7 +45,7 @@ inline bool StripSuffix(TString* filename, const TString& suffix) { return false; } -inline bool StripPrefix(TString* name, const TString& prefix) { +inline bool StripPrefix(TString* name, const TString& prefix) { if (name->length() >= prefix.length()) { if (name->substr(0, prefix.size()) == prefix) { *name = name->substr(prefix.size()); @@ -55,20 +55,20 @@ inline bool StripPrefix(TString* name, const TString& prefix) { return false; } -inline TString StripProto(TString filename) { +inline TString StripProto(TString filename) { if (!StripSuffix(&filename, ".protodevel")) { StripSuffix(&filename, ".proto"); } return filename; } -inline TString StringReplace(TString str, const TString& from, - const TString& to, bool replace_all) { +inline TString StringReplace(TString str, const TString& from, + const TString& to, bool replace_all) { size_t pos = 0; do { pos = str.find(from, pos); - if (pos == TString::npos) { + if (pos == TString::npos) { break; } str.replace(pos, from.length(), to); @@ -78,20 +78,20 @@ inline TString StringReplace(TString str, const TString& from, return str; } -inline TString StringReplace(TString str, const TString& from, - const TString& to) { +inline TString StringReplace(TString str, const TString& from, + const TString& to) { return StringReplace(str, from, to, true); } -inline std::vector<TString> tokenize(const TString& input, - const TString& delimiters) { - std::vector<TString> tokens; +inline std::vector<TString> tokenize(const TString& input, + const TString& delimiters) { + std::vector<TString> tokens; size_t pos, last_pos = 0; for (;;) { bool done = false; pos = input.find_first_of(delimiters, last_pos); - if (pos == TString::npos) { + if (pos == TString::npos) { done = true; pos = input.length(); } @@ -103,7 +103,7 @@ inline std::vector<TString> tokenize(const TString& input, } } -inline TString CapitalizeFirstLetter(TString s) { +inline TString CapitalizeFirstLetter(TString s) { if (s.empty()) { return s; } @@ -111,7 +111,7 @@ inline TString CapitalizeFirstLetter(TString s) { return s; } -inline TString LowercaseFirstLetter(TString s) { +inline TString LowercaseFirstLetter(TString s) { if (s.empty()) { return s; } @@ -119,19 +119,19 @@ inline TString LowercaseFirstLetter(TString s) { return s; } -inline TString LowerUnderscoreToUpperCamel(TString str) { - std::vector<TString> tokens = tokenize(str, "_"); - TString result = ""; +inline TString LowerUnderscoreToUpperCamel(TString str) { + std::vector<TString> tokens = tokenize(str, "_"); + TString result = ""; for (unsigned int i = 0; i < tokens.size(); i++) { result += CapitalizeFirstLetter(tokens[i]); } return result; } -inline TString FileNameInUpperCamel( +inline TString FileNameInUpperCamel( const grpc::protobuf::FileDescriptor* file, bool include_package_path) { - std::vector<TString> tokens = tokenize(StripProto(file->name()), "/"); - TString result = ""; + std::vector<TString> tokens = tokenize(StripProto(file->name()), "/"); + TString result = ""; if (include_package_path) { for (unsigned int i = 0; i < tokens.size() - 1; i++) { result += tokens[i] + "/"; @@ -141,7 +141,7 @@ inline TString FileNameInUpperCamel( return result; } -inline TString FileNameInUpperCamel( +inline TString FileNameInUpperCamel( const grpc::protobuf::FileDescriptor* file) { return FileNameInUpperCamel(file, true); } @@ -171,11 +171,11 @@ inline MethodType GetMethodType( } template <typename TStringType> -inline void Split(const TStringType& s, char /*delim*/, +inline void Split(const TStringType& s, char /*delim*/, std::vector<TStringType>* append_to) { std::istringstream iss(s); TStringType piece; - while (std::getline(iss, piece)) { + while (std::getline(iss, piece)) { append_to->push_back(piece); } } @@ -199,15 +199,15 @@ enum CommentType { // Get all the raw comments and append each line without newline to out. template <typename DescriptorType> inline void GetComment(const DescriptorType* desc, CommentType type, - std::vector<TString>* out) { + std::vector<TString>* out) { grpc::protobuf::SourceLocation location; if (!desc->GetSourceLocation(&location)) { return; } if (type == COMMENTTYPE_LEADING || type == COMMENTTYPE_TRAILING) { - const TString& comments = type == COMMENTTYPE_LEADING - ? location.leading_comments - : location.trailing_comments; + const TString& comments = type == COMMENTTYPE_LEADING + ? location.leading_comments + : location.trailing_comments; Split(comments, '\n', out); } else if (type == COMMENTTYPE_LEADING_DETACHED) { for (unsigned int i = 0; i < location.leading_detached_comments.size(); @@ -226,7 +226,7 @@ inline void GetComment(const DescriptorType* desc, CommentType type, // above syntax line. Return nothing for trailing comments. template <> inline void GetComment(const grpc::protobuf::FileDescriptor* desc, - CommentType type, std::vector<TString>* out) { + CommentType type, std::vector<TString>* out) { if (type == COMMENTTYPE_TRAILING) { return; } @@ -252,11 +252,11 @@ inline void GetComment(const grpc::protobuf::FileDescriptor* desc, // Add prefix and newline to each comment line and concatenate them together. // Make sure there is a space after the prefix unless the line is empty. -inline TString GenerateCommentsWithPrefix( - const std::vector<TString>& in, const TString& prefix) { +inline TString GenerateCommentsWithPrefix( + const std::vector<TString>& in, const TString& prefix) { std::ostringstream oss; for (auto it = in.begin(); it != in.end(); it++) { - const TString& elem = *it; + const TString& elem = *it; if (elem.empty()) { oss << prefix << "\n"; } else if (elem[0] == ' ') { @@ -265,17 +265,17 @@ inline TString GenerateCommentsWithPrefix( oss << prefix << " " << elem << "\n"; } } - return oss.str(); + return oss.str(); } template <typename DescriptorType> -inline TString GetPrefixedComments(const DescriptorType* desc, bool leading, - const TString& prefix) { - std::vector<TString> out; +inline TString GetPrefixedComments(const DescriptorType* desc, bool leading, + const TString& prefix) { + std::vector<TString> out; if (leading) { grpc_generator::GetComment( desc, grpc_generator::COMMENTTYPE_LEADING_DETACHED, &out); - std::vector<TString> leading; + std::vector<TString> leading; grpc_generator::GetComment(desc, grpc_generator::COMMENTTYPE_LEADING, &leading); out.insert(out.end(), leading.begin(), leading.end()); 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 a4b7e363a3b..a5a970dad5e 100644 --- a/contrib/libs/grpc/src/compiler/grpc_cpp_plugin/ya.make +++ b/contrib/libs/grpc/src/compiler/grpc_cpp_plugin/ya.make @@ -2,8 +2,8 @@ PROGRAM() -WITHOUT_LICENSE_TEXTS() - +WITHOUT_LICENSE_TEXTS() + OWNER(g:cpp-contrib) LICENSE(Apache-2.0) @@ -15,7 +15,7 @@ PEERDIR( ) ADDINCL( - ${ARCADIA_BUILD_ROOT}/contrib/libs/grpc + ${ARCADIA_BUILD_ROOT}/contrib/libs/grpc contrib/libs/grpc contrib/libs/grpc/include ) @@ -25,9 +25,9 @@ NO_COMPILER_WARNINGS() SRCDIR(contrib/libs/grpc/src/compiler) IF (OS_LINUX OR OS_DARWIN) - CFLAGS( - -DGRPC_POSIX_FORK_ALLOW_PTHREAD_ATFORK=1 - ) + CFLAGS( + -DGRPC_POSIX_FORK_ALLOW_PTHREAD_ATFORK=1 + ) ENDIF() SRCS( 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 068ae1ead6d..f5001abae28 100644 --- a/contrib/libs/grpc/src/compiler/grpc_plugin_support/ya.make +++ b/contrib/libs/grpc/src/compiler/grpc_plugin_support/ya.make @@ -2,8 +2,8 @@ LIBRARY() -WITHOUT_LICENSE_TEXTS() - +WITHOUT_LICENSE_TEXTS() + OWNER(g:cpp-contrib) LICENSE(Apache-2.0) @@ -15,7 +15,7 @@ PEERDIR( ADDINCL( GLOBAL contrib/libs/grpc/include - ${ARCADIA_BUILD_ROOT}/contrib/libs/grpc + ${ARCADIA_BUILD_ROOT}/contrib/libs/grpc contrib/libs/grpc ) @@ -24,9 +24,9 @@ NO_COMPILER_WARNINGS() SRCDIR(contrib/libs/grpc/src/compiler) IF (OS_LINUX OR OS_DARWIN) - CFLAGS( - -DGRPC_POSIX_FORK_ALLOW_PTHREAD_ATFORK=1 - ) + CFLAGS( + -DGRPC_POSIX_FORK_ALLOW_PTHREAD_ATFORK=1 + ) ENDIF() SRCS( 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 cf2a106c915..351fab1a2f3 100644 --- a/contrib/libs/grpc/src/compiler/grpc_python_plugin/ya.make +++ b/contrib/libs/grpc/src/compiler/grpc_python_plugin/ya.make @@ -2,8 +2,8 @@ PROGRAM() -WITHOUT_LICENSE_TEXTS() - +WITHOUT_LICENSE_TEXTS() + OWNER(g:cpp-contrib) LICENSE(Apache-2.0) @@ -14,7 +14,7 @@ PEERDIR( ) ADDINCL( - ${ARCADIA_BUILD_ROOT}/contrib/libs/grpc + ${ARCADIA_BUILD_ROOT}/contrib/libs/grpc contrib/libs/grpc contrib/libs/grpc/include ) @@ -24,9 +24,9 @@ NO_COMPILER_WARNINGS() SRCDIR(contrib/libs/grpc/src/compiler) IF (OS_LINUX OR OS_DARWIN) - CFLAGS( - -DGRPC_POSIX_FORK_ALLOW_PTHREAD_ATFORK=1 - ) + CFLAGS( + -DGRPC_POSIX_FORK_ALLOW_PTHREAD_ATFORK=1 + ) ENDIF() SRCS( diff --git a/contrib/libs/grpc/src/compiler/node_generator.cc b/contrib/libs/grpc/src/compiler/node_generator.cc index 89e4871a660..12ac3a9727c 100644 --- a/contrib/libs/grpc/src/compiler/node_generator.cc +++ b/contrib/libs/grpc/src/compiler/node_generator.cc @@ -37,7 +37,7 @@ namespace { // Returns the alias we assign to the module of the given .proto filename // when importing. Copied entirely from // github:google/protobuf/src/google/protobuf/compiler/js/js_generator.cc#L154 -TString ModuleAlias(const TString filename) { +TString ModuleAlias(const TString filename) { // This scheme could technically cause problems if a file includes any 2 of: // foo/bar_baz.proto // foo_bar_baz.proto @@ -45,7 +45,7 @@ TString ModuleAlias(const TString filename) { // // We'll worry about this problem if/when we actually see it. This name isn't // exposed to users so we can change it later if we need to. - TString basename = grpc_generator::StripProto(filename); + TString basename = grpc_generator::StripProto(filename); basename = grpc_generator::StringReplace(basename, "-", "$"); basename = grpc_generator::StringReplace(basename, "/", "_"); basename = grpc_generator::StringReplace(basename, ".", "_"); @@ -54,15 +54,15 @@ TString ModuleAlias(const TString filename) { // Given a filename like foo/bar/baz.proto, returns the corresponding JavaScript // message file foo/bar/baz.js -TString GetJSMessageFilename(const TString& filename) { - TString name = filename; +TString GetJSMessageFilename(const TString& filename) { + TString name = filename; return grpc_generator::StripProto(name) + "_pb.js"; } // Given a filename like foo/bar/baz.proto, returns the root directory // path ../../ -TString GetRootPath(const TString& from_filename, - const TString& to_filename) { +TString GetRootPath(const TString& from_filename, + const TString& to_filename) { if (to_filename.find("google/protobuf") == 0) { // Well-known types (.proto files in the google/protobuf directory) are // assumed to come from the 'google-protobuf' npm package. We may want to @@ -74,7 +74,7 @@ TString GetRootPath(const TString& from_filename, if (slashes == 0) { return "./"; } - TString result = ""; + TString result = ""; for (size_t i = 0; i < slashes; i++) { result += "../"; } @@ -83,15 +83,15 @@ TString GetRootPath(const TString& from_filename, // Return the relative path to load to_file from the directory containing // from_file, assuming that both paths are relative to the same directory -TString GetRelativePath(const TString& from_file, - const TString& to_file) { +TString GetRelativePath(const TString& from_file, + const TString& to_file) { return GetRootPath(from_file, to_file) + to_file; } /* Finds all message types used in all services in the file, and returns them * as a map of fully qualified message type name to message descriptor */ -map<TString, const Descriptor*> GetAllMessages(const FileDescriptor* file) { - map<TString, const Descriptor*> message_types; +map<TString, const Descriptor*> GetAllMessages(const FileDescriptor* file) { + map<TString, const Descriptor*> message_types; for (int service_num = 0; service_num < file->service_count(); service_num++) { const ServiceDescriptor* service = file->service(service_num); @@ -107,13 +107,13 @@ map<TString, const Descriptor*> GetAllMessages(const FileDescriptor* file) { return message_types; } -TString MessageIdentifierName(const TString& name) { +TString MessageIdentifierName(const TString& name) { return grpc_generator::StringReplace(name, ".", "_"); } -TString NodeObjectPath(const Descriptor* descriptor) { - TString module_alias = ModuleAlias(descriptor->file()->name()); - TString name = descriptor->full_name(); +TString NodeObjectPath(const Descriptor* descriptor) { + TString module_alias = ModuleAlias(descriptor->file()->name()); + TString name = descriptor->full_name(); grpc_generator::StripPrefix(&name, descriptor->file()->package() + "."); return module_alias + "." + name; } @@ -121,8 +121,8 @@ TString NodeObjectPath(const Descriptor* descriptor) { // Prints out the message serializer and deserializer functions void PrintMessageTransformer(const Descriptor* descriptor, Printer* out, const Parameters& params) { - map<TString, TString> template_vars; - TString full_name = descriptor->full_name(); + map<TString, TString> template_vars; + TString full_name = descriptor->full_name(); template_vars["identifier_name"] = MessageIdentifierName(full_name); template_vars["name"] = full_name; template_vars["node_name"] = NodeObjectPath(descriptor); @@ -158,7 +158,7 @@ void PrintMessageTransformer(const Descriptor* descriptor, Printer* out, void PrintMethod(const MethodDescriptor* method, Printer* out) { const Descriptor* input_type = method->input_type(); const Descriptor* output_type = method->output_type(); - map<TString, TString> vars; + map<TString, TString> vars; vars["service_name"] = method->service()->full_name(); vars["name"] = method->name(); vars["input_type"] = NodeObjectPath(input_type); @@ -184,13 +184,13 @@ void PrintMethod(const MethodDescriptor* method, Printer* out) { // Prints out the service descriptor object void PrintService(const ServiceDescriptor* service, Printer* out) { - map<TString, TString> template_vars; + map<TString, TString> template_vars; out->Print(GetNodeComments(service, true).c_str()); template_vars["name"] = service->name(); out->Print(template_vars, "var $name$Service = exports.$name$Service = {\n"); out->Indent(); for (int i = 0; i < service->method_count(); i++) { - TString method_name = + TString method_name = grpc_generator::LowercaseFirstLetter(service->method(i)->name()); out->Print(GetNodeComments(service->method(i), true).c_str()); out->Print("$method_name$: ", "method_name", method_name); @@ -209,14 +209,14 @@ void PrintService(const ServiceDescriptor* service, Printer* out) { void PrintImports(const FileDescriptor* file, Printer* out) { out->Print("var grpc = require('grpc');\n"); if (file->message_type_count() > 0) { - TString file_path = + TString file_path = GetRelativePath(file->name(), GetJSMessageFilename(file->name())); out->Print("var $module_alias$ = require('$file_path$');\n", "module_alias", ModuleAlias(file->name()), "file_path", file_path); } for (int i = 0; i < file->dependency_count(); i++) { - TString file_path = GetRelativePath( + TString file_path = GetRelativePath( file->name(), GetJSMessageFilename(file->dependency(i)->name())); out->Print("var $module_alias$ = require('$file_path$');\n", "module_alias", ModuleAlias(file->dependency(i)->name()), "file_path", @@ -227,8 +227,8 @@ void PrintImports(const FileDescriptor* file, Printer* out) { void PrintTransformers(const FileDescriptor* file, Printer* out, const Parameters& params) { - map<TString, const Descriptor*> messages = GetAllMessages(file); - for (std::map<TString, const Descriptor*>::iterator it = messages.begin(); + map<TString, const Descriptor*> messages = GetAllMessages(file); + for (std::map<TString, const Descriptor*>::iterator it = messages.begin(); it != messages.end(); it++) { PrintMessageTransformer(it->second, out, params); } @@ -242,8 +242,8 @@ void PrintServices(const FileDescriptor* file, Printer* out) { } } // namespace -TString GenerateFile(const FileDescriptor* file, const Parameters& params) { - TString output; +TString GenerateFile(const FileDescriptor* file, const Parameters& params) { + TString output; { StringOutputStream output_stream(&output); Printer out(&output_stream, '$'); @@ -253,7 +253,7 @@ TString GenerateFile(const FileDescriptor* file, const Parameters& params) { } out.Print("// GENERATED CODE -- DO NOT EDIT!\n\n"); - TString leading_comments = GetNodeComments(file, true); + TString leading_comments = GetNodeComments(file, true); if (!leading_comments.empty()) { out.Print("// Original file comments:\n"); out.PrintRaw(leading_comments.c_str()); diff --git a/contrib/libs/grpc/src/compiler/node_generator.h b/contrib/libs/grpc/src/compiler/node_generator.h index 959df436ea5..5361552d5d5 100644 --- a/contrib/libs/grpc/src/compiler/node_generator.h +++ b/contrib/libs/grpc/src/compiler/node_generator.h @@ -29,8 +29,8 @@ struct Parameters { int minimum_node_version; }; -TString GenerateFile(const grpc::protobuf::FileDescriptor* file, - const Parameters& params); +TString GenerateFile(const grpc::protobuf::FileDescriptor* file, + const Parameters& params); } // namespace grpc_node_generator diff --git a/contrib/libs/grpc/src/compiler/node_generator_helpers.h b/contrib/libs/grpc/src/compiler/node_generator_helpers.h index ccf57ec8a62..ce380cecc2e 100644 --- a/contrib/libs/grpc/src/compiler/node_generator_helpers.h +++ b/contrib/libs/grpc/src/compiler/node_generator_helpers.h @@ -26,14 +26,14 @@ namespace grpc_node_generator { -inline TString GetJSServiceFilename(const TString& filename) { +inline TString GetJSServiceFilename(const TString& filename) { return grpc_generator::StripProto(filename) + "_grpc_pb.js"; } // Get leading or trailing comments in a string. Comment lines start with "// ". // Leading detached comments are put in front of leading comments. template <typename DescriptorType> -inline TString GetNodeComments(const DescriptorType* desc, bool leading) { +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 07826b6a8d8..66a473705ae 100644 --- a/contrib/libs/grpc/src/compiler/objective_c_generator.cc +++ b/contrib/libs/grpc/src/compiler/objective_c_generator.cc @@ -37,9 +37,9 @@ using ::std::set; namespace grpc_objective_c_generator { namespace { -void PrintProtoRpcDeclarationAsPragma(Printer* printer, - const MethodDescriptor* method, - map< ::TString, ::TString> vars) { +void PrintProtoRpcDeclarationAsPragma(Printer* printer, + const MethodDescriptor* method, + map< ::TString, ::TString> vars) { vars["client_stream"] = method->client_streaming() ? "stream " : ""; vars["server_stream"] = method->server_streaming() ? "stream " : ""; @@ -51,7 +51,7 @@ void PrintProtoRpcDeclarationAsPragma(Printer* printer, template <typename DescriptorType> static void PrintAllComments(const DescriptorType* desc, Printer* printer, bool deprecated = false) { - std::vector<TString> comments; + std::vector<TString> comments; grpc_generator::GetComment(desc, grpc_generator::COMMENTTYPE_LEADING_DETACHED, &comments); grpc_generator::GetComment(desc, grpc_generator::COMMENTTYPE_LEADING, @@ -65,7 +65,7 @@ static void PrintAllComments(const DescriptorType* desc, Printer* printer, for (auto it = comments.begin(); it != comments.end(); ++it) { printer->Print(" * "); size_t start_pos = it->find_first_not_of(' '); - if (start_pos != TString::npos) { + if (start_pos != TString::npos) { printer->PrintRaw(it->c_str() + start_pos); } printer->Print("\n"); @@ -81,7 +81,7 @@ static void PrintAllComments(const DescriptorType* desc, Printer* printer, } void PrintMethodSignature(Printer* printer, const MethodDescriptor* method, - const map< ::TString, ::TString>& vars) { + const map< ::TString, ::TString>& vars) { // Print comment PrintAllComments(method, printer, true); @@ -106,7 +106,7 @@ void PrintMethodSignature(Printer* printer, const MethodDescriptor* method, } void PrintSimpleSignature(Printer* printer, const MethodDescriptor* method, - map< ::TString, ::TString> vars) { + map< ::TString, ::TString> vars) { vars["method_name"] = grpc_generator::LowercaseFirstLetter(vars["method_name"]); vars["return_type"] = "void"; @@ -114,14 +114,14 @@ void PrintSimpleSignature(Printer* printer, const MethodDescriptor* method, } void PrintAdvancedSignature(Printer* printer, const MethodDescriptor* method, - map< ::TString, ::TString> vars) { + map< ::TString, ::TString> vars) { vars["method_name"] = "RPCTo" + vars["method_name"]; vars["return_type"] = "GRPCProtoCall *"; PrintMethodSignature(printer, method, vars); } void PrintV2Signature(Printer* printer, const MethodDescriptor* method, - map< ::TString, ::TString> vars) { + map< ::TString, ::TString> vars) { if (method->client_streaming()) { vars["return_type"] = "GRPCStreamingProtoCall *"; } else { @@ -143,9 +143,9 @@ void PrintV2Signature(Printer* printer, const MethodDescriptor* method, printer->Print(" callOptions:(GRPCCallOptions *_Nullable)callOptions"); } -inline map< ::TString, ::TString> GetMethodVars( +inline map< ::TString, ::TString> GetMethodVars( const MethodDescriptor* method) { - map< ::TString, ::TString> res; + map< ::TString, ::TString> res; res["method_name"] = method->name(); res["request_type"] = method->input_type()->name(); res["response_type"] = method->output_type()->name(); @@ -155,7 +155,7 @@ inline map< ::TString, ::TString> GetMethodVars( } void PrintMethodDeclarations(Printer* printer, const MethodDescriptor* method) { - map< ::TString, ::TString> vars = GetMethodVars(method); + map< ::TString, ::TString> vars = GetMethodVars(method); PrintProtoRpcDeclarationAsPragma(printer, method, vars); @@ -167,7 +167,7 @@ void PrintMethodDeclarations(Printer* printer, const MethodDescriptor* method) { void PrintV2MethodDeclarations(Printer* printer, const MethodDescriptor* method) { - map< ::TString, ::TString> vars = GetMethodVars(method); + map< ::TString, ::TString> vars = GetMethodVars(method); PrintProtoRpcDeclarationAsPragma(printer, method, vars); @@ -176,7 +176,7 @@ void PrintV2MethodDeclarations(Printer* printer, } void PrintSimpleImplementation(Printer* printer, const MethodDescriptor* method, - map< ::TString, ::TString> vars) { + map< ::TString, ::TString> vars) { printer->Print("{\n"); printer->Print(vars, " [[self RPCTo$method_name$With"); if (method->client_streaming()) { @@ -194,7 +194,7 @@ void PrintSimpleImplementation(Printer* printer, const MethodDescriptor* method, void PrintAdvancedImplementation(Printer* printer, const MethodDescriptor* method, - map< ::TString, ::TString> vars) { + map< ::TString, ::TString> vars) { printer->Print("{\n"); printer->Print(vars, " return [self RPCToMethod:@\"$method_name$\"\n"); @@ -218,7 +218,7 @@ void PrintAdvancedImplementation(Printer* printer, } void PrintV2Implementation(Printer* printer, const MethodDescriptor* method, - map< ::TString, ::TString> vars) { + map< ::TString, ::TString> vars) { printer->Print(" {\n"); if (method->client_streaming()) { printer->Print(vars, " return [self RPCToMethod:@\"$method_name$\"\n"); @@ -239,7 +239,7 @@ void PrintV2Implementation(Printer* printer, const MethodDescriptor* method, void PrintMethodImplementations(Printer* printer, const MethodDescriptor* method, const Parameters& generator_params) { - map< ::TString, ::TString> vars = GetMethodVars(method); + map< ::TString, ::TString> vars = GetMethodVars(method); PrintProtoRpcDeclarationAsPragma(printer, method, vars); @@ -259,9 +259,9 @@ void PrintMethodImplementations(Printer* printer, } // namespace -::TString GetAllMessageClasses(const FileDescriptor* file) { - ::TString output; - set< ::TString> classes; +::TString GetAllMessageClasses(const FileDescriptor* file) { + ::TString output; + set< ::TString> classes; for (int i = 0; i < file->service_count(); i++) { const auto service = file->service(i); for (int i = 0; i < service->method_count(); i++) { @@ -277,9 +277,9 @@ void PrintMethodImplementations(Printer* printer, return output; } -::TString GetProtocol(const ServiceDescriptor* service, - const Parameters& generator_params) { - ::TString output; +::TString GetProtocol(const ServiceDescriptor* service, + const Parameters& generator_params) { + ::TString output; if (generator_params.no_v1_compatibility) return output; @@ -287,7 +287,7 @@ void PrintMethodImplementations(Printer* printer, grpc::protobuf::io::StringOutputStream output_stream(&output); Printer printer(&output_stream, '$'); - map< ::TString, ::TString> vars = { + map< ::TString, ::TString> vars = { {"service_class", ServiceClassName(service)}}; printer.Print(vars, @@ -306,14 +306,14 @@ void PrintMethodImplementations(Printer* printer, return output; } -::TString GetV2Protocol(const ServiceDescriptor* service) { - ::TString output; +::TString GetV2Protocol(const ServiceDescriptor* service) { + ::TString 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, '$'); - map< ::TString, ::TString> vars = { + map< ::TString, ::TString> vars = { {"service_class", ServiceClassName(service) + "2"}}; printer.Print(vars, "@protocol $service_class$ <NSObject>\n\n"); @@ -325,15 +325,15 @@ void PrintMethodImplementations(Printer* printer, return output; } -::TString GetInterface(const ServiceDescriptor* service, - const Parameters& generator_params) { - ::TString output; +::TString GetInterface(const ServiceDescriptor* service, + const Parameters& generator_params) { + ::TString 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, '$'); - map< ::TString, ::TString> vars = { + map< ::TString, ::TString> vars = { {"service_class", ServiceClassName(service)}}; printer.Print(vars, @@ -368,15 +368,15 @@ void PrintMethodImplementations(Printer* printer, return output; } -::TString GetSource(const ServiceDescriptor* service, - const Parameters& generator_params) { - ::TString output; +::TString GetSource(const ServiceDescriptor* service, + const Parameters& generator_params) { + ::TString 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, '$'); - map< ::TString, ::TString> vars = { + map< ::TString, ::TString> vars = { {"service_name", service->name()}, {"service_class", ServiceClassName(service)}, {"package", service->file()->package()}}; diff --git a/contrib/libs/grpc/src/compiler/objective_c_generator.h b/contrib/libs/grpc/src/compiler/objective_c_generator.h index 9770f65436d..e1d5bdc1604 100644 --- a/contrib/libs/grpc/src/compiler/objective_c_generator.h +++ b/contrib/libs/grpc/src/compiler/objective_c_generator.h @@ -30,7 +30,7 @@ struct Parameters { using ::grpc::protobuf::FileDescriptor; using ::grpc::protobuf::ServiceDescriptor; -using ::TString; +using ::TString; // Returns forward declaration of classes in the generated header file. string GetAllMessageClasses(const FileDescriptor* file); 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 ae296741cec..9ad3773ac23 100644 --- a/contrib/libs/grpc/src/compiler/objective_c_generator_helpers.h +++ b/contrib/libs/grpc/src/compiler/objective_c_generator_helpers.h @@ -29,7 +29,7 @@ namespace grpc_objective_c_generator { using ::grpc::protobuf::FileDescriptor; using ::grpc::protobuf::ServiceDescriptor; -using ::TString; +using ::TString; inline string MessageHeaderName(const FileDescriptor* file) { return google::protobuf::compiler::objectivec::FilePath(file) + ".pbobjc.h"; @@ -41,53 +41,53 @@ inline string ServiceClassName(const ServiceDescriptor* service) { return prefix + service->name(); } -inline ::TString LocalImport(const ::TString& import) { - return ::TString("#import \"" + import + "\"\n"); +inline ::TString LocalImport(const ::TString& import) { + return ::TString("#import \"" + import + "\"\n"); } -inline ::TString FrameworkImport(const ::TString& import, - const ::TString& framework) { +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 - ::TString filename = import.substr(pos + 1, import.size() - (pos + 1)); - return ::TString("#import <" + framework + "/" + filename + ">\n"); + ::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"); +inline ::TString SystemImport(const ::TString& import) { + return ::TString("#import <" + import + ">\n"); } -inline ::TString PreprocConditional(::TString symbol, bool invert) { +inline ::TString PreprocConditional(::TString symbol, bool invert) { return invert ? "!defined(" + symbol + ") || !" + symbol : "defined(" + symbol + ") && " + symbol; } -inline ::TString PreprocIf(const ::TString& symbol, - const ::TString& if_true) { - return ::TString("#if " + PreprocConditional(symbol, false) + "\n" + - if_true + "#endif\n"); +inline ::TString PreprocIf(const ::TString& symbol, + const ::TString& if_true) { + return ::TString("#if " + PreprocConditional(symbol, false) + "\n" + + if_true + "#endif\n"); } -inline ::TString PreprocIfNot(const ::TString& symbol, - const ::TString& if_true) { - return ::TString("#if " + PreprocConditional(symbol, true) + "\n" + - if_true + "#endif\n"); +inline ::TString PreprocIfNot(const ::TString& symbol, + const ::TString& if_true) { + return ::TString("#if " + PreprocConditional(symbol, true) + "\n" + + if_true + "#endif\n"); } -inline ::TString PreprocIfElse(const ::TString& symbol, - const ::TString& if_true, - const ::TString& if_false) { - return ::TString("#if " + PreprocConditional(symbol, false) + "\n" + - if_true + "#else\n" + if_false + "#endif\n"); +inline ::TString PreprocIfElse(const ::TString& symbol, + const ::TString& if_true, + const ::TString& if_false) { + return ::TString("#if " + PreprocConditional(symbol, false) + "\n" + + if_true + "#else\n" + if_false + "#endif\n"); } -inline ::TString PreprocIfNotElse(const ::TString& symbol, - const ::TString& if_true, - const ::TString& if_false) { - return ::TString("#if " + PreprocConditional(symbol, true) + "\n" + - if_true + "#else\n" + if_false + "#endif\n"); +inline ::TString PreprocIfNotElse(const ::TString& symbol, + const ::TString& if_true, + const ::TString& if_false) { + return ::TString("#if " + PreprocConditional(symbol, true) + "\n" + + if_true + "#else\n" + if_false + "#endif\n"); } } // namespace grpc_objective_c_generator diff --git a/contrib/libs/grpc/src/compiler/php_generator.cc b/contrib/libs/grpc/src/compiler/php_generator.cc index b35d3f2a02e..fccd99aefb5 100644 --- a/contrib/libs/grpc/src/compiler/php_generator.cc +++ b/contrib/libs/grpc/src/compiler/php_generator.cc @@ -35,8 +35,8 @@ using std::map; namespace grpc_php_generator { namespace { -TString ConvertToPhpNamespace(const TString& name) { - std::vector<TString> tokens = grpc_generator::tokenize(name, "."); +TString ConvertToPhpNamespace(const TString& name) { + std::vector<TString> tokens = grpc_generator::tokenize(name, "."); std::ostringstream oss; for (unsigned int i = 0; i < tokens.size(); i++) { oss << (i == 0 ? "" : "\\") @@ -45,7 +45,7 @@ TString ConvertToPhpNamespace(const TString& name) { return oss.str(); } -TString PackageName(const FileDescriptor* file) { +TString PackageName(const FileDescriptor* file) { if (file->options().has_php_namespace()) { return file->options().php_namespace(); } else { @@ -53,9 +53,9 @@ TString PackageName(const FileDescriptor* file) { } } -TString MessageIdentifierName(const TString& name, - const FileDescriptor* file) { - std::vector<TString> tokens = grpc_generator::tokenize(name, "."); +TString MessageIdentifierName(const TString& name, + const FileDescriptor* file) { + std::vector<TString> tokens = grpc_generator::tokenize(name, "."); std::ostringstream oss; if (PackageName(file) != "") { oss << PackageName(file) << "\\"; @@ -67,7 +67,7 @@ TString MessageIdentifierName(const TString& name, void PrintMethod(const MethodDescriptor* method, Printer* out) { const Descriptor* input_type = method->input_type(); const Descriptor* output_type = method->output_type(); - map<TString, TString> vars; + map<TString, TString> vars; vars["service_name"] = method->service()->full_name(); vars["name"] = method->name(); vars["input_type_id"] = @@ -78,15 +78,15 @@ void PrintMethod(const MethodDescriptor* method, Printer* out) { out->Print("/**\n"); out->Print(GetPHPComments(method, " *").c_str()); if (method->client_streaming()) { - if (method->server_streaming()) { - vars["return_type_id"] = "\\Grpc\\BidiStreamingCall"; - } else { - vars["return_type_id"] = "\\Grpc\\ClientStreamingCall"; - } + if (method->server_streaming()) { + vars["return_type_id"] = "\\Grpc\\BidiStreamingCall"; + } else { + vars["return_type_id"] = "\\Grpc\\ClientStreamingCall"; + } out->Print(vars, " * @param array $$metadata metadata\n" - " * @param array $$options call options\n" - " * @return $return_type_id$\n */\n" + " * @param array $$options call options\n" + " * @return $return_type_id$\n */\n" "public function $name$($$metadata = [], " "$$options = []) {\n"); out->Indent(); @@ -101,16 +101,16 @@ void PrintMethod(const MethodDescriptor* method, Printer* out) { "['\\$output_type_id$','decode'],\n" "$$metadata, $$options);\n"); } else { - if (method->server_streaming()) { - vars["return_type_id"] = "\\Grpc\\ServerStreamingCall"; - } else { - vars["return_type_id"] = "\\Grpc\\UnaryCall"; - } + if (method->server_streaming()) { + vars["return_type_id"] = "\\Grpc\\ServerStreamingCall"; + } else { + vars["return_type_id"] = "\\Grpc\\UnaryCall"; + } out->Print(vars, " * @param \\$input_type_id$ $$argument input argument\n" " * @param array $$metadata metadata\n" - " * @param array $$options call options\n" - " * @return $return_type_id$\n */\n" + " * @param array $$options call options\n" + " * @return $return_type_id$\n */\n" "public function $name$(\\$input_type_id$ $$argument,\n" " $$metadata = [], $$options = []) {\n"); out->Indent(); @@ -133,8 +133,8 @@ void PrintMethod(const MethodDescriptor* method, Printer* out) { // Prints out the service descriptor object void PrintService(const ServiceDescriptor* service, - const TString& class_suffix, Printer* out) { - map<TString, TString> vars; + const TString& class_suffix, Printer* out) { + map<TString, TString> vars; out->Print("/**\n"); out->Print(GetPHPComments(service, " *").c_str()); out->Print(" */\n"); @@ -156,7 +156,7 @@ void PrintService(const ServiceDescriptor* service, out->Outdent(); out->Print("}\n\n"); for (int i = 0; i < service->method_count(); i++) { - TString method_name = + TString method_name = grpc_generator::LowercaseFirstLetter(service->method(i)->name()); PrintMethod(service->method(i), out); } @@ -166,10 +166,10 @@ void PrintService(const ServiceDescriptor* service, } } // namespace -TString GenerateFile(const FileDescriptor* file, - const ServiceDescriptor* service, - const TString& class_suffix) { - TString output; +TString GenerateFile(const FileDescriptor* file, + const ServiceDescriptor* service, + const TString& class_suffix) { + TString output; { StringOutputStream output_stream(&output); Printer out(&output_stream, '$'); @@ -177,14 +177,14 @@ TString GenerateFile(const FileDescriptor* file, out.Print("<?php\n"); out.Print("// GENERATED CODE -- DO NOT EDIT!\n\n"); - TString leading_comments = GetPHPComments(file, "//"); + TString leading_comments = GetPHPComments(file, "//"); if (!leading_comments.empty()) { out.Print("// Original file comments:\n"); out.PrintRaw(leading_comments.c_str()); } - map<TString, TString> vars; - TString php_namespace = PackageName(file); + map<TString, TString> vars; + TString php_namespace = PackageName(file); vars["package"] = php_namespace; out.Print(vars, "namespace $package$;\n\n"); diff --git a/contrib/libs/grpc/src/compiler/php_generator_helpers.h b/contrib/libs/grpc/src/compiler/php_generator_helpers.h index 70a31eaf75e..985326fdb2e 100644 --- a/contrib/libs/grpc/src/compiler/php_generator_helpers.h +++ b/contrib/libs/grpc/src/compiler/php_generator_helpers.h @@ -26,32 +26,32 @@ namespace grpc_php_generator { -inline TString GetPHPServiceClassname( +inline TString GetPHPServiceClassname( const grpc::protobuf::ServiceDescriptor* service, - const TString& class_suffix) { + const TString& class_suffix) { return service->name() + (class_suffix == "" ? "Client" : class_suffix); } // ReplaceAll replaces all instances of search with replace in s. -inline TString ReplaceAll(TString s, const TString& search, - const TString& replace) { +inline TString ReplaceAll(TString s, const TString& search, + const TString& replace) { size_t pos = 0; - while ((pos = s.find(search, pos)) != TString::npos) { + while ((pos = s.find(search, pos)) != TString::npos) { s.replace(pos, search.length(), replace); pos += replace.length(); } return s; } -inline TString GetPHPServiceFilename( +inline TString GetPHPServiceFilename( const grpc::protobuf::FileDescriptor* file, const grpc::protobuf::ServiceDescriptor* service, - const TString& class_suffix) { + const TString& class_suffix) { std::ostringstream oss; if (file->options().has_php_namespace()) { oss << ReplaceAll(file->options().php_namespace(), "\\", "/"); } else { - std::vector<TString> tokens = + std::vector<TString> tokens = grpc_generator::tokenize(file->package(), "."); for (unsigned int i = 0; i < tokens.size(); i++) { oss << (i == 0 ? "" : "/") @@ -65,8 +65,8 @@ 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. template <typename DescriptorType> -inline TString GetPHPComments(const DescriptorType* desc, - TString prefix) { +inline TString GetPHPComments(const DescriptorType* desc, + TString prefix) { return ReplaceAll(grpc_generator::GetPrefixedComments(desc, true, prefix), "*/", "*/"); } diff --git a/contrib/libs/grpc/src/compiler/protobuf_plugin.h b/contrib/libs/grpc/src/compiler/protobuf_plugin.h index ef844ea0551..f7df4d7b7e1 100644 --- a/contrib/libs/grpc/src/compiler/protobuf_plugin.h +++ b/contrib/libs/grpc/src/compiler/protobuf_plugin.h @@ -29,8 +29,8 @@ // Get leading or trailing comments in a string. template <typename DescriptorType> -inline TString GetCommentsHelper(const DescriptorType* desc, bool leading, - const TString& prefix) { +inline TString GetCommentsHelper(const DescriptorType* desc, bool leading, + const TString& prefix) { return grpc_generator::GetPrefixedComments(desc, leading, prefix); } @@ -39,36 +39,36 @@ class ProtoBufMethod : public grpc_generator::Method { ProtoBufMethod(const grpc::protobuf::MethodDescriptor* method) : method_(method) {} - TString name() const { return method_->name(); } + TString name() const { return method_->name(); } - TString input_type_name() const { + TString input_type_name() const { return grpc_cpp_generator::ClassName(method_->input_type(), true); } - TString output_type_name() const { + TString output_type_name() const { return grpc_cpp_generator::ClassName(method_->output_type(), true); } - TString get_input_type_name() const { + TString get_input_type_name() const { return method_->input_type()->file()->name(); } - TString get_output_type_name() const { + TString get_output_type_name() const { return method_->output_type()->file()->name(); } // 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 { + 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); } 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 { + 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); @@ -86,15 +86,15 @@ class ProtoBufMethod : public grpc_generator::Method { return method_->client_streaming() && method_->server_streaming(); } - TString GetLeadingComments(const TString prefix) const { + TString GetLeadingComments(const TString prefix) const { return GetCommentsHelper(method_, true, prefix); } - TString GetTrailingComments(const TString prefix) const { + TString GetTrailingComments(const TString prefix) const { return GetCommentsHelper(method_, false, prefix); } - vector<TString> GetAllComments() const { + vector<TString> GetAllComments() const { return grpc_python_generator::get_all_comments(method_); } @@ -107,7 +107,7 @@ class ProtoBufService : public grpc_generator::Service { ProtoBufService(const grpc::protobuf::ServiceDescriptor* service) : service_(service) {} - TString name() const { return service_->name(); } + TString name() const { return service_->name(); } int method_count() const { return service_->method_count(); } std::unique_ptr<const grpc_generator::Method> method(int i) const { @@ -115,15 +115,15 @@ class ProtoBufService : public grpc_generator::Service { new ProtoBufMethod(service_->method(i))); } - TString GetLeadingComments(const TString prefix) const { + TString GetLeadingComments(const TString prefix) const { return GetCommentsHelper(service_, true, prefix); } - TString GetTrailingComments(const TString prefix) const { + TString GetTrailingComments(const TString prefix) const { return GetCommentsHelper(service_, false, prefix); } - vector<TString> GetAllComments() const { + vector<TString> GetAllComments() const { return grpc_python_generator::get_all_comments(service_); } @@ -133,10 +133,10 @@ class ProtoBufService : public grpc_generator::Service { class ProtoBufPrinter : public grpc_generator::Printer { public: - ProtoBufPrinter(TString* str) + ProtoBufPrinter(TString* str) : output_stream_(str), printer_(&output_stream_, '$') {} - void Print(const std::map<TString, TString>& vars, + void Print(const std::map<TString, TString>& vars, const char* string_template) { printer_.Print(vars, string_template); } @@ -155,17 +155,17 @@ class ProtoBufFile : public grpc_generator::File { public: ProtoBufFile(const grpc::protobuf::FileDescriptor* file) : file_(file) {} - TString filename() const { return file_->name(); } - TString filename_without_ext() const { + TString filename() const { return file_->name(); } + TString filename_without_ext() const { return grpc_generator::StripProto(filename()); } - TString package() const { return file_->package(); } - std::vector<TString> package_parts() const { + TString package() const { return file_->package(); } + std::vector<TString> package_parts() const { return grpc_generator::tokenize(package(), "."); } - TString additional_headers() const { return ""; } + TString additional_headers() const { return ""; } int service_count() const { return file_->service_count(); } std::unique_ptr<const grpc_generator::Service> service(int i) const { @@ -174,24 +174,24 @@ class ProtoBufFile : public grpc_generator::File { } std::unique_ptr<grpc_generator::Printer> CreatePrinter( - TString* str) const { + TString* str) const { return std::unique_ptr<grpc_generator::Printer>(new ProtoBufPrinter(str)); } - TString GetLeadingComments(const TString prefix) const { + TString GetLeadingComments(const TString prefix) const { return GetCommentsHelper(file_, true, prefix); } - TString GetTrailingComments(const TString prefix) const { + TString GetTrailingComments(const TString prefix) const { return GetCommentsHelper(file_, false, prefix); } - vector<TString> GetAllComments() const { + vector<TString> GetAllComments() const { return grpc_python_generator::get_all_comments(file_); } - vector<TString> GetImportNames() const { - vector<TString> proto_names; + 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()); diff --git a/contrib/libs/grpc/src/compiler/python_generator.cc b/contrib/libs/grpc/src/compiler/python_generator.cc index d083d19f0b3..57d7b6152e9 100644 --- a/contrib/libs/grpc/src/compiler/python_generator.cc +++ b/contrib/libs/grpc/src/compiler/python_generator.cc @@ -51,13 +51,13 @@ using std::vector; namespace grpc_python_generator { -TString generator_file_name; +TString generator_file_name; namespace { -typedef map<TString, TString> StringMap; -typedef vector<TString> StringVector; -typedef tuple<TString, TString> StringPair; +typedef map<TString, TString> StringMap; +typedef vector<TString> StringVector; +typedef tuple<TString, TString> StringPair; typedef set<StringPair> StringPairSet; // Provides RAII indentation handling. Use as: @@ -70,16 +70,16 @@ typedef set<StringPair> StringPairSet; class IndentScope { public: explicit IndentScope(grpc_generator::Printer* printer) : printer_(printer) { - // NOTE(rbellevi): Two-space tabs are hard-coded in the protocol compiler. - // Doubling our indents and outdents guarantees compliance with PEP8. - printer_->Indent(); + // NOTE(rbellevi): Two-space tabs are hard-coded in the protocol compiler. + // Doubling our indents and outdents guarantees compliance with PEP8. printer_->Indent(); + printer_->Indent(); } - ~IndentScope() { - printer_->Outdent(); - printer_->Outdent(); - } + ~IndentScope() { + printer_->Outdent(); + printer_->Outdent(); + } private: grpc_generator::Printer* printer_; @@ -98,16 +98,16 @@ void PrivateGenerator::PrintAllComments(StringVector comments, // smarter and more sophisticated, but at the moment, if there is // no docstring to print, we simply emit "pass" to ensure validity // of the generated code. - out->Print( - "\"\"\"Missing associated documentation comment in .proto " - "file.\"\"\"\n"); + out->Print( + "\"\"\"Missing associated documentation comment in .proto " + "file.\"\"\"\n"); return; } out->Print("\"\"\""); for (StringVector::iterator it = comments.begin(); it != comments.end(); ++it) { size_t start_pos = it->find_first_not_of(' '); - if (start_pos != TString::npos) { + if (start_pos != TString::npos) { out->PrintRaw(it->c_str() + start_pos); } out->Print("\n"); @@ -134,7 +134,7 @@ bool PrivateGenerator::PrintBetaServicer(const grpc_generator::Service* service, PrintAllComments(service_comments, out); for (int i = 0; i < service->method_count(); ++i) { auto method = service->method(i); - TString arg_name = + TString arg_name = method->ClientStreaming() ? "request_iterator" : "request"; StringMap method_dict; method_dict["Method"] = method->name(); @@ -170,7 +170,7 @@ bool PrivateGenerator::PrintBetaStub(const grpc_generator::Service* service, PrintAllComments(service_comments, out); for (int i = 0; i < service->method_count(); ++i) { auto method = service->method(i); - TString arg_name = + TString arg_name = method->ClientStreaming() ? "request_iterator" : "request"; StringMap method_dict; method_dict["Method"] = method->name(); @@ -193,7 +193,7 @@ bool PrivateGenerator::PrintBetaStub(const grpc_generator::Service* service, } bool PrivateGenerator::PrintBetaServerFactory( - const TString& package_qualified_service_name, + const TString& package_qualified_service_name, const grpc_generator::Service* service, grpc_generator::Printer* out) { StringMap service_dict; service_dict["Service"] = service->name(); @@ -214,18 +214,18 @@ bool PrivateGenerator::PrintBetaServerFactory( StringMap output_message_modules_and_classes; for (int i = 0; i < service->method_count(); ++i) { auto method = service->method(i); - const TString method_implementation_constructor = - TString(method->ClientStreaming() ? "stream_" : "unary_") + - TString(method->ServerStreaming() ? "stream_" : "unary_") + + const TString method_implementation_constructor = + TString(method->ClientStreaming() ? "stream_" : "unary_") + + TString(method->ServerStreaming() ? "stream_" : "unary_") + "inline"; - TString input_message_module_and_class; + 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)) { return false; } - TString output_message_module_and_class; + 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, @@ -280,7 +280,7 @@ bool PrivateGenerator::PrintBetaServerFactory( method_dict["Method"] = name_and_implementation_constructor->first; method_dict["Constructor"] = name_and_implementation_constructor->second; IndentScope raii_descriptions_indent(out); - const TString method_name = + const TString method_name = name_and_implementation_constructor->first; out->Print(method_dict, "(\'$PackageQualifiedServiceName$\', \'$Method$\'): " @@ -302,7 +302,7 @@ bool PrivateGenerator::PrintBetaServerFactory( } bool PrivateGenerator::PrintBetaStubFactory( - const TString& package_qualified_service_name, + const TString& package_qualified_service_name, const grpc_generator::Service* service, grpc_generator::Printer* out) { StringMap dict; dict["Service"] = service->name(); @@ -323,17 +323,17 @@ bool PrivateGenerator::PrintBetaStubFactory( StringMap output_message_modules_and_classes; for (int i = 0; i < service->method_count(); ++i) { auto method = service->method(i); - const TString method_cardinality = - TString(method->ClientStreaming() ? "STREAM" : "UNARY") + "_" + - TString(method->ServerStreaming() ? "STREAM" : "UNARY"); - TString input_message_module_and_class; + const TString method_cardinality = + TString(method->ClientStreaming() ? "STREAM" : "UNARY") + "_" + + TString(method->ServerStreaming() ? "STREAM" : "UNARY"); + 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)) { return false; } - TString output_message_module_and_class; + 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, @@ -406,7 +406,7 @@ bool PrivateGenerator::PrintBetaStubFactory( } bool PrivateGenerator::PrintStub( - const TString& package_qualified_service_name, + const TString& package_qualified_service_name, const grpc_generator::Service* service, grpc_generator::Printer* out) { StringMap dict; dict["Service"] = service->name(); @@ -430,17 +430,17 @@ bool PrivateGenerator::PrintStub( out->Print("\"\"\"\n"); for (int i = 0; i < service->method_count(); ++i) { auto method = service->method(i); - TString multi_callable_constructor = - TString(method->ClientStreaming() ? "stream" : "unary") + "_" + - TString(method->ServerStreaming() ? "stream" : "unary"); - TString request_module_and_class; + TString multi_callable_constructor = + TString(method->ClientStreaming() ? "stream" : "unary") + "_" + + TString(method->ServerStreaming() ? "stream" : "unary"); + 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)) { return false; } - TString response_module_and_class; + 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, @@ -486,7 +486,7 @@ bool PrivateGenerator::PrintServicer(const grpc_generator::Service* service, PrintAllComments(service_comments, out); for (int i = 0; i < service->method_count(); ++i) { auto method = service->method(i); - TString arg_name = + TString arg_name = method->ClientStreaming() ? "request_iterator" : "request"; StringMap method_dict; method_dict["Method"] = method->name(); @@ -507,7 +507,7 @@ bool PrivateGenerator::PrintServicer(const grpc_generator::Service* service, } bool PrivateGenerator::PrintAddServicerToServer( - const TString& package_qualified_service_name, + const TString& package_qualified_service_name, const grpc_generator::Service* service, grpc_generator::Printer* out) { StringMap service_dict; service_dict["Service"] = service->name(); @@ -522,18 +522,18 @@ bool PrivateGenerator::PrintAddServicerToServer( IndentScope raii_dict_second_indent(out); for (int i = 0; i < service->method_count(); ++i) { auto method = service->method(i); - TString method_handler_constructor = - TString(method->ClientStreaming() ? "stream" : "unary") + "_" + - TString(method->ServerStreaming() ? "stream" : "unary") + + TString method_handler_constructor = + TString(method->ClientStreaming() ? "stream" : "unary") + "_" + + TString(method->ServerStreaming() ? "stream" : "unary") + "_rpc_method_handler"; - TString request_module_and_class; + 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)) { return false; } - TString response_module_and_class; + 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, @@ -577,94 +577,94 @@ bool PrivateGenerator::PrintAddServicerToServer( return true; } -/* Prints out a service class used as a container for static methods pertaining - * to a class. This class has the exact name of service written in the ".proto" - * file, with no suffixes. Since this class merely acts as a namespace, it - * should never be instantiated. - */ -bool PrivateGenerator::PrintServiceClass( - const TString& package_qualified_service_name, - const grpc_generator::Service* service, grpc_generator::Printer* out) { - StringMap dict; - dict["Service"] = service->name(); - out->Print("\n\n"); - out->Print(" # This class is part of an EXPERIMENTAL API.\n"); - out->Print(dict, "class $Service$(object):\n"); - { - IndentScope class_indent(out); - StringVector service_comments = service->GetAllComments(); - PrintAllComments(service_comments, out); - for (int i = 0; i < service->method_count(); ++i) { - const auto& method = service->method(i); - 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)) { - 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)) { - return false; - } - out->Print("\n"); - StringMap method_dict; - method_dict["Method"] = method->name(); - out->Print("@staticmethod\n"); - out->Print(method_dict, "def $Method$("); - TString request_parameter( - method->ClientStreaming() ? "request_iterator" : "request"); - StringMap args_dict; - args_dict["RequestParameter"] = request_parameter; - { - IndentScope args_indent(out); - IndentScope args_double_indent(out); - out->Print(args_dict, "$RequestParameter$,\n"); - out->Print("target,\n"); - out->Print("options=(),\n"); - out->Print("channel_credentials=None,\n"); - out->Print("call_credentials=None,\n"); - out->Print("insecure=False,\n"); - out->Print("compression=None,\n"); - out->Print("wait_for_ready=None,\n"); - out->Print("timeout=None,\n"); - out->Print("metadata=None):\n"); - } - { - IndentScope method_indent(out); - TString arity_method_name = - TString(method->ClientStreaming() ? "stream" : "unary") + "_" + - TString(method->ServerStreaming() ? "stream" : "unary"); - args_dict["ArityMethodName"] = arity_method_name; - args_dict["PackageQualifiedService"] = package_qualified_service_name; - args_dict["Method"] = method->name(); - out->Print(args_dict, - "return " - "grpc.experimental.$ArityMethodName$($RequestParameter$, " - "target, '/$PackageQualifiedService$/$Method$',\n"); - { - IndentScope continuation_indent(out); - StringMap serializer_dict; - serializer_dict["RequestModuleAndClass"] = request_module_and_class; - serializer_dict["ResponseModuleAndClass"] = response_module_and_class; - out->Print(serializer_dict, - "$RequestModuleAndClass$.SerializeToString,\n"); - out->Print(serializer_dict, "$ResponseModuleAndClass$.FromString,\n"); - out->Print("options, channel_credentials,\n"); - out->Print( - "insecure, call_credentials, compression, wait_for_ready, " - "timeout, metadata)\n"); - } - } - } - } - // TODO(rbellevi): Add methods pertinent to the server side as well. - return true; -} - +/* Prints out a service class used as a container for static methods pertaining + * to a class. This class has the exact name of service written in the ".proto" + * file, with no suffixes. Since this class merely acts as a namespace, it + * should never be instantiated. + */ +bool PrivateGenerator::PrintServiceClass( + const TString& package_qualified_service_name, + const grpc_generator::Service* service, grpc_generator::Printer* out) { + StringMap dict; + dict["Service"] = service->name(); + out->Print("\n\n"); + out->Print(" # This class is part of an EXPERIMENTAL API.\n"); + out->Print(dict, "class $Service$(object):\n"); + { + IndentScope class_indent(out); + StringVector service_comments = service->GetAllComments(); + PrintAllComments(service_comments, out); + for (int i = 0; i < service->method_count(); ++i) { + const auto& method = service->method(i); + 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)) { + 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)) { + return false; + } + out->Print("\n"); + StringMap method_dict; + method_dict["Method"] = method->name(); + out->Print("@staticmethod\n"); + out->Print(method_dict, "def $Method$("); + TString request_parameter( + method->ClientStreaming() ? "request_iterator" : "request"); + StringMap args_dict; + args_dict["RequestParameter"] = request_parameter; + { + IndentScope args_indent(out); + IndentScope args_double_indent(out); + out->Print(args_dict, "$RequestParameter$,\n"); + out->Print("target,\n"); + out->Print("options=(),\n"); + out->Print("channel_credentials=None,\n"); + out->Print("call_credentials=None,\n"); + out->Print("insecure=False,\n"); + out->Print("compression=None,\n"); + out->Print("wait_for_ready=None,\n"); + out->Print("timeout=None,\n"); + out->Print("metadata=None):\n"); + } + { + IndentScope method_indent(out); + TString arity_method_name = + TString(method->ClientStreaming() ? "stream" : "unary") + "_" + + TString(method->ServerStreaming() ? "stream" : "unary"); + args_dict["ArityMethodName"] = arity_method_name; + args_dict["PackageQualifiedService"] = package_qualified_service_name; + args_dict["Method"] = method->name(); + out->Print(args_dict, + "return " + "grpc.experimental.$ArityMethodName$($RequestParameter$, " + "target, '/$PackageQualifiedService$/$Method$',\n"); + { + IndentScope continuation_indent(out); + StringMap serializer_dict; + serializer_dict["RequestModuleAndClass"] = request_module_and_class; + serializer_dict["ResponseModuleAndClass"] = response_module_and_class; + out->Print(serializer_dict, + "$RequestModuleAndClass$.SerializeToString,\n"); + out->Print(serializer_dict, "$ResponseModuleAndClass$.FromString,\n"); + out->Print("options, channel_credentials,\n"); + out->Print( + "insecure, call_credentials, compression, wait_for_ready, " + "timeout, metadata)\n"); + } + } + } + } + // TODO(rbellevi): Add methods pertinent to the server side as well. + return true; +} + bool PrivateGenerator::PrintBetaPreamble(grpc_generator::Printer* out) { StringMap var; var["Package"] = config.beta_package_root; @@ -690,21 +690,21 @@ bool PrivateGenerator::PrintPreamble(grpc_generator::Printer* out) { for (int j = 0; j < service->method_count(); ++j) { auto method = service.get()->method(j); - TString input_type_file_name = method->get_input_type_name(); - TString input_module_name = + 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); - TString input_module_alias = + TString input_module_alias = ModuleAlias(input_type_file_name, config.import_prefix, 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 = + 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); - TString output_module_alias = + TString output_module_alias = ModuleAlias(output_type_file_name, config.import_prefix, config.prefixes_to_filter); imports_set.insert( @@ -717,7 +717,7 @@ bool PrivateGenerator::PrintPreamble(grpc_generator::Printer* out) { auto module_name = std::get<0>(*it); var["ModuleAlias"] = std::get<1>(*it); const size_t last_dot_pos = module_name.rfind('.'); - if (last_dot_pos == TString::npos) { + if (last_dot_pos == TString::npos) { var["ImportStatement"] = "import " + module_name; } else { var["ImportStatement"] = "from " + module_name.substr(0, last_dot_pos) + @@ -731,19 +731,19 @@ bool PrivateGenerator::PrintPreamble(grpc_generator::Printer* out) { } bool PrivateGenerator::PrintGAServices(grpc_generator::Printer* out) { - TString package = file->package(); + TString package = file->package(); if (!package.empty()) { package = package.append("."); } for (int i = 0; i < file->service_count(); ++i) { auto service = file->service(i); - TString package_qualified_service_name = package + service->name(); + TString package_qualified_service_name = package + service->name(); if (!(PrintStub(package_qualified_service_name, service.get(), out) && PrintServicer(service.get(), out) && PrintAddServicerToServer(package_qualified_service_name, - service.get(), out) && - PrintServiceClass(package_qualified_service_name, service.get(), - out))) { + service.get(), out) && + PrintServiceClass(package_qualified_service_name, service.get(), + out))) { return false; } } @@ -751,13 +751,13 @@ bool PrivateGenerator::PrintGAServices(grpc_generator::Printer* out) { } bool PrivateGenerator::PrintBetaServices(grpc_generator::Printer* out) { - TString package = file->package(); + TString package = file->package(); if (!package.empty()) { package = package.append("."); } for (int i = 0; i < file->service_count(); ++i) { auto service = file->service(i); - TString package_qualified_service_name = package + service->name(); + TString package_qualified_service_name = package + service->name(); if (!(PrintBetaServicer(service.get(), out) && PrintBetaStub(service.get(), out) && PrintBetaServerFactory(package_qualified_service_name, service.get(), @@ -770,17 +770,17 @@ bool PrivateGenerator::PrintBetaServices(grpc_generator::Printer* out) { return true; } -pair<bool, TString> PrivateGenerator::GetGrpcServices() { - TString output; +pair<bool, TString> PrivateGenerator::GetGrpcServices() { + TString output; { // Scope the output stream so it closes and finalizes output to the string. auto out = file->CreatePrinter(&output); if (generate_in_pb2_grpc) { out->Print( "# Generated by the gRPC Python protocol compiler plugin. " - "DO NOT EDIT!\n\"\"\"" - "Client and server classes corresponding to protobuf-defined " - "services.\"\"\"\n"); + "DO NOT EDIT!\n\"\"\"" + "Client and server classes corresponding to protobuf-defined " + "services.\"\"\"\n"); if (!PrintPreamble(out.get())) { return make_pair(false, ""); } @@ -830,11 +830,11 @@ PythonGrpcGenerator::PythonGrpcGenerator(const GeneratorConfiguration& config) PythonGrpcGenerator::~PythonGrpcGenerator() {} static bool GenerateGrpc(GeneratorContext* context, PrivateGenerator& generator, - TString file_name, bool generate_in_pb2_grpc) { + TString file_name, bool generate_in_pb2_grpc) { bool success; std::unique_ptr<ZeroCopyOutputStream> output; std::unique_ptr<CodedOutputStream> coded_output; - TString grpc_code; + TString grpc_code; if (generate_in_pb2_grpc) { output.reset(context->Open(file_name)); @@ -845,7 +845,7 @@ static bool GenerateGrpc(GeneratorContext* context, PrivateGenerator& generator, } coded_output.reset(new CodedOutputStream(output.get())); - tie(success, grpc_code) = generator.GetGrpcServices(); + tie(success, grpc_code) = generator.GetGrpcServices(); if (success) { coded_output->WriteRaw(grpc_code.data(), grpc_code.size()); @@ -855,11 +855,11 @@ static bool GenerateGrpc(GeneratorContext* context, PrivateGenerator& generator, } } -static bool ParseParameters(const TString& parameter, - TString* grpc_version, - std::vector<TString>* strip_prefixes, - TString* error) { - std::vector<TString> comma_delimited_parameters; +static bool ParseParameters(const TString& parameter, + TString* grpc_version, + 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()) { @@ -878,21 +878,21 @@ static bool ParseParameters(const TString& parameter, return true; } -uint64_t PythonGrpcGenerator::GetSupportedFeatures() const { - return FEATURE_PROTO3_OPTIONAL; -} - +uint64_t PythonGrpcGenerator::GetSupportedFeatures() const { + return FEATURE_PROTO3_OPTIONAL; +} + bool PythonGrpcGenerator::Generate(const FileDescriptor* file, - const TString& parameter, + const TString& parameter, GeneratorContext* context, - TString* error) const { + TString* error) const { // Get output file name. - TString pb2_file_name; - TString pb2_grpc_file_name; + TString pb2_file_name; + TString pb2_grpc_file_name; static const int proto_suffix_length = strlen(".proto"); if (file->name().size() > static_cast<size_t>(proto_suffix_length) && file->name().find_last_of(".proto") == file->name().size() - 1) { - TString base = + TString base = file->name().substr(0, file->name().size() - proto_suffix_length); pb2_file_name = base + "_pb2.py"; pb2_grpc_file_name = base + "_pb2_grpc.py"; @@ -903,7 +903,7 @@ bool PythonGrpcGenerator::Generate(const FileDescriptor* file, generator_file_name = file->name(); ProtoBufFile pbfile(file); - TString grpc_version; + TString grpc_version; GeneratorConfiguration extended_config(config_); bool success = ParseParameters(parameter, &grpc_version, &(extended_config.prefixes_to_filter), error); diff --git a/contrib/libs/grpc/src/compiler/python_generator.h b/contrib/libs/grpc/src/compiler/python_generator.h index bcde0a5e358..962e23cac05 100644 --- a/contrib/libs/grpc/src/compiler/python_generator.h +++ b/contrib/libs/grpc/src/compiler/python_generator.h @@ -31,12 +31,12 @@ namespace grpc_python_generator { // that may be used internally at Google. struct GeneratorConfiguration { GeneratorConfiguration(); - TString grpc_package_root; + TString grpc_package_root; // TODO(https://github.com/grpc/grpc/issues/8622): Drop this. - TString beta_package_root; + TString beta_package_root; // TODO(https://github.com/google/protobuf/issues/888): Drop this. - TString import_prefix; - std::vector<TString> prefixes_to_filter; + TString import_prefix; + std::vector<TString> prefixes_to_filter; }; class PythonGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { @@ -44,12 +44,12 @@ class PythonGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { PythonGrpcGenerator(const GeneratorConfiguration& config); ~PythonGrpcGenerator(); - uint64_t GetSupportedFeatures() const override; - + uint64_t GetSupportedFeatures() const override; + bool Generate(const grpc::protobuf::FileDescriptor* file, - const TString& parameter, + const TString& parameter, grpc::protobuf::compiler::GeneratorContext* context, - TString* error) const override; + TString* error) const override; private: GeneratorConfiguration config_; diff --git a/contrib/libs/grpc/src/compiler/python_generator_helpers.h b/contrib/libs/grpc/src/compiler/python_generator_helpers.h index 78e7efd7e0d..441b7dc4c06 100644 --- a/contrib/libs/grpc/src/compiler/python_generator_helpers.h +++ b/contrib/libs/grpc/src/compiler/python_generator_helpers.h @@ -47,11 +47,11 @@ namespace grpc_python_generator { namespace { typedef vector<const Descriptor*> DescriptorVector; -typedef vector<TString> StringVector; +typedef vector<TString> StringVector; -static TString StripModulePrefixes( - const TString& raw_module_name, - const std::vector<TString>& prefixes_to_filter) { +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(), @@ -64,10 +64,10 @@ static TString StripModulePrefixes( // TODO(https://github.com/google/protobuf/issues/888): // Export `ModuleName` from protobuf's // `src/google/protobuf/compiler/python/python_generator.cc` file. -TString ModuleName(const TString& filename, - const TString& import_prefix, - const std::vector<TString>& prefixes_to_filter) { - TString basename = StripProto(filename); +TString ModuleName(const TString& filename, + const TString& import_prefix, + const std::vector<TString>& prefixes_to_filter) { + TString basename = StripProto(filename); basename = StringReplace(basename, "-", "_"); basename = StringReplace(basename, "/", "."); return StripModulePrefixes(import_prefix + basename + "_pb2", @@ -77,10 +77,10 @@ TString ModuleName(const TString& filename, // TODO(https://github.com/google/protobuf/issues/888): // Export `ModuleAlias` from protobuf's // `src/google/protobuf/compiler/python/python_generator.cc` file. -TString ModuleAlias(const TString& filename, - const TString& import_prefix, - const std::vector<TString>& prefixes_to_filter) { - TString module_name = +TString ModuleAlias(const TString& filename, + const TString& import_prefix, + const std::vector<TString>& prefixes_to_filter) { + TString module_name = ModuleName(filename, import_prefix, prefixes_to_filter); // We can't have dots in the module name, so we replace each with _dot_. // But that could lead to a collision between a.b and a_dot_b, so we also @@ -91,29 +91,29 @@ TString ModuleAlias(const TString& filename, } 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) { + const Descriptor* type, TString* out, TString generator_file_name, + bool generate_in_pb2_grpc, TString& import_prefix, + const std::vector<TString>& prefixes_to_filter) { const Descriptor* path_elem_type = type; DescriptorVector message_path; do { message_path.push_back(path_elem_type); path_elem_type = path_elem_type->containing_type(); } while (path_elem_type); // implicit nullptr comparison; don't be explicit - TString file_name = type->file()->name(); + TString file_name = type->file()->name(); static const int proto_suffix_length = strlen(".proto"); if (!(file_name.size() > static_cast<size_t>(proto_suffix_length) && file_name.find_last_of(".proto") == file_name.size() - 1)) { return false; } - TString module; + TString module; if (generator_file_name != file_name || generate_in_pb2_grpc) { module = ModuleAlias(file_name, import_prefix, prefixes_to_filter) + "."; } else { module = ""; } - TString message_type; + TString message_type; for (DescriptorVector::reverse_iterator path_iter = message_path.rbegin(); path_iter != message_path.rend(); ++path_iter) { message_type += (*path_iter)->name() + "."; @@ -136,8 +136,8 @@ StringVector get_all_comments(const DescriptorType* descriptor) { return comments; } -inline void Split(const TString& s, char delim, - std::vector<TString>* append_to) { +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); diff --git a/contrib/libs/grpc/src/compiler/python_private_generator.h b/contrib/libs/grpc/src/compiler/python_private_generator.h index 3039a38e122..48bce873f20 100644 --- a/contrib/libs/grpc/src/compiler/python_private_generator.h +++ b/contrib/libs/grpc/src/compiler/python_private_generator.h @@ -42,7 +42,7 @@ struct PrivateGenerator { PrivateGenerator(const GeneratorConfiguration& config, const grpc_generator::File* file); - std::pair<bool, TString> GetGrpcServices(); + std::pair<bool, TString> GetGrpcServices(); private: bool PrintPreamble(grpc_generator::Printer* out); @@ -51,32 +51,32 @@ struct PrivateGenerator { bool PrintBetaServices(grpc_generator::Printer* out); bool PrintAddServicerToServer( - const TString& package_qualified_service_name, + const TString& package_qualified_service_name, const grpc_generator::Service* service, grpc_generator::Printer* out); bool PrintServicer(const grpc_generator::Service* service, grpc_generator::Printer* out); - bool PrintStub(const TString& package_qualified_service_name, + bool PrintStub(const TString& package_qualified_service_name, const grpc_generator::Service* service, grpc_generator::Printer* out); - bool PrintServiceClass(const TString& package_qualified_service_name, - const grpc_generator::Service* service, - grpc_generator::Printer* out); + bool PrintServiceClass(const TString& package_qualified_service_name, + const grpc_generator::Service* service, + grpc_generator::Printer* out); bool PrintBetaServicer(const grpc_generator::Service* service, grpc_generator::Printer* out); - bool PrintBetaServerFactory(const TString& package_qualified_service_name, - const grpc_generator::Service* service, - grpc_generator::Printer* out); + bool PrintBetaServerFactory(const TString& package_qualified_service_name, + const grpc_generator::Service* service, + grpc_generator::Printer* out); bool PrintBetaStub(const grpc_generator::Service* service, grpc_generator::Printer* out); - bool PrintBetaStubFactory(const TString& package_qualified_service_name, + bool PrintBetaStubFactory(const TString& package_qualified_service_name, const grpc_generator::Service* service, grpc_generator::Printer* out); // Get all comments (leading, leading_detached, trailing) and print them as a // docstring. Any leading space of a line will be removed, but the line // wrapping will not be changed. - void PrintAllComments(std::vector<TString> comments, + void PrintAllComments(std::vector<TString> comments, grpc_generator::Printer* out); }; diff --git a/contrib/libs/grpc/src/compiler/ruby_generator.cc b/contrib/libs/grpc/src/compiler/ruby_generator.cc index c82e78fd640..eeb82612a4e 100644 --- a/contrib/libs/grpc/src/compiler/ruby_generator.cc +++ b/contrib/libs/grpc/src/compiler/ruby_generator.cc @@ -38,16 +38,16 @@ namespace grpc_ruby_generator { namespace { // Prints out the method using the ruby gRPC DSL. -void PrintMethod(const MethodDescriptor* method, Printer* out) { - TString input_type = RubyTypeOf(method->input_type()); +void PrintMethod(const MethodDescriptor* method, Printer* out) { + TString input_type = RubyTypeOf(method->input_type()); if (method->client_streaming()) { input_type = "stream(" + input_type + ")"; } - TString output_type = RubyTypeOf(method->output_type()); + TString output_type = RubyTypeOf(method->output_type()); if (method->server_streaming()) { output_type = "stream(" + output_type + ")"; } - std::map<TString, TString> method_vars = ListToDict({ + std::map<TString, TString> method_vars = ListToDict({ "mth.name", method->name(), "input.type", @@ -61,13 +61,13 @@ void PrintMethod(const MethodDescriptor* method, Printer* out) { } // Prints out the service using the ruby gRPC DSL. -void PrintService(const ServiceDescriptor* service, Printer* out) { +void PrintService(const ServiceDescriptor* service, Printer* out) { if (service->method_count() == 0) { return; } // Begin the service module - std::map<TString, TString> module_vars = ListToDict({ + std::map<TString, TString> module_vars = ListToDict({ "module.name", Modularize(service->name()), }); @@ -84,12 +84,12 @@ void PrintService(const ServiceDescriptor* service, Printer* out) { out->Print("\n"); out->Print("self.marshal_class_method = :encode\n"); out->Print("self.unmarshal_class_method = :decode\n"); - std::map<TString, TString> pkg_vars = + std::map<TString, TString> pkg_vars = ListToDict({"service_full_name", service->full_name()}); out->Print(pkg_vars, "self.service_name = '$service_full_name$'\n"); out->Print("\n"); for (int i = 0; i < service->method_count(); ++i) { - PrintMethod(service->method(i), out); + PrintMethod(service->method(i), out); } out->Outdent(); @@ -120,12 +120,12 @@ char ToUpper(char ch) { return IsLower(ch) ? (ch - 'a' + 'A') : ch; } // names must be PascalCased. // // foo_bar_baz -> FooBarBaz -TString PackageToModule(const TString& name) { +TString PackageToModule(const TString& name) { bool next_upper = true; - TString result; + TString result; result.reserve(name.size()); - for (TString::size_type i = 0; i < name.size(); i++) { + for (TString::size_type i = 0; i < name.size(); i++) { if (name[i] == '_') { next_upper = true; } else { @@ -142,8 +142,8 @@ TString PackageToModule(const TString& name) { } // end copying of protoc generator for ruby code -TString GetServices(const FileDescriptor* file) { - TString output; +TString GetServices(const FileDescriptor* file) { + TString output; { // Scope the output stream so it closes and finalizes output to the string. @@ -156,10 +156,10 @@ TString GetServices(const FileDescriptor* file) { return output; } - TString package_name = RubyPackage(file); + TString package_name = RubyPackage(file); // Write out a file header. - std::map<TString, TString> header_comment_vars = ListToDict({ + std::map<TString, TString> header_comment_vars = ListToDict({ "file.name", file->name(), "file.package", @@ -169,7 +169,7 @@ TString GetServices(const FileDescriptor* file) { out.Print(header_comment_vars, "# Source: $file.name$ for package '$file.package$'\n"); - TString leading_comments = GetRubyComments(file, true); + TString leading_comments = GetRubyComments(file, true); if (!leading_comments.empty()) { out.Print("# Original file comments:\n"); out.PrintRaw(leading_comments.c_str()); @@ -180,7 +180,7 @@ TString GetServices(const FileDescriptor* file) { // Write out require statemment to import the separately generated file // that defines the messages used by the service. This is generated by the // main ruby plugin. - std::map<TString, TString> dep_vars = ListToDict({ + std::map<TString, TString> dep_vars = ListToDict({ "dep.name", MessagesRequireName(file), }); @@ -188,9 +188,9 @@ TString GetServices(const FileDescriptor* file) { // Write out services within the modules out.Print("\n"); - std::vector<TString> modules = Split(package_name, '.'); + std::vector<TString> modules = Split(package_name, '.'); for (size_t i = 0; i < modules.size(); ++i) { - std::map<TString, TString> module_vars = ListToDict({ + std::map<TString, TString> module_vars = ListToDict({ "module.name", PackageToModule(modules[i]), }); @@ -199,7 +199,7 @@ TString GetServices(const FileDescriptor* file) { } for (int i = 0; i < file->service_count(); ++i) { auto service = file->service(i); - PrintService(service, &out); + PrintService(service, &out); } for (size_t i = 0; i < modules.size(); ++i) { out.Outdent(); diff --git a/contrib/libs/grpc/src/compiler/ruby_generator.h b/contrib/libs/grpc/src/compiler/ruby_generator.h index 325dc02294a..d4f23eca5f9 100644 --- a/contrib/libs/grpc/src/compiler/ruby_generator.h +++ b/contrib/libs/grpc/src/compiler/ruby_generator.h @@ -23,7 +23,7 @@ namespace grpc_ruby_generator { -TString GetServices(const grpc::protobuf::FileDescriptor* file); +TString GetServices(const grpc::protobuf::FileDescriptor* file); } // namespace grpc_ruby_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 9a109766194..504d0e1db15 100644 --- a/contrib/libs/grpc/src/compiler/ruby_generator_helpers-inl.h +++ b/contrib/libs/grpc/src/compiler/ruby_generator_helpers-inl.h @@ -26,7 +26,7 @@ namespace grpc_ruby_generator { inline bool ServicesFilename(const grpc::protobuf::FileDescriptor* file, - TString* file_name_or_error) { + TString* file_name_or_error) { // Get output file name. static const unsigned proto_suffix_length = 6; // length of ".proto" if (file->name().size() > proto_suffix_length && @@ -41,7 +41,7 @@ inline bool ServicesFilename(const grpc::protobuf::FileDescriptor* file, } } -inline TString MessagesRequireName( +inline TString MessagesRequireName( const grpc::protobuf::FileDescriptor* file) { return Replace(file->name(), ".proto", "_pb"); } @@ -49,7 +49,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. template <typename DescriptorType> -inline TString GetRubyComments(const DescriptorType* desc, bool leading) { +inline TString GetRubyComments(const DescriptorType* desc, bool leading) { return grpc_generator::GetPrefixedComments(desc, leading, "#"); } diff --git a/contrib/libs/grpc/src/compiler/ruby_generator_map-inl.h b/contrib/libs/grpc/src/compiler/ruby_generator_map-inl.h index 4c75780b1a3..87ee01ceb36 100644 --- a/contrib/libs/grpc/src/compiler/ruby_generator_map-inl.h +++ b/contrib/libs/grpc/src/compiler/ruby_generator_map-inl.h @@ -35,17 +35,17 @@ namespace grpc_ruby_generator { // Converts an initializer list of the form { key0, value0, key1, value1, ... } // into a map of key* to value*. Is merely a readability helper for later code. -inline std::map<TString, TString> ListToDict( - const initializer_list<TString>& values) { +inline std::map<TString, TString> ListToDict( + const initializer_list<TString>& values) { if (values.size() % 2 != 0) { std::cerr << "Not every 'key' has a value in `values`." << std::endl; } - std::map<TString, TString> value_map; + std::map<TString, TString> value_map; auto value_iter = values.begin(); for (unsigned i = 0; i < values.size() / 2; ++i) { - TString key = *value_iter; + TString key = *value_iter; ++value_iter; - TString value = *value_iter; + TString value = *value_iter; value_map[key] = value; ++value_iter; } 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 956539f392a..04f9924268b 100644 --- a/contrib/libs/grpc/src/compiler/ruby_generator_string-inl.h +++ b/contrib/libs/grpc/src/compiler/ruby_generator_string-inl.h @@ -31,10 +31,10 @@ using std::transform; namespace grpc_ruby_generator { // Split splits a string using char into elems. -inline std::vector<TString>& Split(const TString& s, char delim, - std::vector<TString>* elems) { +inline std::vector<TString>& Split(const TString& s, char delim, + std::vector<TString>* elems) { std::stringstream ss(s); - TString item; + TString item; while (getline(ss, item, delim)) { elems->push_back(item); } @@ -42,17 +42,17 @@ inline std::vector<TString>& Split(const TString& s, char delim, } // Split splits a string using char, returning the result in a vector. -inline std::vector<TString> Split(const TString& s, char delim) { - std::vector<TString> elems; +inline std::vector<TString> Split(const TString& s, char delim) { + std::vector<TString> elems; Split(s, delim, &elems); return elems; } // Replace replaces from with to in s. -inline TString Replace(TString s, const TString& from, - const TString& to) { +inline TString Replace(TString s, const TString& from, + const TString& to) { size_t start_pos = s.find(from); - if (start_pos == TString::npos) { + if (start_pos == TString::npos) { return s; } s.replace(start_pos, from.length(), to); @@ -60,10 +60,10 @@ inline TString Replace(TString s, const TString& from, } // ReplaceAll replaces all instances of search with replace in s. -inline TString ReplaceAll(TString s, const TString& search, - const TString& replace) { +inline TString ReplaceAll(TString s, const TString& search, + const TString& replace) { size_t pos = 0; - while ((pos = s.find(search, pos)) != TString::npos) { + while ((pos = s.find(search, pos)) != TString::npos) { s.replace(pos, search.length(), replace); pos += replace.length(); } @@ -71,10 +71,10 @@ inline TString ReplaceAll(TString s, const TString& search, } // ReplacePrefix replaces from with to in s if search is a prefix of s. -inline bool ReplacePrefix(TString* s, const TString& from, - const TString& to) { +inline bool ReplacePrefix(TString* s, const TString& from, + const TString& to) { size_t start_pos = s->find(from); - if (start_pos == TString::npos || start_pos != 0) { + if (start_pos == TString::npos || start_pos != 0) { return false; } s->replace(start_pos, from.length(), to); @@ -82,14 +82,14 @@ inline bool ReplacePrefix(TString* s, const TString& from, } // Modularize converts a string into a ruby module compatible name -inline TString Modularize(TString s) { +inline TString Modularize(TString s) { if (s.empty()) { return s; } - TString new_string = ""; + TString new_string = ""; bool was_last_underscore = false; new_string.append(1, ::toupper(s[0])); - for (TString::size_type i = 1; i < s.size(); ++i) { + for (TString::size_type i = 1; i < s.size(); ++i) { if (was_last_underscore && s[i] != '_') { new_string.append(1, ::toupper(s[i])); } else if (s[i] != '_') { @@ -101,8 +101,8 @@ inline TString Modularize(TString s) { } // 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(); +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(); @@ -116,19 +116,19 @@ inline TString RubyPackage(const grpc::protobuf::FileDescriptor* file) { } // RubyTypeOf updates a proto type to the required ruby equivalent. -inline TString RubyTypeOf(const grpc::protobuf::Descriptor* descriptor) { - TString proto_type = descriptor->full_name(); +inline TString RubyTypeOf(const grpc::protobuf::Descriptor* descriptor) { + TString proto_type = descriptor->full_name(); 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; + // 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) { + TString res("." + proto_type); + if (res.find('.') == TString::npos) { return res; } else { - std::vector<TString> prefixes_and_type = Split(res, '.'); + std::vector<TString> prefixes_and_type = Split(res, '.'); res.clear(); for (unsigned int i = 0; i < prefixes_and_type.size(); ++i) { if (i != 0) { diff --git a/contrib/libs/grpc/src/compiler/schema_interface.h b/contrib/libs/grpc/src/compiler/schema_interface.h index 60b9d337e8d..abf6f55ae7f 100644 --- a/contrib/libs/grpc/src/compiler/schema_interface.h +++ b/contrib/libs/grpc/src/compiler/schema_interface.h @@ -22,19 +22,19 @@ #include "src/compiler/config.h" #include <memory> -#include <util/generic/string.h> +#include <util/generic/string.h> #include <vector> -#ifdef GRPC_CUSTOM_STRING -#warning GRPC_CUSTOM_STRING is no longer supported. Please use TString. +#ifdef GRPC_CUSTOM_STRING +#warning GRPC_CUSTOM_STRING is no longer supported. Please use TString. #endif namespace grpc { -// Using grpc::string and grpc::to_string is discouraged in favor of -// TString and ToString. This is only for legacy code using -// them explictly. -typedef TString string; // deprecated +// Using grpc::string and grpc::to_string is discouraged in favor of +// TString and ToString. This is only for legacy code using +// them explictly. +typedef TString string; // deprecated } // namespace grpc @@ -44,31 +44,31 @@ namespace grpc_generator { // Return formatted comments to be inserted in generated code. struct CommentHolder { virtual ~CommentHolder() {} - virtual TString GetLeadingComments(const TString prefix) const = 0; - virtual TString GetTrailingComments(const TString prefix) const = 0; - virtual std::vector<TString> GetAllComments() const = 0; + virtual TString GetLeadingComments(const TString prefix) const = 0; + virtual TString GetTrailingComments(const TString prefix) const = 0; + virtual std::vector<TString> GetAllComments() const = 0; }; // An abstract interface representing a method. struct Method : public CommentHolder { virtual ~Method() {} - virtual TString name() const = 0; + virtual TString name() const = 0; - virtual TString input_type_name() const = 0; - virtual TString output_type_name() const = 0; + virtual TString input_type_name() const = 0; + virtual TString output_type_name() const = 0; virtual 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 = 0; + TString* str, TString generator_file_name, + bool generate_in_pb2_grpc, TString import_prefix, + const std::vector<TString>& prefixes_to_filter) const = 0; virtual 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 = 0; + TString* str, TString generator_file_name, + bool generate_in_pb2_grpc, TString import_prefix, + const std::vector<TString>& prefixes_to_filter) const = 0; - virtual TString get_input_type_name() const = 0; - virtual TString get_output_type_name() const = 0; + virtual TString get_input_type_name() const = 0; + virtual TString get_output_type_name() const = 0; virtual bool NoStreaming() const = 0; virtual bool ClientStreaming() const = 0; virtual bool ServerStreaming() const = 0; @@ -79,7 +79,7 @@ struct Method : public CommentHolder { struct Service : public CommentHolder { virtual ~Service() {} - virtual TString name() const = 0; + virtual TString name() const = 0; virtual int method_count() const = 0; virtual std::unique_ptr<const Method> method(int i) const = 0; @@ -88,7 +88,7 @@ struct Service : public CommentHolder { struct Printer { virtual ~Printer() {} - virtual void Print(const std::map<TString, TString>& vars, + virtual void Print(const std::map<TString, TString>& vars, const char* template_string) = 0; virtual void Print(const char* string) = 0; virtual void PrintRaw(const char* string) = 0; @@ -101,17 +101,17 @@ struct Printer { struct File : public CommentHolder { virtual ~File() {} - virtual TString filename() const = 0; - virtual TString filename_without_ext() const = 0; - virtual TString package() const = 0; - virtual std::vector<TString> package_parts() const = 0; - virtual TString additional_headers() const = 0; - virtual std::vector<TString> GetImportNames() const { return {}; } + virtual TString filename() const = 0; + virtual TString filename_without_ext() const = 0; + virtual TString package() const = 0; + virtual std::vector<TString> package_parts() const = 0; + virtual TString additional_headers() const = 0; + virtual std::vector<TString> GetImportNames() const { return {}; } virtual int service_count() const = 0; virtual std::unique_ptr<const Service> service(int i) const = 0; - virtual std::unique_ptr<Printer> CreatePrinter(TString* str) const = 0; + virtual std::unique_ptr<Printer> CreatePrinter(TString* str) const = 0; }; } // namespace grpc_generator |