Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-31 10:11:57

0001 // Protocol Buffers - Google's data interchange format
0002 // Copyright 2008 Google Inc.  All rights reserved.
0003 //
0004 // Use of this source code is governed by a BSD-style
0005 // license that can be found in the LICENSE file or at
0006 // https://developers.google.com/open-source/licenses/bsd
0007 
0008 // Author: kenton@google.com (Kenton Varda)
0009 //  Based on original Protocol Buffers design by
0010 //  Sanjay Ghemawat, Jeff Dean, and others.
0011 
0012 #ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_SERVICE_H__
0013 #define GOOGLE_PROTOBUF_COMPILER_JAVA_SERVICE_H__
0014 
0015 #include "google/protobuf/compiler/java/generator_factory.h"
0016 #include "google/protobuf/descriptor.h"
0017 
0018 namespace google {
0019 namespace protobuf {
0020 namespace compiler {
0021 namespace java {
0022 class Context;            // context.h
0023 class ClassNameResolver;  // name_resolver.h
0024 }  // namespace java
0025 }  // namespace compiler
0026 namespace io {
0027 class Printer;  // printer.h
0028 }
0029 }  // namespace protobuf
0030 }  // namespace google
0031 
0032 namespace google {
0033 namespace protobuf {
0034 namespace compiler {
0035 namespace java {
0036 
0037 class ImmutableServiceGenerator : public ServiceGenerator {
0038  public:
0039   ImmutableServiceGenerator(const ServiceDescriptor* descriptor,
0040                             Context* context);
0041   ImmutableServiceGenerator(const ImmutableServiceGenerator&) = delete;
0042   ImmutableServiceGenerator& operator=(const ImmutableServiceGenerator&) =
0043       delete;
0044   ~ImmutableServiceGenerator() override;
0045 
0046   void Generate(io::Printer* printer) override;
0047 
0048  private:
0049   // Generate the getDescriptorForType() method.
0050   void GenerateGetDescriptorForType(io::Printer* printer);
0051 
0052   // Generate a Java interface for the service.
0053   void GenerateInterface(io::Printer* printer);
0054 
0055   // Generate newReflectiveService() method.
0056   void GenerateNewReflectiveServiceMethod(io::Printer* printer);
0057 
0058   // Generate newReflectiveBlockingService() method.
0059   void GenerateNewReflectiveBlockingServiceMethod(io::Printer* printer);
0060 
0061   // Generate abstract method declarations for all methods.
0062   void GenerateAbstractMethods(io::Printer* printer);
0063 
0064   // Generate the implementation of Service.callMethod().
0065   void GenerateCallMethod(io::Printer* printer);
0066 
0067   // Generate the implementation of BlockingService.callBlockingMethod().
0068   void GenerateCallBlockingMethod(io::Printer* printer);
0069 
0070   // Generate the implementations of Service.get{Request,Response}Prototype().
0071   void GenerateGetPrototype(RequestOrResponse which, io::Printer* printer);
0072 
0073   // Generate a stub implementation of the service.
0074   void GenerateStub(io::Printer* printer);
0075 
0076   // Generate a method signature, possibly abstract, without body or trailing
0077   // semicolon.
0078   void GenerateMethodSignature(io::Printer* printer,
0079                                const MethodDescriptor* method,
0080                                IsAbstract is_abstract);
0081 
0082   // Generate a blocking stub interface and implementation of the service.
0083   void GenerateBlockingStub(io::Printer* printer);
0084 
0085   // Generate the method signature for one method of a blocking stub.
0086   void GenerateBlockingMethodSignature(io::Printer* printer,
0087                                        const MethodDescriptor* method);
0088 
0089   // Return the output type of the method.
0090   std::string GetOutput(const MethodDescriptor* method);
0091 
0092   Context* context_;
0093   ClassNameResolver* name_resolver_;
0094 };
0095 
0096 }  // namespace java
0097 }  // namespace compiler
0098 }  // namespace protobuf
0099 }  // namespace google
0100 
0101 #endif  // NET_PROTO2_COMPILER_JAVA_SERVICE_H__