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 24 matching lines...) Expand all Loading... |
35 #ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_FILE_H__ | 35 #ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_FILE_H__ |
36 #define GOOGLE_PROTOBUF_COMPILER_JAVA_FILE_H__ | 36 #define GOOGLE_PROTOBUF_COMPILER_JAVA_FILE_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 #include <google/protobuf/stubs/common.h> | 44 #include <google/protobuf/stubs/common.h> |
45 #include <google/protobuf/compiler/java/java_options.h> | |
46 | 45 |
47 namespace google { | 46 namespace google { |
48 namespace protobuf { | 47 namespace protobuf { |
49 class FileDescriptor; // descriptor.h | 48 class FileDescriptor; // descriptor.h |
50 namespace io { | 49 namespace io { |
51 class Printer; // printer.h | 50 class Printer; // printer.h |
52 } | 51 } |
53 namespace compiler { | 52 namespace compiler { |
54 class GeneratorContext; // code_generator.h | 53 class GeneratorContext; // code_generator.h |
55 namespace java { | 54 namespace java { |
56 class Context; // context.h | 55 class Context; // context.h |
57 class MessageGenerator; // message.h | 56 class MessageGenerator; // message.h |
58 class GeneratorFactory; // generator_factory.h | 57 class GeneratorFactory; // generator_factory.h |
59 class ExtensionGenerator; // extension.h | 58 class ExtensionGenerator; // extension.h |
60 class ClassNameResolver; // name_resolver.h | 59 class ClassNameResolver; // name_resolver.h |
61 } | 60 } |
62 } | 61 } |
63 } | 62 } |
64 | 63 |
65 namespace protobuf { | 64 namespace protobuf { |
66 namespace compiler { | 65 namespace compiler { |
67 namespace java { | 66 namespace java { |
68 | 67 |
69 class FileGenerator { | 68 class FileGenerator { |
70 public: | 69 public: |
71 FileGenerator(const FileDescriptor* file, const Options& options, | 70 FileGenerator(const FileDescriptor* file, bool immutable_api = true, |
72 bool immutable_api = true); | 71 bool enforce_lite = false); |
73 ~FileGenerator(); | 72 ~FileGenerator(); |
74 | 73 |
75 // Checks for problems that would otherwise lead to cryptic compile errors. | 74 // Checks for problems that would otherwise lead to cryptic compile errors. |
76 // Returns true if there are no problems, or writes an error description to | 75 // Returns true if there are no problems, or writes an error description to |
77 // the given string and returns false otherwise. | 76 // the given string and returns false otherwise. |
78 bool Validate(string* error); | 77 bool Validate(string* error); |
79 | 78 |
80 void Generate(io::Printer* printer); | 79 void Generate(io::Printer* printer); |
81 | 80 |
82 // If we aren't putting everything into one file, this will write all the | 81 // If we aren't putting everything into one file, this will write all the |
83 // files other than the outer file (i.e. one for each message, enum, and | 82 // files other than the outer file (i.e. one for each message, enum, and |
84 // service type). | 83 // service type). |
85 void GenerateSiblings(const string& package_dir, | 84 void GenerateSiblings(const string& package_dir, |
86 GeneratorContext* generator_context, | 85 GeneratorContext* generator_context, |
87 std::vector<string>* file_list, | 86 vector<string>* file_list); |
88 std::vector<string>* annotation_list); | |
89 | 87 |
90 const string& java_package() { return java_package_; } | 88 const string& java_package() { return java_package_; } |
91 const string& classname() { return classname_; } | 89 const string& classname() { return classname_; } |
92 | 90 |
| 91 |
93 private: | 92 private: |
94 void GenerateDescriptorInitializationCodeForImmutable(io::Printer* printer); | 93 void GenerateDescriptorInitializationCodeForImmutable(io::Printer* printer); |
95 void GenerateDescriptorInitializationCodeForMutable(io::Printer* printer); | 94 void GenerateDescriptorInitializationCodeForMutable(io::Printer* printer); |
96 | 95 |
97 bool ShouldIncludeDependency(const FileDescriptor* descriptor, | 96 bool ShouldIncludeDependency(const FileDescriptor* descriptor, |
98 bool immutable_api_); | 97 bool immutable_api_); |
99 | 98 |
100 const FileDescriptor* file_; | 99 const FileDescriptor* file_; |
101 string java_package_; | 100 string java_package_; |
102 string classname_; | 101 string classname_; |
103 | 102 |
104 google::protobuf::scoped_array<google::protobuf::scoped_ptr<MessageGenerator>
> message_generators_; | 103 google::protobuf::scoped_array<google::protobuf::scoped_ptr<MessageGenerator>
> message_generators_; |
105 google::protobuf::scoped_array<google::protobuf::scoped_ptr<ExtensionGenerator
> > extension_generators_; | 104 google::protobuf::scoped_array<google::protobuf::scoped_ptr<ExtensionGenerator
> > extension_generators_; |
106 google::protobuf::scoped_ptr<GeneratorFactory> generator_factory_; | 105 google::protobuf::scoped_ptr<GeneratorFactory> generator_factory_; |
107 google::protobuf::scoped_ptr<Context> context_; | 106 google::protobuf::scoped_ptr<Context> context_; |
108 ClassNameResolver* name_resolver_; | 107 ClassNameResolver* name_resolver_; |
109 const Options options_; | |
110 bool immutable_api_; | 108 bool immutable_api_; |
111 | 109 |
| 110 |
112 GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FileGenerator); | 111 GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FileGenerator); |
113 }; | 112 }; |
114 | 113 |
115 } // namespace java | 114 } // namespace java |
116 } // namespace compiler | 115 } // namespace compiler |
117 } // namespace protobuf | 116 } // namespace protobuf |
118 | 117 |
119 } // namespace google | 118 } // namespace google |
120 #endif // GOOGLE_PROTOBUF_COMPILER_JAVA_FILE_H__ | 119 #endif // GOOGLE_PROTOBUF_COMPILER_JAVA_FILE_H__ |
OLD | NEW |