diff options
author | Muxi Yan <mxyan@google.com> | 2017-09-18 17:30:20 -0700 |
---|---|---|
committer | Muxi Yan <mxyan@google.com> | 2017-09-18 18:20:09 -0700 |
commit | 75271d741e61ec82737d4374203f2b9a6f894e03 (patch) | |
tree | 445dcf6052cef9bb4b004ddd28cf4b05ed38d640 /src/compiler/objective_c_generator.cc | |
parent | ab65dc20f75a234864c2a7ef9844da060567033c (diff) |
Generate forward declaration in pbrpc.h
Diffstat (limited to 'src/compiler/objective_c_generator.cc')
-rw-r--r-- | src/compiler/objective_c_generator.cc | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/compiler/objective_c_generator.cc b/src/compiler/objective_c_generator.cc index c05d15375b..33b5fedd5c 100644 --- a/src/compiler/objective_c_generator.cc +++ b/src/compiler/objective_c_generator.cc @@ -17,6 +17,7 @@ */ #include <map> +#include <set> #include <sstream> #include "src/compiler/config.h" @@ -29,7 +30,9 @@ using ::google::protobuf::compiler::objectivec::ClassName; using ::grpc::protobuf::io::Printer; using ::grpc::protobuf::MethodDescriptor; using ::grpc::protobuf::ServiceDescriptor; +using ::grpc::protobuf::FileDescriptor; using ::std::map; +using ::std::set; namespace grpc_objective_c_generator { namespace { @@ -190,6 +193,24 @@ void PrintMethodImplementations(Printer *printer, } // namespace +::grpc::string GetAllMessageClasses(const FileDescriptor *file) { + ::grpc::string output; + set< ::grpc::string> 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++) { + const auto method = service->method(i); + classes.insert(ClassName(method->input_type())); + classes.insert(ClassName(method->output_type())); + } + } + for (auto one_class : classes) { + output += " @class " + one_class + ";\n"; + } + + return output; +} + ::grpc::string GetHeader(const ServiceDescriptor *service) { ::grpc::string output; { |