From 33d7aaffe85a6abc9c83af976f4f617e4b3e0cff Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Fri, 19 Mar 2021 01:12:28 -0700 Subject: [PATCH] Fix const-ness of callback client read RPC requests (#25763) * Fix const-ness of callback client read RPC requests * Fix golden file --- src/compiler/cpp_generator.cc | 10 +++++----- test/cpp/codegen/compiler_test_golden | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/compiler/cpp_generator.cc b/src/compiler/cpp_generator.cc index c78a3e08e22..1024d789524 100644 --- a/src/compiler/cpp_generator.cc +++ b/src/compiler/cpp_generator.cc @@ -633,12 +633,12 @@ void PrintHeaderClientMethodCallbackInterfaces( printer->Print(*vars, "#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" "virtual void $Method$(::grpc::ClientContext* context, " - "$Request$* request, " + "const $Request$* request, " "::grpc::ClientReadReactor< $Response$>* " "reactor) = 0;\n" "#else\n" "virtual void $Method$(::grpc::ClientContext* context, " - "$Request$* request, " + "const $Request$* request, " "::grpc::experimental::ClientReadReactor< $Response$>* " "reactor) = 0;\n" "#endif\n"); @@ -730,12 +730,12 @@ void PrintHeaderClientMethodCallback(grpc_generator::Printer* printer, printer->Print(*vars, "#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL\n" "void $Method$(::grpc::ClientContext* context, " - "$Request$* request, " + "const $Request$* request, " "::grpc::ClientReadReactor< $Response$>* " "reactor) override;\n" "#else\n" "void $Method$(::grpc::ClientContext* context, " - "$Request$* request, " + "const $Request$* request, " "::grpc::experimental::ClientReadReactor< $Response$>* " "reactor) override;\n" "#endif\n"); @@ -2005,7 +2005,7 @@ void PrintSourceClientMethod(grpc_generator::Printer* printer, *vars, "void $ns$$Service$::Stub::experimental_async::$Method$(::grpc::" "ClientContext* context, " - "$Request$* request, " + "const $Request$* request, " "::grpc::experimental::ClientReadReactor< $Response$>* reactor) {\n"); printer->Print(*vars, " ::grpc::internal::ClientCallbackReaderFactory< " diff --git a/test/cpp/codegen/compiler_test_golden b/test/cpp/codegen/compiler_test_golden index bf456894ff7..2bcd72dbcc9 100644 --- a/test/cpp/codegen/compiler_test_golden +++ b/test/cpp/codegen/compiler_test_golden @@ -130,9 +130,9 @@ class ServiceA final { // MethodA2 trailing comment 1 // Method A3 leading comment 1 #ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL - virtual void MethodA3(::grpc::ClientContext* context, ::grpc::testing::Request* request, ::grpc::ClientReadReactor< ::grpc::testing::Response>* reactor) = 0; + virtual void MethodA3(::grpc::ClientContext* context, const ::grpc::testing::Request* request, ::grpc::ClientReadReactor< ::grpc::testing::Response>* reactor) = 0; #else - virtual void MethodA3(::grpc::ClientContext* context, ::grpc::testing::Request* request, ::grpc::experimental::ClientReadReactor< ::grpc::testing::Response>* reactor) = 0; + virtual void MethodA3(::grpc::ClientContext* context, const ::grpc::testing::Request* request, ::grpc::experimental::ClientReadReactor< ::grpc::testing::Response>* reactor) = 0; #endif // Method A3 trailing comment 1 // Method A4 leading comment 1 @@ -215,9 +215,9 @@ class ServiceA final { void MethodA2(::grpc::ClientContext* context, ::grpc::testing::Response* response, ::grpc::experimental::ClientWriteReactor< ::grpc::testing::Request>* reactor) override; #endif #ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL - void MethodA3(::grpc::ClientContext* context, ::grpc::testing::Request* request, ::grpc::ClientReadReactor< ::grpc::testing::Response>* reactor) override; + void MethodA3(::grpc::ClientContext* context, const ::grpc::testing::Request* request, ::grpc::ClientReadReactor< ::grpc::testing::Response>* reactor) override; #else - void MethodA3(::grpc::ClientContext* context, ::grpc::testing::Request* request, ::grpc::experimental::ClientReadReactor< ::grpc::testing::Response>* reactor) override; + void MethodA3(::grpc::ClientContext* context, const ::grpc::testing::Request* request, ::grpc::experimental::ClientReadReactor< ::grpc::testing::Response>* reactor) override; #endif #ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL void MethodA4(::grpc::ClientContext* context, ::grpc::ClientBidiReactor< ::grpc::testing::Request,::grpc::testing::Response>* reactor) override;