Index: third_party/protobuf/src/google/protobuf/compiler/java/java_context.h |
diff --git a/third_party/protobuf/src/google/protobuf/compiler/java/java_extension.h b/third_party/protobuf/src/google/protobuf/compiler/java/java_context.h |
similarity index 52% |
copy from third_party/protobuf/src/google/protobuf/compiler/java/java_extension.h |
copy to third_party/protobuf/src/google/protobuf/compiler/java/java_context.h |
index 009ed9ffacaf207d4fb6322dca43697499b32991..5b595d07fced4d0a4786644c8d56695abbd61680 100644 |
--- a/third_party/protobuf/src/google/protobuf/compiler/java/java_extension.h |
+++ b/third_party/protobuf/src/google/protobuf/compiler/java/java_context.h |
@@ -1,6 +1,6 @@ |
// Protocol Buffers - Google's data interchange format |
// Copyright 2008 Google Inc. All rights reserved. |
-// http://code.google.com/p/protobuf/ |
+// https://developers.google.com/protocol-buffers/ |
// |
// Redistribution and use in source and binary forms, with or without |
// modification, are permitted provided that the following conditions are |
@@ -28,45 +28,66 @@ |
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
-// Author: kenton@google.com (Kenton Varda) |
-// Based on original Protocol Buffers design by |
-// Sanjay Ghemawat, Jeff Dean, and others. |
+#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_CONTEXT_H__ |
+#define GOOGLE_PROTOBUF_COMPILER_JAVA_CONTEXT_H__ |
-#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_EXTENSION_H__ |
-#define GOOGLE_PROTOBUF_COMPILER_JAVA_EXTENSION_H__ |
- |
-#include <string> |
+#include <map> |
+#include <memory> |
+#ifndef _SHARED_PTR_H |
+#include <google/protobuf/stubs/shared_ptr.h> |
+#endif |
+#include <vector> |
#include <google/protobuf/stubs/common.h> |
namespace google { |
namespace protobuf { |
- class FieldDescriptor; // descriptor.h |
- namespace io { |
- class Printer; // printer.h |
+ class FileDescriptor; |
+ class FieldDescriptor; |
+ class OneofDescriptor; |
+ class Descriptor; |
+ namespace compiler { |
+ namespace java { |
+ class ClassNameResolver; // name_resolver.h |
+ } |
} |
-} |
+} // namespace protobuf |
namespace protobuf { |
namespace compiler { |
namespace java { |
-// Generates code for an extension, which may be within the scope of some |
-// message or may be at file scope. This is much simpler than FieldGenerator |
-// since extensions are just simple identifiers with interesting types. |
-class ExtensionGenerator { |
+struct FieldGeneratorInfo; |
+struct OneofGeneratorInfo; |
+// A context object holds the information that is shared among all code |
+// generators. |
+class Context { |
public: |
- explicit ExtensionGenerator(const FieldDescriptor* descriptor); |
- ~ExtensionGenerator(); |
+ explicit Context(const FileDescriptor* file); |
+ ~Context(); |
+ |
+ // Get the name resolver associated with this context. The resolver |
+ // can be used to map descriptors to Java class names. |
+ ClassNameResolver* GetNameResolver(); |
- void Generate(io::Printer* printer); |
- void GenerateNonNestedInitializationCode(io::Printer* printer); |
- void GenerateRegistrationCode(io::Printer* printer); |
+ // Get the FieldGeneratorInfo for a given field. |
+ const FieldGeneratorInfo* GetFieldGeneratorInfo( |
+ const FieldDescriptor* field) const; |
+ |
+ // Get the OneofGeneratorInfo for a given oneof. |
+ const OneofGeneratorInfo* GetOneofGeneratorInfo( |
+ const OneofDescriptor* oneof) const; |
private: |
- const FieldDescriptor* descriptor_; |
- string scope_; |
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ExtensionGenerator); |
+ void InitializeFieldGeneratorInfo(const FileDescriptor* file); |
+ void InitializeFieldGeneratorInfoForMessage(const Descriptor* message); |
+ void InitializeFieldGeneratorInfoForFields( |
+ const vector<const FieldDescriptor*>& fields); |
+ |
+ google::protobuf::scoped_ptr<ClassNameResolver> name_resolver_; |
+ map<const FieldDescriptor*, FieldGeneratorInfo> field_generator_info_map_; |
+ map<const OneofDescriptor*, OneofGeneratorInfo> oneof_generator_info_map_; |
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Context); |
}; |
} // namespace java |
@@ -74,4 +95,4 @@ class ExtensionGenerator { |
} // namespace protobuf |
} // namespace google |
-#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_H__ |
+#endif // GOOGLE_PROTOBUF_COMPILER_JAVA_CONTEXT_H__ |