| OLD | NEW |
| 1 // Protocol Buffers - Google's data interchange format | 1 // Protocol Buffers - Google's data interchange format |
| 2 // Copyright 2008 Google Inc. All rights reserved. | 2 // Copyright 2008 Google Inc. All rights reserved. |
| 3 // http://code.google.com/p/protobuf/ | 3 // http://code.google.com/p/protobuf/ |
| 4 // | 4 // |
| 5 // Redistribution and use in source and binary forms, with or without | 5 // Redistribution and use in source and binary forms, with or without |
| 6 // modification, are permitted provided that the following conditions are | 6 // modification, are permitted provided that the following conditions are |
| 7 // met: | 7 // met: |
| 8 // | 8 // |
| 9 // * Redistributions of source code must retain the above copyright | 9 // * Redistributions of source code must retain the above copyright |
| 10 // notice, this list of conditions and the following disclaimer. | 10 // notice, this list of conditions and the following disclaimer. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 26 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 27 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 27 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 28 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 28 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 29 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 29 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 30 | 30 |
| 31 // Author: kenton@google.com (Kenton Varda) | 31 // Author: kenton@google.com (Kenton Varda) |
| 32 // Based on original Protocol Buffers design by | 32 // Based on original Protocol Buffers design by |
| 33 // Sanjay Ghemawat, Jeff Dean, and others. | 33 // Sanjay Ghemawat, Jeff Dean, and others. |
| 34 | 34 |
| 35 #include <google/protobuf/compiler/java/java_service.h> | 35 #include <google/protobuf/compiler/java/java_service.h> |
| 36 #include <google/protobuf/compiler/java/java_doc_comment.h> |
| 36 #include <google/protobuf/compiler/java/java_helpers.h> | 37 #include <google/protobuf/compiler/java/java_helpers.h> |
| 37 #include <google/protobuf/io/printer.h> | 38 #include <google/protobuf/io/printer.h> |
| 38 #include <google/protobuf/descriptor.pb.h> | 39 #include <google/protobuf/descriptor.pb.h> |
| 39 #include <google/protobuf/stubs/strutil.h> | 40 #include <google/protobuf/stubs/strutil.h> |
| 40 | 41 |
| 41 namespace google { | 42 namespace google { |
| 42 namespace protobuf { | 43 namespace protobuf { |
| 43 namespace compiler { | 44 namespace compiler { |
| 44 namespace java { | 45 namespace java { |
| 45 | 46 |
| 46 ServiceGenerator::ServiceGenerator(const ServiceDescriptor* descriptor) | 47 ServiceGenerator::ServiceGenerator(const ServiceDescriptor* descriptor) |
| 47 : descriptor_(descriptor) {} | 48 : descriptor_(descriptor) {} |
| 48 | 49 |
| 49 ServiceGenerator::~ServiceGenerator() {} | 50 ServiceGenerator::~ServiceGenerator() {} |
| 50 | 51 |
| 51 void ServiceGenerator::Generate(io::Printer* printer) { | 52 void ServiceGenerator::Generate(io::Printer* printer) { |
| 52 bool is_own_file = descriptor_->file()->options().java_multiple_files(); | 53 bool is_own_file = descriptor_->file()->options().java_multiple_files(); |
| 54 WriteServiceDocComment(printer, descriptor_); |
| 53 printer->Print( | 55 printer->Print( |
| 54 "public $static$ abstract class $classname$\n" | 56 "public $static$ abstract class $classname$\n" |
| 55 " implements com.google.protobuf.Service {\n", | 57 " implements com.google.protobuf.Service {\n", |
| 56 "static", is_own_file ? "" : "static", | 58 "static", is_own_file ? "" : "static", |
| 57 "classname", descriptor_->name()); | 59 "classname", descriptor_->name()); |
| 58 printer->Indent(); | 60 printer->Indent(); |
| 59 | 61 |
| 60 printer->Print( | 62 printer->Print( |
| 61 "protected $classname$() {}\n\n", | 63 "protected $classname$() {}\n\n", |
| 62 "classname", descriptor_->name()); | 64 "classname", descriptor_->name()); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 | 158 |
| 157 printer->Outdent(); | 159 printer->Outdent(); |
| 158 printer->Print("};\n"); | 160 printer->Print("};\n"); |
| 159 printer->Outdent(); | 161 printer->Outdent(); |
| 160 printer->Print("}\n\n"); | 162 printer->Print("}\n\n"); |
| 161 } | 163 } |
| 162 | 164 |
| 163 void ServiceGenerator::GenerateAbstractMethods(io::Printer* printer) { | 165 void ServiceGenerator::GenerateAbstractMethods(io::Printer* printer) { |
| 164 for (int i = 0; i < descriptor_->method_count(); i++) { | 166 for (int i = 0; i < descriptor_->method_count(); i++) { |
| 165 const MethodDescriptor* method = descriptor_->method(i); | 167 const MethodDescriptor* method = descriptor_->method(i); |
| 168 WriteMethodDocComment(printer, method); |
| 166 GenerateMethodSignature(printer, method, IS_ABSTRACT); | 169 GenerateMethodSignature(printer, method, IS_ABSTRACT); |
| 167 printer->Print(";\n\n"); | 170 printer->Print(";\n\n"); |
| 168 } | 171 } |
| 169 } | 172 } |
| 170 | 173 |
| 171 void ServiceGenerator::GenerateCallMethod(io::Printer* printer) { | 174 void ServiceGenerator::GenerateCallMethod(io::Printer* printer) { |
| 172 printer->Print( | 175 printer->Print( |
| 173 "\n" | 176 "\n" |
| 174 "public final void callMethod(\n" | 177 "public final void callMethod(\n" |
| 175 " com.google.protobuf.Descriptors.MethodDescriptor method,\n" | 178 " com.google.protobuf.Descriptors.MethodDescriptor method,\n" |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 "public $output$ $method$(\n" | 444 "public $output$ $method$(\n" |
| 442 " com.google.protobuf.RpcController controller,\n" | 445 " com.google.protobuf.RpcController controller,\n" |
| 443 " $input$ request)\n" | 446 " $input$ request)\n" |
| 444 " throws com.google.protobuf.ServiceException"); | 447 " throws com.google.protobuf.ServiceException"); |
| 445 } | 448 } |
| 446 | 449 |
| 447 } // namespace java | 450 } // namespace java |
| 448 } // namespace compiler | 451 } // namespace compiler |
| 449 } // namespace protobuf | 452 } // namespace protobuf |
| 450 } // namespace google | 453 } // namespace google |
| OLD | NEW |