protobuf/src/google/protobuf/compiler/java/java_extension.h
Go to the documentation of this file.
1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2008 Google Inc. All rights reserved.
3 // https://developers.google.com/protocol-buffers/
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 // * Redistributions in binary form must reproduce the above
12 // copyright notice, this list of conditions and the following disclaimer
13 // in the documentation and/or other materials provided with the
14 // distribution.
15 // * Neither the name of Google Inc. nor the names of its
16 // contributors may be used to endorse or promote products derived from
17 // this software without specific prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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.
30 
31 // Author: kenton@google.com (Kenton Varda)
32 // Based on original Protocol Buffers design by
33 // Sanjay Ghemawat, Jeff Dean, and others.
34 
35 #ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_EXTENSION_H__
36 #define GOOGLE_PROTOBUF_COMPILER_JAVA_EXTENSION_H__
37 
38 #include <map>
39 #include <string>
40 
41 #include <google/protobuf/stubs/common.h>
42 
43 namespace google {
44 namespace protobuf {
45 class FieldDescriptor; // descriptor.h
46 namespace compiler {
47 namespace java {
48 class Context; // context.h
49 class ClassNameResolver; // name_resolver.h
50 } // namespace java
51 } // namespace compiler
52 namespace io {
53 class Printer; // printer.h
54 }
55 } // namespace protobuf
56 } // namespace google
57 
58 namespace google {
59 namespace protobuf {
60 namespace compiler {
61 namespace java {
62 
63 // Generates code for an extension, which may be within the scope of some
64 // message or may be at file scope. This is much simpler than FieldGenerator
65 // since extensions are just simple identifiers with interesting types.
66 class ExtensionGenerator {
67  public:
68  explicit ExtensionGenerator() {}
69  virtual ~ExtensionGenerator() {}
70 
71  virtual void Generate(io::Printer* printer) = 0;
72 
73  // Returns an estimate of the number of bytes the printed code will compile
74  // to
75  virtual int GenerateNonNestedInitializationCode(io::Printer* printer) = 0;
76 
77  // Returns an estimate of the number of bytes the printed code will compile
78  // to
79  virtual int GenerateRegistrationCode(io::Printer* printer) = 0;
80 
81  protected:
82  static void InitTemplateVars(
83  const FieldDescriptor* descriptor, const std::string& scope,
84  bool immutable, ClassNameResolver* name_resolver,
85  std::map<std::string, std::string>* vars_pointer);
86 
87  private:
89 };
90 
91 class ImmutableExtensionGenerator : public ExtensionGenerator {
92  public:
94  Context* context);
96 
97  void Generate(io::Printer* printer) override;
98  int GenerateNonNestedInitializationCode(io::Printer* printer) override;
99  int GenerateRegistrationCode(io::Printer* printer) override;
100 
101  protected:
103  ClassNameResolver* name_resolver_;
105 
106  private:
108 };
109 
110 } // namespace java
111 } // namespace compiler
112 } // namespace protobuf
113 } // namespace google
114 
115 #endif // GOOGLE_PROTOBUF_COMPILER_JAVA_EXTENSION_H__
google::protobuf::FieldDescriptor
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:515
google::protobuf::compiler::java::ImmutableExtensionGenerator::ImmutableExtensionGenerator
ImmutableExtensionGenerator(const FieldDescriptor *descriptor, Context *context)
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_extension.cc:49
google::protobuf::compiler::java::ImmutableExtensionGenerator::GOOGLE_DISALLOW_EVIL_CONSTRUCTORS
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableExtensionGenerator)
google::protobuf::compiler::java::ExtensionGenerator
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_extension.h:66
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
grpc::protobuf::io::Printer
GRPC_CUSTOM_PRINTER Printer
Definition: src/compiler/config.h:54
google::protobuf
Definition: bloaty/third_party/protobuf/benchmarks/util/data_proto2_to_proto3_util.h:12
google::protobuf::compiler::java::ExtensionGenerator::GOOGLE_DISALLOW_EVIL_CONSTRUCTORS
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ExtensionGenerator)
google::protobuf::compiler::java::ImmutableExtensionGenerator::Generate
virtual void Generate(io::Printer *printer)
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_extension.cc:112
FieldDescriptor
Definition: bloaty/third_party/protobuf/ruby/ext/google/protobuf_c/protobuf.h:133
google::protobuf::compiler::java::ImmutableExtensionGenerator::GenerateNonNestedInitializationCode
virtual int GenerateNonNestedInitializationCode(io::Printer *printer)
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_extension.cc:148
google::protobuf::compiler::java::ExtensionGenerator::Generate
virtual void Generate(io::Printer *printer)=0
google::protobuf::compiler::java::ExtensionGenerator::ExtensionGenerator
ExtensionGenerator()
Definition: protobuf/src/google/protobuf/compiler/java/java_extension.h:68
io
google::protobuf::compiler::java::ExtensionGenerator::InitTemplateVars
static void InitTemplateVars(const FieldDescriptor *descriptor, const std::string &scope, bool immutable, ClassNameResolver *name_resolver, std::map< std::string, std::string > *vars_pointer)
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_extension.cc:63
google::protobuf::compiler::java::ImmutableExtensionGenerator::scope_
std::string scope_
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_extension.h:104
google::protobuf::io::Printer
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/printer.h:181
java
google::protobuf::compiler::java::ExtensionGenerator::GenerateRegistrationCode
virtual int GenerateRegistrationCode(io::Printer *printer)=0
google::protobuf::compiler::java::ImmutableExtensionGenerator::name_resolver_
ClassNameResolver * name_resolver_
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_extension.h:103
google::protobuf::compiler::java::ImmutableExtensionGenerator::~ImmutableExtensionGenerator
virtual ~ImmutableExtensionGenerator()
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_extension.cc:60
google::protobuf::compiler::java::ImmutableExtensionGenerator::GenerateRegistrationCode
virtual int GenerateRegistrationCode(io::Printer *printer)
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_extension.cc:162
google::protobuf::compiler::java::ImmutableExtensionGenerator::descriptor_
const FieldDescriptor * descriptor_
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_extension.h:102
context
grpc::ClientContext context
Definition: istio_echo_server_lib.cc:61
google::protobuf::compiler::java::ClassNameResolver
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/java/java_name_resolver.h:56
google::protobuf::compiler::java::ExtensionGenerator::~ExtensionGenerator
virtual ~ExtensionGenerator()
Definition: protobuf/src/google/protobuf/compiler/java/java_extension.h:69
descriptor
static const char descriptor[1336]
Definition: certs.upbdefs.c:16
compiler
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/plugin.pb.cc:21
google
Definition: bloaty/third_party/protobuf/benchmarks/util/data_proto2_to_proto3_util.h:11
google::protobuf::compiler::java::ExtensionGenerator::GenerateNonNestedInitializationCode
virtual int GenerateNonNestedInitializationCode(io::Printer *printer)=0


grpc
Author(s):
autogenerated on Fri May 16 2025 02:59:09