From 88974d506a8dd3598c9d35a0bbf6264afe23731e Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Tue, 30 May 2017 16:41:51 -0700 Subject: [PATCH 01/11] Use protobuf's native upper camel conversion --- src/compiler/objective_c_generator_helpers.h | 4 +++- src/compiler/objective_c_plugin.cc | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/compiler/objective_c_generator_helpers.h b/src/compiler/objective_c_generator_helpers.h index b482f028a10..3ebd1b14447 100644 --- a/src/compiler/objective_c_generator_helpers.h +++ b/src/compiler/objective_c_generator_helpers.h @@ -38,6 +38,8 @@ #include "src/compiler/config.h" #include "src/compiler/generator_helpers.h" +#include + namespace grpc_objective_c_generator { using ::grpc::protobuf::FileDescriptor; @@ -45,7 +47,7 @@ using ::grpc::protobuf::ServiceDescriptor; using ::grpc::string; inline string MessageHeaderName(const FileDescriptor *file) { - return grpc_generator::FileNameInUpperCamel(file) + ".pbobjc.h"; + return google::protobuf::compiler::objectivec::FilePath(file) + ".pbobjc.h"; } inline string ServiceClassName(const ServiceDescriptor *service) { diff --git a/src/compiler/objective_c_plugin.cc b/src/compiler/objective_c_plugin.cc index 5178115e44c..682d6aa9aa7 100644 --- a/src/compiler/objective_c_plugin.cc +++ b/src/compiler/objective_c_plugin.cc @@ -59,7 +59,7 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { return true; } - ::grpc::string file_name = grpc_generator::FileNameInUpperCamel(file); + ::grpc::string file_name = google::protobuf::compiler::objectivec::FilePath(file); ::grpc::string prefix = file->options().objc_class_prefix(); { From 88d937736548544077357a0bb74df52f275dec7e Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Wed, 31 May 2017 09:32:27 -0700 Subject: [PATCH 02/11] clang-format --- src/compiler/objective_c_plugin.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/compiler/objective_c_plugin.cc b/src/compiler/objective_c_plugin.cc index 682d6aa9aa7..466da4c3b48 100644 --- a/src/compiler/objective_c_plugin.cc +++ b/src/compiler/objective_c_plugin.cc @@ -59,7 +59,8 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { return true; } - ::grpc::string file_name = google::protobuf::compiler::objectivec::FilePath(file); + ::grpc::string file_name = + google::protobuf::compiler::objectivec::FilePath(file); ::grpc::string prefix = file->options().objc_class_prefix(); { From c4f84819bd92ccc1851647727400407bb9366564 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Mon, 5 Jun 2017 11:57:12 -0700 Subject: [PATCH 03/11] Backward compatibility --- src/compiler/objective_c_generator_helpers.h | 8 ++++++-- src/compiler/objective_c_plugin.cc | 14 +++++++++++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/compiler/objective_c_generator_helpers.h b/src/compiler/objective_c_generator_helpers.h index 3ebd1b14447..3048fe273a2 100644 --- a/src/compiler/objective_c_generator_helpers.h +++ b/src/compiler/objective_c_generator_helpers.h @@ -46,8 +46,12 @@ using ::grpc::protobuf::FileDescriptor; using ::grpc::protobuf::ServiceDescriptor; using ::grpc::string; -inline string MessageHeaderName(const FileDescriptor *file) { - return google::protobuf::compiler::objectivec::FilePath(file) + ".pbobjc.h"; +inline string MessageHeaderName(const FileDescriptor *file, bool dash_as_separator) { + if (dash_as_separator) { + return google::protobuf::compiler::objectivec::FilePath(file) + ".pbobjc.h"; + } else { + return grpc_generator::FileNameInUpperCamel(file) + ".pbobjc.h"; + } } inline string ServiceClassName(const ServiceDescriptor *service) { diff --git a/src/compiler/objective_c_plugin.cc b/src/compiler/objective_c_plugin.cc index 466da4c3b48..92b9c828fb6 100644 --- a/src/compiler/objective_c_plugin.cc +++ b/src/compiler/objective_c_plugin.cc @@ -59,8 +59,16 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { return true; } - ::grpc::string file_name = - google::protobuf::compiler::objectivec::FilePath(file); + ::grpc::string file_name; + + // Simple parameter parsing as we have only one parameter. + // TODO(mxyan): Complete parameter parsing. + bool dash_as_separator = (0 == parameter.compare("--filename-dash-as-separator")); + if (dash_as_separator) { + file_name = google::protobuf::compiler::objectivec::FilePath(file); + } else { + file_name = grpc_generator::FileNameInUpperCamel(file); + } ::grpc::string prefix = file->options().objc_class_prefix(); { @@ -78,7 +86,7 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { ::grpc::string proto_imports; for (int i = 0; i < file->dependency_count(); i++) { ::grpc::string header = - grpc_objective_c_generator::MessageHeaderName(file->dependency(i)); + grpc_objective_c_generator::MessageHeaderName(file->dependency(i), dash_as_separator); const grpc::protobuf::FileDescriptor *dependency = file->dependency(i); if (IsProtobufLibraryBundledProtoFile(dependency)) { ::grpc::string base_name = header; From 28dbc84a53c13f0159b65ce9c5008b0e4f3798f7 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Mon, 5 Jun 2017 15:25:04 -0700 Subject: [PATCH 04/11] Polish --- src/compiler/objective_c_plugin.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/objective_c_plugin.cc b/src/compiler/objective_c_plugin.cc index 92b9c828fb6..aeaf743c632 100644 --- a/src/compiler/objective_c_plugin.cc +++ b/src/compiler/objective_c_plugin.cc @@ -63,7 +63,7 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { // Simple parameter parsing as we have only one parameter. // TODO(mxyan): Complete parameter parsing. - bool dash_as_separator = (0 == parameter.compare("--filename-dash-as-separator")); + bool dash_as_separator = (0 == parameter.compare("filename-dash-as-separator")); if (dash_as_separator) { file_name = google::protobuf::compiler::objectivec::FilePath(file); } else { From 732498b9111e1fd8604e45ca6877147d86302715 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Mon, 5 Jun 2017 15:28:10 -0700 Subject: [PATCH 05/11] clang-format --- src/compiler/objective_c_generator_helpers.h | 3 ++- src/compiler/objective_c_plugin.cc | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/compiler/objective_c_generator_helpers.h b/src/compiler/objective_c_generator_helpers.h index 3048fe273a2..6fdb942387f 100644 --- a/src/compiler/objective_c_generator_helpers.h +++ b/src/compiler/objective_c_generator_helpers.h @@ -46,7 +46,8 @@ using ::grpc::protobuf::FileDescriptor; using ::grpc::protobuf::ServiceDescriptor; using ::grpc::string; -inline string MessageHeaderName(const FileDescriptor *file, bool dash_as_separator) { +inline string MessageHeaderName(const FileDescriptor *file, + bool dash_as_separator) { if (dash_as_separator) { return google::protobuf::compiler::objectivec::FilePath(file) + ".pbobjc.h"; } else { diff --git a/src/compiler/objective_c_plugin.cc b/src/compiler/objective_c_plugin.cc index aeaf743c632..6fc612018b6 100644 --- a/src/compiler/objective_c_plugin.cc +++ b/src/compiler/objective_c_plugin.cc @@ -63,7 +63,8 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { // Simple parameter parsing as we have only one parameter. // TODO(mxyan): Complete parameter parsing. - bool dash_as_separator = (0 == parameter.compare("filename-dash-as-separator")); + bool dash_as_separator = + (0 == parameter.compare("filename-dash-as-separator")); if (dash_as_separator) { file_name = google::protobuf::compiler::objectivec::FilePath(file); } else { @@ -85,8 +86,8 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { // and import the files in the .pbrpc.m ::grpc::string proto_imports; for (int i = 0; i < file->dependency_count(); i++) { - ::grpc::string header = - grpc_objective_c_generator::MessageHeaderName(file->dependency(i), dash_as_separator); + ::grpc::string header = grpc_objective_c_generator::MessageHeaderName( + file->dependency(i), dash_as_separator); const grpc::protobuf::FileDescriptor *dependency = file->dependency(i); if (IsProtobufLibraryBundledProtoFile(dependency)) { ::grpc::string base_name = header; From 6a8763eca9866d6e94dfbff9ca8c133e5ef6e5c5 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Tue, 6 Jun 2017 11:13:09 -0700 Subject: [PATCH 06/11] Add test to verify objective c plugin outputs correct filename --- .../RemoteTestClient/test-dash-filename.proto | 72 +++++++++++++++++++ src/objective-c/tests/build_tests.sh | 23 ++++++ 2 files changed, 95 insertions(+) create mode 100644 src/objective-c/tests/RemoteTestClient/test-dash-filename.proto diff --git a/src/objective-c/tests/RemoteTestClient/test-dash-filename.proto b/src/objective-c/tests/RemoteTestClient/test-dash-filename.proto new file mode 100644 index 00000000000..5c359c5c129 --- /dev/null +++ b/src/objective-c/tests/RemoteTestClient/test-dash-filename.proto @@ -0,0 +1,72 @@ +// Copyright 2015, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// An integration test service that covers all the method signature permutations +// of unary/streaming requests/responses. +syntax = "proto3"; + +import "google/protobuf/empty.proto"; +import "messages.proto"; + +package grpc.testing; + +option objc_class_prefix = "RMT"; + +// A simple service to test the various types of RPCs and experiment with +// performance with various types of payload. +service TestService { + // One empty request followed by one empty response. + rpc EmptyCall(google.protobuf.Empty) returns (google.protobuf.Empty); + + // One request followed by one response. + rpc UnaryCall(SimpleRequest) returns (SimpleResponse); + + // One request followed by a sequence of responses (streamed download). + // The server returns the payload with client desired type and sizes. + rpc StreamingOutputCall(StreamingOutputCallRequest) + returns (stream StreamingOutputCallResponse); + + // A sequence of requests followed by one response (streamed upload). + // The server returns the aggregated size of client payload as the result. + rpc StreamingInputCall(stream StreamingInputCallRequest) + returns (StreamingInputCallResponse); + + // A sequence of requests with each request served by the server immediately. + // As one request could lead to multiple responses, this interface + // demonstrates the idea of full duplexing. + rpc FullDuplexCall(stream StreamingOutputCallRequest) + returns (stream StreamingOutputCallResponse); + + // A sequence of requests followed by a sequence of responses. + // The server buffers all the client requests and then serves them in order. A + // stream of responses are returned to the client when the server starts with + // first request. + rpc HalfDuplexCall(stream StreamingOutputCallRequest) + returns (stream StreamingOutputCallResponse); +} diff --git a/src/objective-c/tests/build_tests.sh b/src/objective-c/tests/build_tests.sh index 6602d510d94..496dbcbe600 100755 --- a/src/objective-c/tests/build_tests.sh +++ b/src/objective-c/tests/build_tests.sh @@ -52,3 +52,26 @@ rm -f RemoteTestClient/*.{h,m} echo "TIME: $(date)" pod install + +# Verify the output proto name +[ -e ./RemoteTestClient/Test-dash-filename.pbrpc.h ] || { + echo >&2 "protoc outputs wrong filename." + exit 1 +} + +# Verify the output proto name when dash is treated as separator +PROTOC=../../../bins/$CONFIG/protobuf/protoc +PLUGIN=../../../bins/$CONFIG/grpc_objective_c_plugin + +eval $PROTOC \ + --plugin=protoc-gen-grpc=$PLUGIN \ + --objc_out=RemoteTestClient \ + --grpc_out=filename-dash-as-separator:RemoteTestClient \ + -I RemoteTestClient \ + -I ../../../third_party/protobuf/src \ + RemoteTestClient/*.proto + +[ -e ./RemoteTestClient/TestDashFilename.pbrpc.h ] || { + echo >&2 "protoc outputs wring filename. 2" + exit 1 +} From daa2cb663b5862cd9abbb1ca76eb98acc6a1500e Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Tue, 6 Jun 2017 11:21:09 -0700 Subject: [PATCH 07/11] Add comment --- src/compiler/objective_c_plugin.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/compiler/objective_c_plugin.cc b/src/compiler/objective_c_plugin.cc index 6fc612018b6..ff980ae5499 100644 --- a/src/compiler/objective_c_plugin.cc +++ b/src/compiler/objective_c_plugin.cc @@ -32,6 +32,10 @@ */ // Generates Objective C gRPC service interface out of Protobuf IDL. +// For legacy reason, output filename of this plugin is by default in uppercamel +// case with dash "-" treated as character and preserved in the output file +// name. If normal upper camel case (dash treated as word separator) is desired, +// use plugin option "filename-dash-as-separator". #include From cc620dffd02da894dd5678e650c474d21c8432c0 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Wed, 7 Jun 2017 10:00:39 -0700 Subject: [PATCH 08/11] Fix test proto --- .../RemoteTestClient/test-dash-filename.proto | 35 +------------------ 1 file changed, 1 insertion(+), 34 deletions(-) diff --git a/src/objective-c/tests/RemoteTestClient/test-dash-filename.proto b/src/objective-c/tests/RemoteTestClient/test-dash-filename.proto index 5c359c5c129..413d6f9eaac 100644 --- a/src/objective-c/tests/RemoteTestClient/test-dash-filename.proto +++ b/src/objective-c/tests/RemoteTestClient/test-dash-filename.proto @@ -31,42 +31,9 @@ // of unary/streaming requests/responses. syntax = "proto3"; -import "google/protobuf/empty.proto"; -import "messages.proto"; - package grpc.testing; option objc_class_prefix = "RMT"; -// A simple service to test the various types of RPCs and experiment with -// performance with various types of payload. -service TestService { - // One empty request followed by one empty response. - rpc EmptyCall(google.protobuf.Empty) returns (google.protobuf.Empty); - - // One request followed by one response. - rpc UnaryCall(SimpleRequest) returns (SimpleResponse); - - // One request followed by a sequence of responses (streamed download). - // The server returns the payload with client desired type and sizes. - rpc StreamingOutputCall(StreamingOutputCallRequest) - returns (stream StreamingOutputCallResponse); - - // A sequence of requests followed by one response (streamed upload). - // The server returns the aggregated size of client payload as the result. - rpc StreamingInputCall(stream StreamingInputCallRequest) - returns (StreamingInputCallResponse); - - // A sequence of requests with each request served by the server immediately. - // As one request could lead to multiple responses, this interface - // demonstrates the idea of full duplexing. - rpc FullDuplexCall(stream StreamingOutputCallRequest) - returns (stream StreamingOutputCallResponse); - - // A sequence of requests followed by a sequence of responses. - // The server buffers all the client requests and then serves them in order. A - // stream of responses are returned to the client when the server starts with - // first request. - rpc HalfDuplexCall(stream StreamingOutputCallRequest) - returns (stream StreamingOutputCallResponse); +service DummyService { } From 7352bae1bb02d0d66091f85761934e7fcc1b95ef Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Thu, 8 Jun 2017 09:58:06 -0700 Subject: [PATCH 09/11] Move tests --- .../tests/PluginTest/imported-with-dash.proto | 38 +++++++++++++++++++ .../test-dash-filename.proto | 8 +++- src/objective-c/tests/build_tests.sh | 22 ----------- src/objective-c/tests/run_tests.sh | 32 ++++++++++++++++ 4 files changed, 77 insertions(+), 23 deletions(-) create mode 100644 src/objective-c/tests/PluginTest/imported-with-dash.proto rename src/objective-c/tests/{RemoteTestClient => PluginTest}/test-dash-filename.proto (94%) diff --git a/src/objective-c/tests/PluginTest/imported-with-dash.proto b/src/objective-c/tests/PluginTest/imported-with-dash.proto new file mode 100644 index 00000000000..0c4ee3827ad --- /dev/null +++ b/src/objective-c/tests/PluginTest/imported-with-dash.proto @@ -0,0 +1,38 @@ +// Copyright 2017, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +syntax = "proto3"; + +package grpc.testing; + +option objc_class_prefix = "RMT"; + +message TestMessageImported { + int32 dummy = 1; +} diff --git a/src/objective-c/tests/RemoteTestClient/test-dash-filename.proto b/src/objective-c/tests/PluginTest/test-dash-filename.proto similarity index 94% rename from src/objective-c/tests/RemoteTestClient/test-dash-filename.proto rename to src/objective-c/tests/PluginTest/test-dash-filename.proto index 413d6f9eaac..be9386f9608 100644 --- a/src/objective-c/tests/RemoteTestClient/test-dash-filename.proto +++ b/src/objective-c/tests/PluginTest/test-dash-filename.proto @@ -1,4 +1,4 @@ -// Copyright 2015, Google Inc. +// Copyright 2017, Google Inc. // All rights reserved. // // Redistribution and use in source and binary forms, with or without @@ -35,5 +35,11 @@ package grpc.testing; option objc_class_prefix = "RMT"; +import "imported-with-dash.proto"; + +message TestMessage { + int32 dummy = 1; +} + service DummyService { } diff --git a/src/objective-c/tests/build_tests.sh b/src/objective-c/tests/build_tests.sh index 496dbcbe600..4b3ed21886c 100755 --- a/src/objective-c/tests/build_tests.sh +++ b/src/objective-c/tests/build_tests.sh @@ -53,25 +53,3 @@ rm -f RemoteTestClient/*.{h,m} echo "TIME: $(date)" pod install -# Verify the output proto name -[ -e ./RemoteTestClient/Test-dash-filename.pbrpc.h ] || { - echo >&2 "protoc outputs wrong filename." - exit 1 -} - -# Verify the output proto name when dash is treated as separator -PROTOC=../../../bins/$CONFIG/protobuf/protoc -PLUGIN=../../../bins/$CONFIG/grpc_objective_c_plugin - -eval $PROTOC \ - --plugin=protoc-gen-grpc=$PLUGIN \ - --objc_out=RemoteTestClient \ - --grpc_out=filename-dash-as-separator:RemoteTestClient \ - -I RemoteTestClient \ - -I ../../../third_party/protobuf/src \ - RemoteTestClient/*.proto - -[ -e ./RemoteTestClient/TestDashFilename.pbrpc.h ] || { - echo >&2 "protoc outputs wring filename. 2" - exit 1 -} diff --git a/src/objective-c/tests/run_tests.sh b/src/objective-c/tests/run_tests.sh index 2432209f4f1..2d61910bbda 100755 --- a/src/objective-c/tests/run_tests.sh +++ b/src/objective-c/tests/run_tests.sh @@ -38,6 +38,38 @@ cd $(dirname $0) # Run the tests server. BINDIR=../../../bins/$CONFIG +PROTOC=$BINDIR/protobuf/protoc +PLUGIN=$BINDIR/grpc_objective_c_plugin + +rm -rf PluginTest/*pb* + +# Verify the output proto filename +eval $PROTOC \ + --plugin=protoc-gen-grpc=$PLUGIN \ + --objc_out=PluginTest \ + --grpc_out=PluginTest \ + -I PluginTest \ + -I ../../../third_party/protobuf/src \ + PluginTest/*.proto + +[ -e ./PluginTest/TestDashFilename.pbrpc.h ] || { + echo >&2 "protoc outputs wrong filename." + exit 1 +} + +# Verify names of the imported protos in generated code +[ "`cat PluginTest/TestDashFilename.pbrpc.h | + egrep '#import ".*\.pb(objc|rpc)\.h"$' | + egrep '-'`" ] && { + echo >&2 "protoc generated import with wrong filename." + exit 1 +} +[ "`cat PluginTest/TestDashFilename.pbrpc.m | + egrep '#import ".*\.pb(objc|rpc)\.m"$' | + egrep '-'`" ] && { + echo >&2 "protoc generated import with wrong filename." + exit 1 +} [ -f $BINDIR/interop_server ] || { echo >&2 "Can't find the test server. Make sure run_tests.py is making" \ From d044281286961f6f26f09fb4ba34a32603b021b0 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Thu, 8 Jun 2017 10:06:39 -0700 Subject: [PATCH 10/11] Revert the changes to maintain backward compatibility --- src/compiler/objective_c_generator_helpers.h | 9 ++------- src/compiler/objective_c_plugin.cc | 21 ++++---------------- 2 files changed, 6 insertions(+), 24 deletions(-) diff --git a/src/compiler/objective_c_generator_helpers.h b/src/compiler/objective_c_generator_helpers.h index 6fdb942387f..3ebd1b14447 100644 --- a/src/compiler/objective_c_generator_helpers.h +++ b/src/compiler/objective_c_generator_helpers.h @@ -46,13 +46,8 @@ using ::grpc::protobuf::FileDescriptor; using ::grpc::protobuf::ServiceDescriptor; using ::grpc::string; -inline string MessageHeaderName(const FileDescriptor *file, - bool dash_as_separator) { - if (dash_as_separator) { - return google::protobuf::compiler::objectivec::FilePath(file) + ".pbobjc.h"; - } else { - return grpc_generator::FileNameInUpperCamel(file) + ".pbobjc.h"; - } +inline string MessageHeaderName(const FileDescriptor *file) { + return google::protobuf::compiler::objectivec::FilePath(file) + ".pbobjc.h"; } inline string ServiceClassName(const ServiceDescriptor *service) { diff --git a/src/compiler/objective_c_plugin.cc b/src/compiler/objective_c_plugin.cc index ff980ae5499..466da4c3b48 100644 --- a/src/compiler/objective_c_plugin.cc +++ b/src/compiler/objective_c_plugin.cc @@ -32,10 +32,6 @@ */ // Generates Objective C gRPC service interface out of Protobuf IDL. -// For legacy reason, output filename of this plugin is by default in uppercamel -// case with dash "-" treated as character and preserved in the output file -// name. If normal upper camel case (dash treated as word separator) is desired, -// use plugin option "filename-dash-as-separator". #include @@ -63,17 +59,8 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { return true; } - ::grpc::string file_name; - - // Simple parameter parsing as we have only one parameter. - // TODO(mxyan): Complete parameter parsing. - bool dash_as_separator = - (0 == parameter.compare("filename-dash-as-separator")); - if (dash_as_separator) { - file_name = google::protobuf::compiler::objectivec::FilePath(file); - } else { - file_name = grpc_generator::FileNameInUpperCamel(file); - } + ::grpc::string file_name = + google::protobuf::compiler::objectivec::FilePath(file); ::grpc::string prefix = file->options().objc_class_prefix(); { @@ -90,8 +77,8 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { // and import the files in the .pbrpc.m ::grpc::string proto_imports; for (int i = 0; i < file->dependency_count(); i++) { - ::grpc::string header = grpc_objective_c_generator::MessageHeaderName( - file->dependency(i), dash_as_separator); + ::grpc::string header = + grpc_objective_c_generator::MessageHeaderName(file->dependency(i)); const grpc::protobuf::FileDescriptor *dependency = file->dependency(i); if (IsProtobufLibraryBundledProtoFile(dependency)) { ::grpc::string base_name = header; From 035f7e4839c272ef48c0c14c8dbf719e3a52a624 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Mon, 12 Jun 2017 09:35:31 -0700 Subject: [PATCH 11/11] Modify copyright information --- .../tests/PluginTest/imported-with-dash.proto | 36 +++++------------- .../tests/PluginTest/test-dash-filename.proto | 38 +++++-------------- 2 files changed, 20 insertions(+), 54 deletions(-) diff --git a/src/objective-c/tests/PluginTest/imported-with-dash.proto b/src/objective-c/tests/PluginTest/imported-with-dash.proto index 0c4ee3827ad..c01bbecc070 100644 --- a/src/objective-c/tests/PluginTest/imported-with-dash.proto +++ b/src/objective-c/tests/PluginTest/imported-with-dash.proto @@ -1,32 +1,16 @@ -// Copyright 2017, Google Inc. -// All rights reserved. +// Copyright 2017 gRPC authors. // -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at // -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. +// http://www.apache.org/licenses/LICENSE-2.0 // -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. syntax = "proto3"; package grpc.testing; diff --git a/src/objective-c/tests/PluginTest/test-dash-filename.proto b/src/objective-c/tests/PluginTest/test-dash-filename.proto index be9386f9608..afbb6035df0 100644 --- a/src/objective-c/tests/PluginTest/test-dash-filename.proto +++ b/src/objective-c/tests/PluginTest/test-dash-filename.proto @@ -1,34 +1,16 @@ -// Copyright 2017, Google Inc. -// All rights reserved. +// Copyright 2017 gRPC authors. // -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at // -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. +// http://www.apache.org/licenses/LICENSE-2.0 // -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// An integration test service that covers all the method signature permutations -// of unary/streaming requests/responses. +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. syntax = "proto3"; package grpc.testing;