• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2008 Google Inc.  All rights reserved.
3 //
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file or at
6 // https://developers.google.com/open-source/licenses/bsd
7 
8 #ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_EXTENSION_LITE_H__
9 #define GOOGLE_PROTOBUF_COMPILER_JAVA_EXTENSION_LITE_H__
10 
11 #include <string>
12 
13 #include "google/protobuf/compiler/java/generator_factory.h"
14 #include "google/protobuf/descriptor.h"
15 #include "google/protobuf/port.h"
16 
17 namespace google {
18 namespace protobuf {
19 namespace compiler {
20 namespace java {
21 
22 // Generates code for a lite extension, which may be within the scope of some
23 // message or may be at file scope.  This is much simpler than FieldGenerator
24 // since extensions are just simple identifiers with interesting types.
25 class ImmutableExtensionLiteGenerator : public ExtensionGenerator {
26  public:
27   explicit ImmutableExtensionLiteGenerator(const FieldDescriptor* descriptor,
28                                            Context* context);
29   ImmutableExtensionLiteGenerator(const ImmutableExtensionLiteGenerator&) =
30       delete;
31   ImmutableExtensionLiteGenerator& operator=(
32       const ImmutableExtensionLiteGenerator&) = delete;
33   ~ImmutableExtensionLiteGenerator() override;
34 
35   void Generate(io::Printer* printer) override;
36 
37   // Returns an estimate of the number of bytes the printed code will compile to
38   int GenerateNonNestedInitializationCode(io::Printer* printer) override;
39 
40   // Returns an estimate of the number of bytes the printed code will compile to
41   int GenerateRegistrationCode(io::Printer* printer) override;
42 
43  private:
44   const FieldDescriptor* descriptor_;
45   ClassNameResolver* name_resolver_;
46   std::string scope_;
47   Context* context_;
48 };
49 
50 }  // namespace java
51 }  // namespace compiler
52 }  // namespace protobuf
53 }  // namespace google
54 
55 #endif  // GOOGLE_PROTOBUF_COMPILER_JAVA_EXTENSION_LITE_H__
56