OLD | NEW |
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 25 matching lines...) Expand all Loading... |
36 #define GOOGLE_PROTOBUF_COMPILER_JAVA_SHARED_CODE_GENERATOR_H__ | 36 #define GOOGLE_PROTOBUF_COMPILER_JAVA_SHARED_CODE_GENERATOR_H__ |
37 | 37 |
38 #include <memory> | 38 #include <memory> |
39 #ifndef _SHARED_PTR_H | 39 #ifndef _SHARED_PTR_H |
40 #include <google/protobuf/stubs/shared_ptr.h> | 40 #include <google/protobuf/stubs/shared_ptr.h> |
41 #endif | 41 #endif |
42 #include <string> | 42 #include <string> |
43 #include <vector> | 43 #include <vector> |
44 | 44 |
45 #include <google/protobuf/stubs/common.h> | 45 #include <google/protobuf/stubs/common.h> |
46 #include <google/protobuf/compiler/java/java_options.h> | |
47 | 46 |
48 namespace google { | 47 namespace google { |
49 namespace protobuf { | 48 namespace protobuf { |
50 class FileDescriptor; // descriptor.h | 49 class FileDescriptor; // descriptor.h |
51 namespace compiler { | 50 namespace compiler { |
52 class GeneratorContext; // code_generator.h | 51 class GeneratorContext; // code_generator.h |
53 namespace java { | 52 namespace java { |
54 class ClassNameResolver; // name_resolver.h | 53 class ClassNameResolver; // name_resolver.h |
55 } | 54 } |
56 } | 55 } |
57 namespace io { | 56 namespace io { |
58 class Printer; // printer.h | 57 class Printer; // printer.h |
59 } | 58 } |
60 } | 59 } |
61 | 60 |
62 namespace protobuf { | 61 namespace protobuf { |
63 namespace compiler { | 62 namespace compiler { |
64 namespace java { | 63 namespace java { |
65 | 64 |
66 // A generator that generates code that are shared between immutable API | 65 // A generator that generates code that are shared between immutable API |
67 // and mutable API. Currently only descriptors are shared. | 66 // and mutable API. Currently only descriptors are shared. |
68 class SharedCodeGenerator { | 67 class SharedCodeGenerator { |
69 public: | 68 public: |
70 SharedCodeGenerator(const FileDescriptor* file, const Options& options); | 69 explicit SharedCodeGenerator(const FileDescriptor* file); |
71 ~SharedCodeGenerator(); | 70 ~SharedCodeGenerator(); |
72 | 71 |
73 void Generate(GeneratorContext* generator_context, | 72 void Generate(GeneratorContext* generator_context, |
74 std::vector<string>* file_list, | 73 vector<string>* file_list); |
75 std::vector<string>* annotation_file_list); | 74 |
| 75 void SetEnforceLite(bool value) { |
| 76 enforce_lite_ = value; |
| 77 } |
76 | 78 |
77 void GenerateDescriptors(io::Printer* printer); | 79 void GenerateDescriptors(io::Printer* printer); |
78 | 80 |
79 private: | 81 private: |
80 // Returns whether the dependency should be included in the output file. | 82 // Returns whether the dependency should be included in the output file. |
81 // Always returns true for opensource, but used internally at Google to help | 83 // Always returns true for opensource, but used internally at Google to help |
82 // improve compatibility with version 1 of protocol buffers. | 84 // improve compatibility with version 1 of protocol buffers. |
83 bool ShouldIncludeDependency(const FileDescriptor* descriptor); | 85 bool ShouldIncludeDependency(const FileDescriptor* descriptor); |
84 | 86 |
85 google::protobuf::scoped_ptr<ClassNameResolver> name_resolver_; | 87 google::protobuf::scoped_ptr<ClassNameResolver> name_resolver_; |
| 88 bool enforce_lite_; |
86 const FileDescriptor* file_; | 89 const FileDescriptor* file_; |
87 const Options options_; | |
88 GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(SharedCodeGenerator); | 90 GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(SharedCodeGenerator); |
89 }; | 91 }; |
90 | 92 |
91 | 93 |
92 } // namespace java | 94 } // namespace java |
93 } // namespace compiler | 95 } // namespace compiler |
94 } // namespace protobuf | 96 } // namespace protobuf |
95 | 97 |
96 } // namespace google | 98 } // namespace google |
97 #endif // GOOGLE_PROTOBUF_COMPILER_JAVA_SHARED_CODE_GENERATOR_H__ | 99 #endif // GOOGLE_PROTOBUF_COMPILER_JAVA_SHARED_CODE_GENERATOR_H__ |
OLD | NEW |