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

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

Issue 2599263002: third_party/protobuf: Update to HEAD (f52e188fe4) (Closed)
Patch Set: Address comments Created 3 years, 12 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 // https://developers.google.com/protocol-buffers/ 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.
(...skipping 21 matching lines...) Expand all
32 #define GOOGLE_PROTOBUF_COMPILER_JAVA_CONTEXT_H__ 32 #define GOOGLE_PROTOBUF_COMPILER_JAVA_CONTEXT_H__
33 33
34 #include <map> 34 #include <map>
35 #include <memory> 35 #include <memory>
36 #ifndef _SHARED_PTR_H 36 #ifndef _SHARED_PTR_H
37 #include <google/protobuf/stubs/shared_ptr.h> 37 #include <google/protobuf/stubs/shared_ptr.h>
38 #endif 38 #endif
39 #include <vector> 39 #include <vector>
40 40
41 #include <google/protobuf/stubs/common.h> 41 #include <google/protobuf/stubs/common.h>
42 #include <google/protobuf/compiler/java/java_options.h>
42 43
43 namespace google { 44 namespace google {
44 namespace protobuf { 45 namespace protobuf {
45 class FileDescriptor; 46 class FileDescriptor;
46 class FieldDescriptor; 47 class FieldDescriptor;
47 class OneofDescriptor; 48 class OneofDescriptor;
48 class Descriptor; 49 class Descriptor;
49 class EnumDescriptor; 50 class EnumDescriptor;
50 namespace compiler { 51 namespace compiler {
51 namespace java { 52 namespace java {
52 class ClassNameResolver; // name_resolver.h 53 class ClassNameResolver; // name_resolver.h
53 } 54 }
54 } 55 }
55 } // namespace protobuf 56 } // namespace protobuf
56 57
57 namespace protobuf { 58 namespace protobuf {
58 namespace compiler { 59 namespace compiler {
59 namespace java { 60 namespace java {
60 61
61 struct FieldGeneratorInfo; 62 struct FieldGeneratorInfo;
62 struct OneofGeneratorInfo; 63 struct OneofGeneratorInfo;
63 // A context object holds the information that is shared among all code 64 // A context object holds the information that is shared among all code
64 // generators. 65 // generators.
65 class Context { 66 class Context {
66 public: 67 public:
67 explicit Context(const FileDescriptor* file); 68 Context(const FileDescriptor* file, const Options& options);
68 ~Context(); 69 ~Context();
69 70
70 // Get the name resolver associated with this context. The resolver 71 // Get the name resolver associated with this context. The resolver
71 // can be used to map descriptors to Java class names. 72 // can be used to map descriptors to Java class names.
72 ClassNameResolver* GetNameResolver(); 73 ClassNameResolver* GetNameResolver();
73 74
74 // Get the FieldGeneratorInfo for a given field. 75 // Get the FieldGeneratorInfo for a given field.
75 const FieldGeneratorInfo* GetFieldGeneratorInfo( 76 const FieldGeneratorInfo* GetFieldGeneratorInfo(
76 const FieldDescriptor* field) const; 77 const FieldDescriptor* field) const;
77 78
78 // Get the OneofGeneratorInfo for a given oneof. 79 // Get the OneofGeneratorInfo for a given oneof.
79 const OneofGeneratorInfo* GetOneofGeneratorInfo( 80 const OneofGeneratorInfo* GetOneofGeneratorInfo(
80 const OneofDescriptor* oneof) const; 81 const OneofDescriptor* oneof) const;
81 82
83 const Options& options() const { return options_; }
84
82 // Enforces all the files (including transitive dependencies) to use 85 // Enforces all the files (including transitive dependencies) to use
83 // LiteRuntime. 86 // LiteRuntime.
84 void SetEnforceLite(bool enforce_lite) {
85 enforce_lite_ = enforce_lite;
86 }
87 87
88 bool EnforceLite() const { 88 bool EnforceLite() const { return options_.enforce_lite; }
89 return enforce_lite_;
90 }
91 89
92 // Does this message class have generated parsing, serialization, and other 90 // Does this message class have generated parsing, serialization, and other
93 // standard methods for which reflection-based fallback implementations exist? 91 // standard methods for which reflection-based fallback implementations exist?
94 bool HasGeneratedMethods(const Descriptor* descriptor) const; 92 bool HasGeneratedMethods(const Descriptor* descriptor) const;
95 93
96 private: 94 private:
97 void InitializeFieldGeneratorInfo(const FileDescriptor* file); 95 void InitializeFieldGeneratorInfo(const FileDescriptor* file);
98 void InitializeFieldGeneratorInfoForMessage(const Descriptor* message); 96 void InitializeFieldGeneratorInfoForMessage(const Descriptor* message);
99 void InitializeFieldGeneratorInfoForFields( 97 void InitializeFieldGeneratorInfoForFields(
100 const vector<const FieldDescriptor*>& fields); 98 const std::vector<const FieldDescriptor*>& fields);
101 99
102 google::protobuf::scoped_ptr<ClassNameResolver> name_resolver_; 100 google::protobuf::scoped_ptr<ClassNameResolver> name_resolver_;
103 map<const FieldDescriptor*, FieldGeneratorInfo> field_generator_info_map_; 101 std::map<const FieldDescriptor*, FieldGeneratorInfo>
104 map<const OneofDescriptor*, OneofGeneratorInfo> oneof_generator_info_map_; 102 field_generator_info_map_;
105 bool enforce_lite_; 103 std::map<const OneofDescriptor*, OneofGeneratorInfo>
104 oneof_generator_info_map_;
105 Options options_;
106 GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Context); 106 GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Context);
107 }; 107 };
108 108
109 } // namespace java 109 } // namespace java
110 } // namespace compiler 110 } // namespace compiler
111 } // namespace protobuf 111 } // namespace protobuf
112 112
113 } // namespace google 113 } // namespace google
114 #endif // GOOGLE_PROTOBUF_COMPILER_JAVA_CONTEXT_H__ 114 #endif // GOOGLE_PROTOBUF_COMPILER_JAVA_CONTEXT_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698