Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1163)

Side by Side Diff: third_party/protobuf/src/google/protobuf/compiler/java/java_extension.h

Issue 1291903002: Pull new version of protobuf sources. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 // https://developers.google.com/protocol-buffers/
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.
11 // * Redistributions in binary form must reproduce the above 11 // * Redistributions in binary form must reproduce the above
12 // copyright notice, this list of conditions and the following disclaimer 12 // copyright notice, this list of conditions and the following disclaimer
13 // in the documentation and/or other materials provided with the 13 // in the documentation and/or other materials provided with the
(...skipping 14 matching lines...) Expand all
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 #ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_EXTENSION_H__ 35 #ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_EXTENSION_H__
36 #define GOOGLE_PROTOBUF_COMPILER_JAVA_EXTENSION_H__ 36 #define GOOGLE_PROTOBUF_COMPILER_JAVA_EXTENSION_H__
37 37
38 #include <map>
38 #include <string> 39 #include <string>
39 40
40 #include <google/protobuf/stubs/common.h> 41 #include <google/protobuf/stubs/common.h>
41 42
42 namespace google { 43 namespace google {
43 namespace protobuf { 44 namespace protobuf {
44 class FieldDescriptor; // descriptor.h 45 class FieldDescriptor; // descriptor.h
46 namespace compiler {
47 namespace java {
48 class Context; // context.h
49 class ClassNameResolver; // name_resolver.h
50 }
51 }
45 namespace io { 52 namespace io {
46 class Printer; // printer.h 53 class Printer; // printer.h
47 } 54 }
48 } 55 }
49 56
50 namespace protobuf { 57 namespace protobuf {
51 namespace compiler { 58 namespace compiler {
52 namespace java { 59 namespace java {
53 60
54 // Generates code for an extension, which may be within the scope of some 61 // Generates code for an extension, which may be within the scope of some
55 // message or may be at file scope. This is much simpler than FieldGenerator 62 // message or may be at file scope. This is much simpler than FieldGenerator
56 // since extensions are just simple identifiers with interesting types. 63 // since extensions are just simple identifiers with interesting types.
57 class ExtensionGenerator { 64 class ExtensionGenerator {
58 public: 65 public:
59 explicit ExtensionGenerator(const FieldDescriptor* descriptor); 66 explicit ExtensionGenerator() {}
60 ~ExtensionGenerator(); 67 virtual ~ExtensionGenerator() {}
61 68
62 void Generate(io::Printer* printer); 69 virtual void Generate(io::Printer* printer) = 0;
63 void GenerateNonNestedInitializationCode(io::Printer* printer); 70
64 void GenerateRegistrationCode(io::Printer* printer); 71 // Returns an estimate of the number of bytes the printed code will compile to
72 virtual int GenerateNonNestedInitializationCode(io::Printer* printer) = 0;
73
74 // Returns an estimate of the number of bytes the printed code will compile to
75 virtual int GenerateRegistrationCode(io::Printer* printer) = 0;
76
77 protected:
78 static void InitTemplateVars(const FieldDescriptor* descriptor,
79 const string& scope,
80 bool immutable,
81 ClassNameResolver* name_resolver,
82 map<string, string>* vars_pointer);
65 83
66 private: 84 private:
67 const FieldDescriptor* descriptor_;
68 string scope_;
69 GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ExtensionGenerator); 85 GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ExtensionGenerator);
70 }; 86 };
71 87
88 class ImmutableExtensionGenerator : public ExtensionGenerator {
89 public:
90 explicit ImmutableExtensionGenerator(const FieldDescriptor* descriptor,
91 Context* context);
92 virtual ~ImmutableExtensionGenerator();
93
94 virtual void Generate(io::Printer* printer);
95 virtual int GenerateNonNestedInitializationCode(io::Printer* printer);
96 virtual int GenerateRegistrationCode(io::Printer* printer);
97
98 protected:
99 const FieldDescriptor* descriptor_;
100 Context* context_;
101 ClassNameResolver* name_resolver_;
102 string scope_;
103
104 private:
105 GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableExtensionGenerator);
106 };
107
72 } // namespace java 108 } // namespace java
73 } // namespace compiler 109 } // namespace compiler
74 } // namespace protobuf 110 } // namespace protobuf
75 111
76 } // namespace google 112 } // namespace google
77 #endif // GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_H__ 113 #endif // GOOGLE_PROTOBUF_COMPILER_JAVA_EXTENSION_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698