aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/compiler/cpp/cpp_file.h
diff options
context:
space:
mode:
authorGravatar Adam Cozzette <acozzette@google.com>2017-09-12 10:32:01 -0700
committerGravatar Adam Cozzette <acozzette@google.com>2017-09-14 10:03:57 -0700
commit13fd045dbb2b4dacea32be162a41d5a4b0d1802f (patch)
treec219e7eb18b82523e36c6748861c403a14ea66ae /src/google/protobuf/compiler/cpp/cpp_file.h
parentd1bc27caef8377a710370189675cb0958443e8f1 (diff)
Integrated internal changes from Google
Diffstat (limited to 'src/google/protobuf/compiler/cpp/cpp_file.h')
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_file.h35
1 files changed, 26 insertions, 9 deletions
diff --git a/src/google/protobuf/compiler/cpp/cpp_file.h b/src/google/protobuf/compiler/cpp/cpp_file.h
index e10fe2f3..7e61cbad 100644
--- a/src/google/protobuf/compiler/cpp/cpp_file.h
+++ b/src/google/protobuf/compiler/cpp/cpp_file.h
@@ -35,10 +35,12 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_FILE_H__
#define GOOGLE_PROTOBUF_COMPILER_CPP_FILE_H__
+#include <algorithm>
#include <memory>
#ifndef _SHARED_PTR_H
#include <google/protobuf/stubs/shared_ptr.h>
#endif
+#include <set>
#include <string>
#include <vector>
#include <google/protobuf/stubs/common.h>
@@ -82,16 +84,21 @@ class FileGenerator {
const string& info_path);
void GenerateSource(io::Printer* printer);
+ int NumMessages() const { return message_generators_.size(); }
+ // Similar to GenerateSource but generates only one message
+ void GenerateSourceForMessage(int idx, io::Printer* printer);
+ void GenerateGlobalSource(io::Printer* printer);
+
private:
// Internal type used by GenerateForwardDeclarations (defined in file.cc).
class ForwardDeclarations;
- // Generate the BuildDescriptors() procedure, which builds all descriptors
- // for types defined in the file.
- void GenerateBuildDescriptors(io::Printer* printer);
+ void GenerateSourceIncludes(io::Printer* printer);
+ void GenerateSourceDefaultInstance(int idx, io::Printer* printer);
- void GenerateNamespaceOpeners(io::Printer* printer);
- void GenerateNamespaceClosers(io::Printer* printer);
+ void GenerateInitForSCC(const SCC* scc, io::Printer* printer);
+ void GenerateInitializationCode(io::Printer* printer);
+ void GenerateReflectionInitializationCode(io::Printer* printer);
// For other imports, generates their forward-declarations.
void GenerateForwardDeclarations(io::Printer* printer);
@@ -143,11 +150,23 @@ class FileGenerator {
// a breaking change so we prefer the #undef approach.
void GenerateMacroUndefs(io::Printer* printer);
+ bool IsSCCRepresentative(const Descriptor* d) {
+ return GetSCCRepresentative(d) == d;
+ }
+ const Descriptor* GetSCCRepresentative(const Descriptor* d) {
+ return GetSCC(d)->GetRepresentative();
+ }
+ const SCC* GetSCC(const Descriptor* d) {
+ return scc_analyzer_.GetSCC(d);
+ }
+
+
const FileDescriptor* file_;
const Options options_;
SCCAnalyzer scc_analyzer_;
+
// Contains the post-order walk of all the messages (and child messages) in
// this file. If you need a pre-order walk just reverse iterate.
std::vector<MessageGenerator*> message_generators_;
@@ -155,10 +174,8 @@ class FileGenerator {
std::vector<ServiceGenerator*> service_generators_;
std::vector<ExtensionGenerator*> extension_generators_;
- // These members are just for owning (and thus proper deleting). Some of the
- // message_ and enum_generators above are owned by child messages.
- google::protobuf::scoped_array<google::protobuf::scoped_ptr<MessageGenerator> >
- message_generators_owner_;
+ // These members are just for owning (and thus proper deleting).
+ // Nested (enum/extension)_generators are owned by child messages.
google::protobuf::scoped_array<google::protobuf::scoped_ptr<EnumGenerator> > enum_generators_owner_;
google::protobuf::scoped_array<google::protobuf::scoped_ptr<ServiceGenerator> >
service_generators_owner_;