aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/compiler
diff options
context:
space:
mode:
Diffstat (limited to 'src/google/protobuf/compiler')
-rw-r--r--src/google/protobuf/compiler/code_generator.h2
-rw-r--r--src/google/protobuf/compiler/command_line_interface.cc57
-rw-r--r--src/google/protobuf/compiler/command_line_interface.h7
-rw-r--r--src/google/protobuf/compiler/command_line_interface_unittest.cc40
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc14
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_enum_field.cc16
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_file.cc154
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_file.h3
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_generator.cc2
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_helpers.cc103
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_helpers.h67
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_map_field.cc79
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_map_field.h2
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_message.cc911
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_message.h33
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_message_field.cc20
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_message_field.h2
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_options.h8
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_primitive_field.cc19
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_string_field.cc14
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_unittest.cc56
-rw-r--r--src/google/protobuf/compiler/importer.cc1
-rw-r--r--src/google/protobuf/compiler/importer.h1
-rw-r--r--src/google/protobuf/compiler/importer_unittest.cc2
-rw-r--r--src/google/protobuf/compiler/java/java_enum_field_lite.cc3
-rw-r--r--src/google/protobuf/compiler/java/java_enum_lite.cc51
-rw-r--r--src/google/protobuf/compiler/java/java_field.h1
-rw-r--r--src/google/protobuf/compiler/java/java_file.cc6
-rw-r--r--src/google/protobuf/compiler/java/java_generator.cc1
-rw-r--r--src/google/protobuf/compiler/java/java_helpers.cc2
-rw-r--r--src/google/protobuf/compiler/java/java_lazy_message_field_lite.cc3
-rw-r--r--src/google/protobuf/compiler/java/java_lazy_message_field_lite.h3
-rw-r--r--src/google/protobuf/compiler/java/java_map_field_lite.cc1
-rw-r--r--src/google/protobuf/compiler/java/java_map_field_lite.h1
-rw-r--r--src/google/protobuf/compiler/java/java_message.cc11
-rw-r--r--src/google/protobuf/compiler/java/java_message_builder_lite.cc7
-rw-r--r--src/google/protobuf/compiler/java/java_message_field_lite.cc2
-rw-r--r--src/google/protobuf/compiler/java/java_message_field_lite.h2
-rw-r--r--src/google/protobuf/compiler/java/java_message_lite.cc29
-rw-r--r--src/google/protobuf/compiler/java/java_primitive_field_lite.cc2
-rw-r--r--src/google/protobuf/compiler/java/java_primitive_field_lite.h3
-rw-r--r--src/google/protobuf/compiler/java/java_string_field_lite.cc3
-rw-r--r--src/google/protobuf/compiler/java/java_string_field_lite.h3
-rw-r--r--src/google/protobuf/compiler/js/embed.cc2
-rwxr-xr-xsrc/google/protobuf/compiler/js/js_generator.cc177
-rw-r--r--src/google/protobuf/compiler/js/well_known_types/timestamp.js1
-rw-r--r--src/google/protobuf/compiler/mock_code_generator.cc12
-rw-r--r--src/google/protobuf/compiler/parser_unittest.cc7
-rw-r--r--src/google/protobuf/compiler/plugin.pb.cc197
-rw-r--r--src/google/protobuf/compiler/plugin.pb.h42
-rw-r--r--src/google/protobuf/compiler/plugin.proto3
-rw-r--r--src/google/protobuf/compiler/profile.pb.cc1442
-rw-r--r--src/google/protobuf/compiler/profile.pb.h728
-rw-r--r--src/google/protobuf/compiler/profile.proto68
-rw-r--r--src/google/protobuf/compiler/test_plugin.cc1
-rw-r--r--src/google/protobuf/compiler/zip_writer.cc30
-rw-r--r--src/google/protobuf/compiler/zip_writer.h30
57 files changed, 3827 insertions, 660 deletions
diff --git a/src/google/protobuf/compiler/code_generator.h b/src/google/protobuf/compiler/code_generator.h
index e2b2a661..b917d373 100644
--- a/src/google/protobuf/compiler/code_generator.h
+++ b/src/google/protobuf/compiler/code_generator.h
@@ -162,7 +162,7 @@ typedef GeneratorContext OutputDirectory;
// "foo=bar,baz,qux=corge"
// parses to the pairs:
// ("foo", "bar"), ("baz", ""), ("qux", "corge")
-extern void LIBPROTOC_EXPORT ParseGeneratorParameter(const string&,
+extern void ParseGeneratorParameter(const string&,
std::vector<std::pair<string, string> >*);
} // namespace compiler
diff --git a/src/google/protobuf/compiler/command_line_interface.cc b/src/google/protobuf/compiler/command_line_interface.cc
index f516477b..30a79c5d 100644
--- a/src/google/protobuf/compiler/command_line_interface.cc
+++ b/src/google/protobuf/compiler/command_line_interface.cc
@@ -816,11 +816,11 @@ int CommandLineInterface::Run(int argc, const char* const argv[]) {
if (direct_dependencies_.find(parsed_file->dependency(i)->name()) ==
direct_dependencies_.end()) {
indirect_imports = true;
- cerr << parsed_file->name() << ": "
- << StringReplace(direct_dependencies_violation_msg_, "%s",
- parsed_file->dependency(i)->name(),
- true /* replace_all */)
- << std::endl;
+ std::cerr << parsed_file->name() << ": "
+ << StringReplace(direct_dependencies_violation_msg_, "%s",
+ parsed_file->dependency(i)->name(),
+ true /* replace_all */)
+ << std::endl;
}
}
if (indirect_imports) {
@@ -1038,7 +1038,7 @@ CommandLineInterface::ParseArguments(int argc, const char* const argv[]) {
// Make sure each plugin option has a matching plugin output.
bool foundUnknownPluginOption = false;
- for (map<string, string>::const_iterator i = plugin_parameters_.begin();
+ for (std::map<string, string>::const_iterator i = plugin_parameters_.begin();
i != plugin_parameters_.end(); ++i) {
if (plugins_.find(i->first) != plugins_.end()) {
continue;
@@ -1221,7 +1221,8 @@ CommandLineInterface::InterpretArgument(const string& name,
if (access(disk_path.c_str(), F_OK) < 0) {
// Try the original path; it may have just happed to have a '=' in it.
if (access(parts[i].c_str(), F_OK) < 0) {
- cerr << disk_path << ": warning: directory does not exist." << endl;
+ std::cerr << disk_path << ": warning: directory does not exist."
+ << std::endl;
} else {
virtual_path = "";
disk_path = parts[i];
@@ -1391,6 +1392,7 @@ CommandLineInterface::InterpretArgument(const string& name,
}
mode_ = MODE_PRINT;
print_mode_ = PRINT_FREE_FIELDS;
+ } else if (name == "--profile_path") {
} else {
// Some other flag. Look it up in the generators list.
const GeneratorInfo* generator_info =
@@ -1790,31 +1792,34 @@ bool CommandLineInterface::EncodeOrDecode(const DescriptorPool* pool) {
}
bool CommandLineInterface::WriteDescriptorSet(
- const std::vector<const FileDescriptor*> parsed_files) {
+ const std::vector<const FileDescriptor*>& parsed_files) {
FileDescriptorSet file_set;
- if (imports_in_descriptor_set_) {
- std::set<const FileDescriptor*> already_seen;
- for (int i = 0; i < parsed_files.size(); i++) {
- GetTransitiveDependencies(parsed_files[i],
- true, // Include json_name
- source_info_in_descriptor_set_,
- &already_seen, file_set.mutable_file());
- }
- } else {
- std::set<const FileDescriptor*> already_seen;
+ std::set<const FileDescriptor*> already_seen;
+ if (!imports_in_descriptor_set_) {
+ // Since we don't want to output transitive dependencies, but we do want
+ // things to be in dependency order, add all dependencies that aren't in
+ // parsed_files to already_seen. This will short circuit the recursion
+ // in GetTransitiveDependencies.
+ std::set<const FileDescriptor*> to_output;
+ to_output.insert(parsed_files.begin(), parsed_files.end());
for (int i = 0; i < parsed_files.size(); i++) {
- if (!already_seen.insert(parsed_files[i]).second) {
- continue;
- }
- FileDescriptorProto* file_proto = file_set.add_file();
- parsed_files[i]->CopyTo(file_proto);
- parsed_files[i]->CopyJsonNameTo(file_proto);
- if (source_info_in_descriptor_set_) {
- parsed_files[i]->CopySourceCodeInfoTo(file_proto);
+ const FileDescriptor* file = parsed_files[i];
+ for (int i = 0; i < file->dependency_count(); i++) {
+ const FileDescriptor* dependency = file->dependency(i);
+ // if the dependency isn't in parsed files, mark it as already seen
+ if (to_output.find(dependency) == to_output.end()) {
+ already_seen.insert(dependency);
+ }
}
}
}
+ for (int i = 0; i < parsed_files.size(); i++) {
+ GetTransitiveDependencies(parsed_files[i],
+ true, // Include json_name
+ source_info_in_descriptor_set_,
+ &already_seen, file_set.mutable_file());
+ }
int fd;
do {
diff --git a/src/google/protobuf/compiler/command_line_interface.h b/src/google/protobuf/compiler/command_line_interface.h
index 8f8c2682..997c1748 100644
--- a/src/google/protobuf/compiler/command_line_interface.h
+++ b/src/google/protobuf/compiler/command_line_interface.h
@@ -258,7 +258,7 @@ class LIBPROTOC_EXPORT CommandLineInterface {
// Implements the --descriptor_set_out option.
bool WriteDescriptorSet(
- const std::vector<const FileDescriptor*> parsed_files);
+ const std::vector<const FileDescriptor*>& parsed_files);
// Implements the --dependency_out option
bool GenerateDependencyManifestFile(
@@ -391,6 +391,11 @@ class LIBPROTOC_EXPORT CommandLineInterface {
// dependency file will be written. Otherwise, empty.
string dependency_out_name_;
+ // Path to a file that contains serialized AccessInfo which provides
+ // relative hotness of fields per message. This helps protoc to generate
+ // better code.
+ string profile_path_;
+
// True if --include_imports was given, meaning that we should
// write all transitive dependencies to the DescriptorSet. Otherwise, only
// the .proto files listed on the command-line are added.
diff --git a/src/google/protobuf/compiler/command_line_interface_unittest.cc b/src/google/protobuf/compiler/command_line_interface_unittest.cc
index eab14f60..366e623f 100644
--- a/src/google/protobuf/compiler/command_line_interface_unittest.cc
+++ b/src/google/protobuf/compiler/command_line_interface_unittest.cc
@@ -32,9 +32,9 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <sys/types.h>
-#include <sys/stat.h>
#include <fcntl.h>
+#include <sys/stat.h>
+#include <sys/types.h>
#ifdef _MSC_VER
#include <io.h>
#else
@@ -46,25 +46,25 @@
#endif
#include <vector>
-#include <google/protobuf/descriptor.pb.h>
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/io/zero_copy_stream.h>
-#include <google/protobuf/compiler/command_line_interface.h>
-#include <google/protobuf/compiler/code_generator.h>
+#include <google/protobuf/stubs/stringprintf.h>
+#include <google/protobuf/testing/file.h>
#include <google/protobuf/testing/file.h>
#include <google/protobuf/compiler/mock_code_generator.h>
#include <google/protobuf/compiler/subprocess.h>
-#include <google/protobuf/io/printer.h>
+#include <google/protobuf/compiler/code_generator.h>
+#include <google/protobuf/compiler/command_line_interface.h>
#include <google/protobuf/unittest.pb.h>
-#include <google/protobuf/testing/file.h>
-#include <google/protobuf/stubs/stringprintf.h>
-#include <google/protobuf/stubs/strutil.h>
+#include <google/protobuf/io/printer.h>
+#include <google/protobuf/io/zero_copy_stream.h>
+#include <google/protobuf/descriptor.pb.h>
+#include <google/protobuf/descriptor.h>
#include <google/protobuf/stubs/substitute.h>
#include <google/protobuf/testing/file.h>
#include <google/protobuf/testing/googletest.h>
#include <gtest/gtest.h>
+#include <google/protobuf/stubs/strutil.h>
namespace google {
namespace protobuf {
@@ -101,7 +101,7 @@ class CommandLineInterfaceTest : public testing::Test {
// command is automatically split on spaces, and the string "$tmpdir"
// is replaced with TestTempDir().
void Run(const string& command);
- void RunWithArgs(vector<string> args);
+ void RunWithArgs(std::vector<string> args);
// -----------------------------------------------------------------
// Methods to set up the test (called before Run()).
@@ -301,7 +301,7 @@ void CommandLineInterfaceTest::Run(const string& command) {
RunWithArgs(Split(command, " ", true));
}
-void CommandLineInterfaceTest::RunWithArgs(vector<string> args) {
+void CommandLineInterfaceTest::RunWithArgs(std::vector<string> args) {
if (!disallow_plugins_) {
cli_.AllowPlugins("prefix-");
#ifndef GOOGLE_THIRD_PARTY_PROTOBUF
@@ -1044,7 +1044,7 @@ TEST_F(CommandLineInterfaceTest, DirectDependencies_CustomErrorMessage) {
"syntax = \"proto2\";\n"
"message Bar { optional string text = 1; }");
- vector<string> commands;
+ std::vector<string> commands;
commands.push_back("protocol_compiler");
commands.push_back("--test_out=$tmpdir");
commands.push_back("--proto_path=$tmpdir");
@@ -1127,15 +1127,17 @@ TEST_F(CommandLineInterfaceTest, WriteDescriptorSetWithDuplicates) {
ReadDescriptorSet("descriptor_set", &descriptor_set);
if (HasFatalFailure()) return;
EXPECT_EQ(3, descriptor_set.file_size());
- EXPECT_EQ("bar.proto", descriptor_set.file(0).name());
- EXPECT_EQ("foo.proto", descriptor_set.file(1).name());
+ // foo should come first since the output is in dependency order.
+ // since bar and baz are unordered, they should be in command line order.
+ EXPECT_EQ("foo.proto", descriptor_set.file(0).name());
+ EXPECT_EQ("bar.proto", descriptor_set.file(1).name());
EXPECT_EQ("baz.proto", descriptor_set.file(2).name());
// Descriptor set should not have source code info.
EXPECT_FALSE(descriptor_set.file(0).has_source_code_info());
// Descriptor set should have json_name.
- EXPECT_EQ("Bar", descriptor_set.file(0).message_type(0).name());
- EXPECT_EQ("foo", descriptor_set.file(0).message_type(0).field(0).name());
- EXPECT_TRUE(descriptor_set.file(0).message_type(0).field(0).has_json_name());
+ EXPECT_EQ("Bar", descriptor_set.file(1).message_type(0).name());
+ EXPECT_EQ("foo", descriptor_set.file(1).message_type(0).field(0).name());
+ EXPECT_TRUE(descriptor_set.file(1).message_type(0).field(0).has_json_name());
}
TEST_F(CommandLineInterfaceTest, WriteDescriptorSetWithSourceInfo) {
diff --git a/src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc b/src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc
index bf4e5831..fce58c02 100644
--- a/src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc
@@ -46,12 +46,11 @@
#include <google/protobuf/compiler/cpp/cpp_generator.h>
#include <google/protobuf/compiler/importer.h>
-#include <google/protobuf/descriptor.h>
#include <google/protobuf/io/zero_copy_stream_impl.h>
+#include <google/protobuf/descriptor.h>
+#include <google/protobuf/stubs/substitute.h>
#include <google/protobuf/stubs/map_util.h>
#include <google/protobuf/stubs/stl_util.h>
-#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/stubs/substitute.h>
#include <google/protobuf/testing/file.h>
#include <google/protobuf/testing/file.h>
@@ -126,9 +125,12 @@ TEST(BootstrapTest, GeneratedDescriptorMatches) {
importer.Import("google/protobuf/descriptor.proto");
const FileDescriptor* plugin_proto_file =
importer.Import("google/protobuf/compiler/plugin.proto");
+ const FileDescriptor* profile_proto_file =
+ importer.Import("google/protobuf/compiler/profile.proto");
EXPECT_EQ("", error_collector.text_);
ASSERT_TRUE(proto_file != NULL);
ASSERT_TRUE(plugin_proto_file != NULL);
+ ASSERT_TRUE(profile_proto_file != NULL);
CppGenerator generator;
MockGeneratorContext context;
@@ -139,6 +141,8 @@ TEST(BootstrapTest, GeneratedDescriptorMatches) {
parameter = "dllexport_decl=LIBPROTOC_EXPORT";
ASSERT_TRUE(generator.Generate(plugin_proto_file, parameter,
&context, &error));
+ ASSERT_TRUE(generator.Generate(profile_proto_file, parameter,
+ &context, &error));
context.ExpectFileMatches("google/protobuf/descriptor.pb.h",
"google/protobuf/descriptor.pb.h");
@@ -148,6 +152,10 @@ TEST(BootstrapTest, GeneratedDescriptorMatches) {
"google/protobuf/compiler/plugin.pb.h");
context.ExpectFileMatches("google/protobuf/compiler/plugin.pb.cc",
"google/protobuf/compiler/plugin.pb.cc");
+ context.ExpectFileMatches("google/protobuf/compiler/profile.pb.h",
+ "google/protobuf/compiler/profile.pb.h");
+ context.ExpectFileMatches("google/protobuf/compiler/profile.pb.cc",
+ "google/protobuf/compiler/profile.pb.cc");
}
} // namespace
diff --git a/src/google/protobuf/compiler/cpp/cpp_enum_field.cc b/src/google/protobuf/compiler/cpp/cpp_enum_field.cc
index e4b17a98..c15be942 100644
--- a/src/google/protobuf/compiler/cpp/cpp_enum_field.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_enum_field.cc
@@ -318,7 +318,7 @@ GenerateMergingCode(io::Printer* printer) const {
void RepeatedEnumFieldGenerator::
GenerateSwappingCode(io::Printer* printer) const {
- printer->Print(variables_, "$name$_.UnsafeArenaSwap(&other->$name$_);\n");
+ printer->Print(variables_, "$name$_.InternalSwap(&other->$name$_);\n");
}
void RepeatedEnumFieldGenerator::
@@ -461,20 +461,14 @@ GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const {
" target);\n"
" target = ::google::protobuf::io::CodedOutputStream::WriteVarint32ToArray("
" _$name$_cached_byte_size_, target);\n"
- "}\n");
- }
- printer->Print(variables_,
- "for (int i = 0, n = this->$name$_size(); i < n; i++) {\n");
- if (descriptor_->is_packed()) {
- printer->Print(variables_,
" target = ::google::protobuf::internal::WireFormatLite::WriteEnumNoTagToArray(\n"
- " this->$name$(i), target);\n");
+ " this->$name$_, target);\n"
+ "}\n");
} else {
printer->Print(variables_,
- " target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(\n"
- " $number$, this->$name$(i), target);\n");
+ "target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(\n"
+ " $number$, this->$name$_, target);\n");
}
- printer->Print("}\n");
}
void RepeatedEnumFieldGenerator::
diff --git a/src/google/protobuf/compiler/cpp/cpp_file.cc b/src/google/protobuf/compiler/cpp/cpp_file.cc
index f2e013c0..83e68c12 100644
--- a/src/google/protobuf/compiler/cpp/cpp_file.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_file.cc
@@ -39,6 +39,7 @@
#include <google/protobuf/stubs/shared_ptr.h>
#endif
#include <set>
+#include <vector>
#include <google/protobuf/compiler/cpp/cpp_enum.h>
#include <google/protobuf/compiler/cpp/cpp_service.h>
@@ -67,7 +68,7 @@ bool IsMacroName(const string& name) {
return false;
}
-void CollectMacroNames(const Descriptor* message, vector<string>* names) {
+void CollectMacroNames(const Descriptor* message, std::vector<string>* names) {
for (int i = 0; i < message->field_count(); ++i) {
const FieldDescriptor* field = message->field(i);
if (IsMacroName(field->name())) {
@@ -79,7 +80,13 @@ void CollectMacroNames(const Descriptor* message, vector<string>* names) {
}
}
-void CollectMacroNames(const FileDescriptor* file, vector<string>* names) {
+void CollectMacroNames(const FileDescriptor* file, std::vector<string>* names) {
+ // Only do this for protobuf's own types. There are some google3 protos using
+ // macros as field names and the generated code compiles after the macro
+ // expansion. Undefing these macros actually breaks such code.
+ if (file->name() != "google/protobuf/compiler/plugin.proto") {
+ return;
+ }
for (int i = 0; i < file->message_type_count(); ++i) {
CollectMacroNames(file->message_type(i), names);
}
@@ -93,18 +100,19 @@ void CollectMacroNames(const FileDescriptor* file, vector<string>* names) {
FileGenerator::FileGenerator(const FileDescriptor* file, const Options& options)
: file_(file),
options_(options),
+ scc_analyzer_(options),
message_generators_owner_(
- new google::protobuf::scoped_ptr<MessageGenerator>[ file->message_type_count() ]),
+ new google::protobuf::scoped_ptr<MessageGenerator>[file->message_type_count()]),
enum_generators_owner_(
- new google::protobuf::scoped_ptr<EnumGenerator>[ file->enum_type_count() ]),
+ new google::protobuf::scoped_ptr<EnumGenerator>[file->enum_type_count()]),
service_generators_owner_(
- new google::protobuf::scoped_ptr<ServiceGenerator>[ file->service_count() ]),
+ new google::protobuf::scoped_ptr<ServiceGenerator>[file->service_count()]),
extension_generators_owner_(
- new google::protobuf::scoped_ptr<ExtensionGenerator>[ file->extension_count() ]) {
+ new google::protobuf::scoped_ptr<ExtensionGenerator>[file->extension_count()]) {
for (int i = 0; i < file->message_type_count(); i++) {
message_generators_owner_[i].reset(
- new MessageGenerator(file->message_type(i), options));
+ new MessageGenerator(file->message_type(i), options, &scc_analyzer_));
message_generators_owner_[i]->Flatten(&message_generators_);
}
@@ -137,7 +145,7 @@ FileGenerator::FileGenerator(const FileDescriptor* file, const Options& options)
FileGenerator::~FileGenerator() {}
void FileGenerator::GenerateMacroUndefs(io::Printer* printer) {
- vector<string> names_to_undef;
+ std::vector<string> names_to_undef;
CollectMacroNames(file_, &names_to_undef);
for (int i = 0; i < names_to_undef.size(); ++i) {
printer->Print(
@@ -241,6 +249,7 @@ void FileGenerator::GeneratePBHeader(io::Printer* printer,
} else {
GenerateLibraryIncludes(printer);
}
+
GenerateDependencyIncludes(printer);
GenerateMetadataPragma(printer, info_path);
@@ -327,11 +336,17 @@ void FileGenerator::GenerateSource(io::Printer* printer) {
GenerateNamespaceOpeners(printer);
for (int i = 0; i < message_generators_.size(); i++) {
- if (IsMapEntryMessage(message_generators_[i]->descriptor_)) continue;
+ string parent;
+ if (IsMapEntryMessage(message_generators_[i]->descriptor_)) {
+ parent = ClassName(message_generators_[i]->descriptor_->containing_type(),
+ false) +
+ "::";
+ }
printer->Print(
"class $classname$DefaultTypeInternal : "
- "public ::google::protobuf::internal::ExplicitlyConstructed<$classname$> {\n",
- "classname", message_generators_[i]->classname_);
+ "public ::google::protobuf::internal::ExplicitlyConstructed<$parent$$classname$> "
+ "{\n",
+ "parent", parent, "classname", message_generators_[i]->classname_);
printer->Indent();
message_generators_[i]->GenerateExtraDefaultFields(printer);
printer->Outdent();
@@ -340,9 +355,6 @@ void FileGenerator::GenerateSource(io::Printer* printer) {
"classname", message_generators_[i]->classname_);
}
- for (int i = 0; i < message_generators_.size(); i++) {
- message_generators_[i]->index_in_metadata_ = i;
- }
for (int i = 0; i < enum_generators_.size(); i++) {
enum_generators_[i]->index_in_metadata_ = i;
}
@@ -530,6 +542,70 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) {
// In optimize_for = LITE_RUNTIME mode, we don't generate AssignDescriptors()
// and we only use AddDescriptors() to allocate default instances.
+ // TODO(ckennelly): Gate this with the same options flag to enable
+ // table-driven parsing.
+
+ printer->Print("PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::ParseTableField\n"
+ " const TableStruct::entries[] = {\n");
+ printer->Indent();
+
+ std::vector<size_t> entries;
+ size_t count = 0;
+ for (int i = 0; i < message_generators_.size(); i++) {
+ size_t value = message_generators_[i]->GenerateParseOffsets(printer);
+ entries.push_back(value);
+ count += value;
+ }
+
+ // We need these arrays to exist, and MSVC does not like empty arrays.
+ if (count == 0) {
+ printer->Print("{0, 0, 0, ::google::protobuf::internal::kInvalidMask, 0, 0},\n");
+ }
+
+ printer->Outdent();
+ printer->Print(
+ "};\n"
+ "\n"
+ "PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::AuxillaryParseTableField\n"
+ " const TableStruct::aux[] = {\n");
+ printer->Indent();
+
+ std::vector<size_t> aux_entries;
+ count = 0;
+ for (int i = 0; i < message_generators_.size(); i++) {
+ size_t value = message_generators_[i]->GenerateParseAuxTable(printer);
+ aux_entries.push_back(value);
+ count += value;
+ }
+
+ if (count == 0) {
+ printer->Print("::google::protobuf::internal::AuxillaryParseTableField(),\n");
+ }
+
+ printer->Outdent();
+ printer->Print(
+ "};\n"
+ "PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::ParseTable const\n"
+ " TableStruct::schema[] = {\n");
+ printer->Indent();
+
+ size_t offset = 0;
+ size_t aux_offset = 0;
+ for (int i = 0; i < message_generators_.size(); i++) {
+ message_generators_[i]->GenerateParseTable(printer, offset, aux_offset);
+ offset += entries[i];
+ aux_offset += aux_entries[i];
+ }
+
+ if (message_generators_.empty()) {
+ printer->Print("{ NULL, NULL, 0, -1, -1, false },\n");
+ }
+
+ printer->Outdent();
+ printer->Print(
+ "};\n"
+ "\n");
+
if (HasDescriptorMethods(file_, options_)) {
if (!message_generators_.empty()) {
printer->Print("const ::google::protobuf::uint32 TableStruct::offsets[] = {\n");
@@ -560,8 +636,6 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) {
printer->Indent();
for (int i = 0; i < message_generators_.size(); i++) {
const Descriptor* descriptor = message_generators_[i]->descriptor_;
- if (IsMapEntryMessage(descriptor)) continue;
-
printer->Print(
"reinterpret_cast<const "
"::google::protobuf::Message*>(&_$classname$_default_instance_),\n",
@@ -600,7 +674,31 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) {
" AssignDescriptors(\n"
" \"$filename$\", schemas, file_default_instances, "
"TableStruct::offsets, factory,\n"
- " $metadata$, $enum_descriptors$, $service_descriptors$);\n"
+ " $metadata$, $enum_descriptors$, $service_descriptors$);\n",
+ "filename", file_->name(), "metadata",
+ !message_generators_.empty() ? "file_level_metadata" : "NULL",
+ "enum_descriptors",
+ !enum_generators_.empty() ? "file_level_enum_descriptors" : "NULL",
+ "service_descriptors",
+ HasGenericServices(file_, options_) && file_->service_count() > 0
+ ? "file_level_service_descriptors"
+ : "NULL",
+ "factory", message_factory);
+ // TODO(gerbens) have the compiler include the schemas for map types
+ // so that this can go away, and we can potentially use table driven
+ // serialization for map types as well.
+ for (int i = 0; i < message_generators_.size(); i++) {
+ if (!IsMapEntryMessage(message_generators_[i]->descriptor_)) continue;
+ printer->Print(
+ "file_level_metadata[$index$].reflection = "
+ "$parent$::$classname$::CreateReflection(file_level_metadata[$index$]"
+ ".descriptor, _$classname$_default_instance_.get_mutable());\n",
+ "index", SimpleItoa(i), "parent",
+ ClassName(message_generators_[i]->descriptor_->containing_type(),
+ false),
+ "classname", ClassName(message_generators_[i]->descriptor_, false));
+ }
+ printer->Print(
"}\n"
"\n"
"void protobuf_AssignDescriptorsOnce() {\n"
@@ -634,12 +732,6 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) {
"size", SimpleItoa(message_generators_.size()));
}
- // Map types are treated special
- // TODO(gerbens) find a way to treat maps more like normal messages.
- for (int i = 0; i < message_generators_.size(); i++) {
- message_generators_[i]->GenerateTypeRegistrations(printer);
- }
-
printer->Outdent();
printer->Print(
"}\n"
@@ -902,8 +994,16 @@ void FileGenerator::GenerateLibraryIncludes(io::Printer* printer) {
"#include <google/protobuf/io/coded_stream.h>\n"
"#include <google/protobuf/arena.h>\n"
"#include <google/protobuf/arenastring.h>\n"
- "#include <google/protobuf/generated_message_util.h>\n"
+ "#include <google/protobuf/generated_message_table_driven.h>\n"
+ "#include <google/protobuf/generated_message_util.h>\n");
+
+ if (HasDescriptorMethods(file_, options_)) {
+ printer->Print(
"#include <google/protobuf/metadata.h>\n");
+ } else {
+ printer->Print(
+ "#include <google/protobuf/metadata_lite.h>\n");
+ }
if (!message_generators_.empty()) {
if (HasDescriptorMethods(file_, options_)) {
@@ -921,7 +1021,8 @@ void FileGenerator::GenerateLibraryIncludes(io::Printer* printer) {
" // IWYU pragma: export\n");
if (HasMapFields(file_)) {
printer->Print(
- "#include <google/protobuf/map.h>\n");
+ "#include <google/protobuf/map.h>"
+ " // IWYU pragma: export\n");
if (HasDescriptorMethods(file_, options_)) {
printer->Print(
"#include <google/protobuf/map_field_inl.h>\n");
@@ -1001,6 +1102,9 @@ void FileGenerator::GenerateGlobalStateFunctionDeclarations(
"namespace $file_namespace$ {\n"
"// Internal implementation detail -- do not call these.\n"
"struct $dllexport_decl$TableStruct {\n"
+ " static const ::google::protobuf::internal::ParseTableField entries[];\n"
+ " static const ::google::protobuf::internal::AuxillaryParseTableField aux[];\n"
+ " static const ::google::protobuf::internal::ParseTable schema[];\n"
" static const ::google::protobuf::uint32 offsets[];\n"
// The following function(s) need to be able to access private members of
// the messages defined in the file. So we make them static members.
diff --git a/src/google/protobuf/compiler/cpp/cpp_file.h b/src/google/protobuf/compiler/cpp/cpp_file.h
index e3fbb96d..e10fe2f3 100644
--- a/src/google/protobuf/compiler/cpp/cpp_file.h
+++ b/src/google/protobuf/compiler/cpp/cpp_file.h
@@ -43,6 +43,7 @@
#include <vector>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/compiler/cpp/cpp_field.h>
+#include <google/protobuf/compiler/cpp/cpp_helpers.h>
#include <google/protobuf/compiler/cpp/cpp_options.h>
namespace google {
@@ -145,6 +146,8 @@ class FileGenerator {
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_;
diff --git a/src/google/protobuf/compiler/cpp/cpp_generator.cc b/src/google/protobuf/compiler/cpp/cpp_generator.cc
index 648ab28a..cee31224 100644
--- a/src/google/protobuf/compiler/cpp/cpp_generator.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_generator.cc
@@ -98,6 +98,8 @@ bool CppGenerator::Generate(const FileDescriptor* file,
file_options.annotation_guard_name = options[i].second;
} else if (options[i].first == "lite") {
file_options.enforce_lite = true;
+ } else if (options[i].first == "table_driven_parsing") {
+ file_options.table_driven_parsing = true;
} else {
*error = "Unknown generator option: " + options[i].first;
return false;
diff --git a/src/google/protobuf/compiler/cpp/cpp_helpers.cc b/src/google/protobuf/compiler/cpp/cpp_helpers.cc
index 3c4dddc5..9cddba5c 100644
--- a/src/google/protobuf/compiler/cpp/cpp_helpers.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_helpers.cc
@@ -654,6 +654,109 @@ void GenerateUtf8CheckCodeForCord(const FieldDescriptor* field,
"VerifyUtf8Cord", "VerifyUTF8CordNamedField", printer);
}
+bool HasWeakFields(const Descriptor* descriptor) {
+ return false;
+}
+
+bool HasWeakFields(const FileDescriptor* file) {
+ return false;
+}
+
+SCCAnalyzer::NodeData SCCAnalyzer::DFS(const Descriptor* descriptor) {
+ // Must not have visited already.
+ GOOGLE_DCHECK_EQ(cache_.count(descriptor), 0);
+
+ // Mark visited by inserting in map.
+ NodeData& result = cache_[descriptor];
+ // Initialize data structures.
+ result.index = result.lowlink = index_++;
+ stack_.push_back(descriptor);
+
+ // Recurse the fields / nodes in graph
+ for (int i = 0; i < descriptor->field_count(); i++) {
+ const Descriptor* child = descriptor->field(i)->message_type();
+ if (child) {
+ if (cache_.count(child) == 0) {
+ // unexplored node
+ NodeData child_data = DFS(child);
+ result.lowlink = std::min(result.lowlink, child_data.lowlink);
+ } else {
+ NodeData child_data = cache_[child];
+ if (child_data.scc == NULL) {
+ // Still in the stack_ so we found a back edge
+ result.lowlink = std::min(result.lowlink, child_data.index);
+ }
+ }
+ }
+ }
+ if (result.index == result.lowlink) {
+ // This is the root of a strongly connected component
+ SCC* scc = CreateSCC();
+ while (true) {
+ const Descriptor* scc_desc = stack_.back();
+ scc->descriptors.push_back(scc_desc);
+ // Remove from stack
+ stack_.pop_back();
+ cache_[scc_desc].scc = scc;
+
+ if (scc_desc == descriptor) break;
+ }
+ }
+ return result;
+}
+
+MessageAnalysis SCCAnalyzer::GetSCCAnalysis(const SCC* scc) {
+ if (analysis_cache_.count(scc)) return analysis_cache_[scc];
+ MessageAnalysis result = MessageAnalysis();
+ for (int i = 0; i < scc->descriptors.size(); i++) {
+ const Descriptor* descriptor = scc->descriptors[i];
+ if (descriptor->extension_range_count() > 0) {
+ result.contains_extension = true;
+ }
+ for (int i = 0; i < descriptor->field_count(); i++) {
+ const FieldDescriptor* field = descriptor->field(i);
+ if (field->is_required()) {
+ result.contains_required = true;
+ }
+ switch (field->type()) {
+ case FieldDescriptor::TYPE_STRING:
+ case FieldDescriptor::TYPE_BYTES: {
+ if (field->options().ctype() == FieldOptions::CORD) {
+ result.contains_cord = true;
+ }
+ break;
+ }
+ case FieldDescriptor::TYPE_GROUP:
+ case FieldDescriptor::TYPE_MESSAGE: {
+ const SCC* child = GetSCC(field->message_type());
+ if (child != scc) {
+ MessageAnalysis analysis = GetSCCAnalysis(child);
+ result.contains_cord |= analysis.contains_cord;
+ result.contains_extension |= analysis.contains_extension;
+ if (!ShouldIgnoreRequiredFieldCheck(field, options_)) {
+ result.contains_required |= analysis.contains_required;
+ }
+ } else {
+ // This field points back into the same SCC hence the messages
+ // in the SCC are recursive. Note if SCC contains more than two
+ // nodes it has to be recursive, however this test also works for
+ // a single node that is recursive.
+ result.is_recursive = true;
+ }
+ break;
+ }
+ default:
+ break;
+ }
+ }
+ }
+ // We deliberately only insert the result here. After we contracted the SCC
+ // in the graph, the graph should be a DAG. Hence we shouldn't need to mark
+ // nodes visited as we can never return to them. By inserting them here
+ // we will go in an infinite loop if the SCC is not correct.
+ return analysis_cache_[scc] = result;
+}
+
} // namespace cpp
} // namespace compiler
} // namespace protobuf
diff --git a/src/google/protobuf/compiler/cpp/cpp_helpers.h b/src/google/protobuf/compiler/cpp/cpp_helpers.h
index 0f297ec8..a744a865 100644
--- a/src/google/protobuf/compiler/cpp/cpp_helpers.h
+++ b/src/google/protobuf/compiler/cpp/cpp_helpers.h
@@ -277,6 +277,73 @@ inline ::google::protobuf::FileOptions_OptimizeMode GetOptimizeFor(
: file->options().optimize_for();
}
+bool HasWeakFields(const Descriptor* desc);
+bool HasWeakFields(const FileDescriptor* desc);
+
+// Returns true if the "required" restriction check should be ignored for the
+// given field.
+inline static bool ShouldIgnoreRequiredFieldCheck(const FieldDescriptor* field,
+ const Options& options) {
+ return false;
+}
+
+struct SCC {
+ std::vector<const Descriptor*> descriptors;
+};
+
+struct MessageAnalysis {
+ bool is_recursive;
+ bool contains_cord;
+ bool contains_extension;
+ bool contains_required;
+};
+
+// This class is used in FileGenerator, to ensure linear instead of
+// quadratic performance, if we do this per message we would get O(V*(V+E)).
+// Logically this is just only used in message.cc, but in the header for
+// FileGenerator to help share it.
+class LIBPROTOC_EXPORT SCCAnalyzer {
+ public:
+ explicit SCCAnalyzer(const Options& options) : options_(options), index_(0) {}
+ ~SCCAnalyzer() {
+ for (int i = 0; i < garbage_bin_.size(); i++) delete garbage_bin_[i];
+ }
+
+ const SCC* GetSCC(const Descriptor* descriptor) {
+ if (cache_.count(descriptor)) return cache_[descriptor].scc;
+ return DFS(descriptor).scc;
+ }
+
+ MessageAnalysis GetSCCAnalysis(const SCC* scc);
+
+ bool HasRequiredFields(const Descriptor* descriptor) {
+ MessageAnalysis result = GetSCCAnalysis(GetSCC(descriptor));
+ return result.contains_required || result.contains_extension;
+ }
+
+ private:
+ struct NodeData {
+ const SCC* scc; // if null it means its still on the stack
+ int index;
+ int lowlink;
+ };
+
+ Options options_;
+ std::map<const Descriptor*, NodeData> cache_;
+ std::map<const SCC*, MessageAnalysis> analysis_cache_;
+ std::vector<const Descriptor*> stack_;
+ int index_;
+ std::vector<SCC*> garbage_bin_;
+
+ SCC* CreateSCC() {
+ garbage_bin_.push_back(new SCC());
+ return garbage_bin_.back();
+ }
+
+ // Tarjan's Strongly Connected Components algo
+ NodeData DFS(const Descriptor* descriptor);
+};
+
} // namespace cpp
} // namespace compiler
} // namespace protobuf
diff --git a/src/google/protobuf/compiler/cpp/cpp_map_field.cc b/src/google/protobuf/compiler/cpp/cpp_map_field.cc
index b4eaf485..52a3b8b0 100644
--- a/src/google/protobuf/compiler/cpp/cpp_map_field.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_map_field.cc
@@ -32,6 +32,7 @@
#include <google/protobuf/compiler/cpp/cpp_helpers.h>
#include <google/protobuf/io/printer.h>
#include <google/protobuf/wire_format.h>
+
#include <google/protobuf/stubs/strutil.h>
namespace google {
@@ -113,18 +114,49 @@ MapFieldGenerator::~MapFieldGenerator() {}
void MapFieldGenerator::
GeneratePrivateMembers(io::Printer* printer) const {
+ if (HasDescriptorMethods(descriptor_->file(), options_)) {
+ printer->Print(
+ variables_,
+ "public:\n"
+ "class $map_classname$ : public "
+ "::google::protobuf::internal::MapEntry<$map_classname$, \n"
+ " $key_cpp$, $val_cpp$,\n"
+ " $key_wire_type$,\n"
+ " $val_wire_type$,\n"
+ " $default_enum_value$ > {\n"
+ "public:\n"
+ " typedef ::google::protobuf::internal::MapEntry<$map_classname$, \n"
+ " $key_cpp$, $val_cpp$,\n"
+ " $key_wire_type$,\n"
+ " $val_wire_type$,\n"
+ " $default_enum_value$ > SuperType;\n"
+ " $map_classname$();\n"
+ " $map_classname$(::google::protobuf::Arena* arena);\n"
+ " void MergeFrom(const ::google::protobuf::Message& other) PROTOBUF_FINAL;\n"
+ " void MergeFrom(const $map_classname$& other);\n"
+ " static const Message* internal_default_instance() { return "
+ "reinterpret_cast<const "
+ "Message*>(&_$map_classname$_default_instance_); }\n"
+ " ::google::protobuf::Metadata GetMetadata() const;\n"
+ "};\n");
+ } else {
+ printer->Print(variables_,
+ "public:\n"
+ "typedef ::google::protobuf::internal::MapEntryLite<\n"
+ " $key_cpp$, $val_cpp$,\n"
+ " $key_wire_type$,\n"
+ " $val_wire_type$,\n"
+ " $default_enum_value$ >\n"
+ " $map_classname$;\n");
+ }
printer->Print(variables_,
- "typedef ::google::protobuf::internal::MapEntryLite<\n"
- " $key_cpp$, $val_cpp$,\n"
- " $key_wire_type$,\n"
- " $val_wire_type$,\n"
- " $default_enum_value$ >\n"
- " $map_classname$;\n"
- "::google::protobuf::internal::MapField$lite$<\n"
- " $key_cpp$, $val_cpp$,\n"
- " $key_wire_type$,\n"
- " $val_wire_type$,\n"
- " $default_enum_value$ > $name$_;\n");
+ "::google::protobuf::internal::MapField$lite$<\n"
+ " $map_classname$,\n"
+ " $key_cpp$, $val_cpp$,\n"
+ " $key_wire_type$,\n"
+ " $val_wire_type$,\n"
+ " $default_enum_value$ > $name$_;\n"
+ "private:\n");
}
void MapFieldGenerator::
@@ -172,17 +204,6 @@ GenerateSwappingCode(io::Printer* printer) const {
}
void MapFieldGenerator::
-GenerateConstructorCode(io::Printer* printer) const {
- if (HasDescriptorMethods(descriptor_->file(), options_)) {
- printer->Print(variables_,
- "$name$_.SetAssignDescriptorCallback(\n"
- " $file_namespace$::protobuf_AssignDescriptorsOnce);\n"
- "$name$_.SetEntryDescriptor(\n"
- " &$type$_descriptor);\n");
- }
-}
-
-void MapFieldGenerator::
GenerateCopyConstructorCode(io::Printer* printer) const {
GenerateConstructorCode(printer);
GenerateMergingCode(printer);
@@ -199,13 +220,15 @@ GenerateMergeFromCodedStream(io::Printer* printer) const {
string value;
if (IsProto3Field(descriptor_) ||
value_field->type() != FieldDescriptor::TYPE_ENUM) {
- printer->Print(variables_,
+ printer->Print(
+ variables_,
"$map_classname$::Parser< ::google::protobuf::internal::MapField$lite$<\n"
- " $key_cpp$, $val_cpp$,\n"
- " $key_wire_type$,\n"
- " $val_wire_type$,\n"
- " $default_enum_value$ >,\n"
- " ::google::protobuf::Map< $key_cpp$, $val_cpp$ > >"
+ " $map_classname$,\n"
+ " $key_cpp$, $val_cpp$,\n"
+ " $key_wire_type$,\n"
+ " $val_wire_type$,\n"
+ " $default_enum_value$ >,\n"
+ " ::google::protobuf::Map< $key_cpp$, $val_cpp$ > >"
" parser(&$name$_);\n"
"DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(\n"
" input, &parser));\n");
diff --git a/src/google/protobuf/compiler/cpp/cpp_map_field.h b/src/google/protobuf/compiler/cpp/cpp_map_field.h
index 816687b3..02e66497 100644
--- a/src/google/protobuf/compiler/cpp/cpp_map_field.h
+++ b/src/google/protobuf/compiler/cpp/cpp_map_field.h
@@ -54,7 +54,7 @@ class MapFieldGenerator : public FieldGenerator {
void GenerateClearingCode(io::Printer* printer) const;
void GenerateMergingCode(io::Printer* printer) const;
void GenerateSwappingCode(io::Printer* printer) const;
- void GenerateConstructorCode(io::Printer* printer) const;
+ void GenerateConstructorCode(io::Printer* printer) const {}
void GenerateCopyConstructorCode(io::Printer* printer) const;
void GenerateMergeFromCodedStream(io::Printer* printer) const;
void GenerateSerializeWithCachedSizes(io::Printer* printer) const;
diff --git a/src/google/protobuf/compiler/cpp/cpp_message.cc b/src/google/protobuf/compiler/cpp/cpp_message.cc
index 1373ffc2..d9524f64 100644
--- a/src/google/protobuf/compiler/cpp/cpp_message.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_message.cc
@@ -32,6 +32,8 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
+#include <google/protobuf/compiler/cpp/cpp_message.h>
+
#include <algorithm>
#include <google/protobuf/stubs/hash.h>
#include <map>
@@ -41,16 +43,18 @@
#endif
#include <utility>
#include <vector>
-#include <google/protobuf/compiler/cpp/cpp_message.h>
-#include <google/protobuf/compiler/cpp/cpp_field.h>
+
#include <google/protobuf/compiler/cpp/cpp_enum.h>
#include <google/protobuf/compiler/cpp/cpp_extension.h>
+#include <google/protobuf/compiler/cpp/cpp_field.h>
#include <google/protobuf/compiler/cpp/cpp_helpers.h>
-#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/io/printer.h>
#include <google/protobuf/io/coded_stream.h>
-#include <google/protobuf/wire_format.h>
+#include <google/protobuf/io/printer.h>
#include <google/protobuf/descriptor.pb.h>
+#include <google/protobuf/generated_message_table_driven.h>
+#include <google/protobuf/wire_format.h>
+#include <google/protobuf/stubs/strutil.h>
+#include <google/protobuf/stubs/substitute.h>
namespace google {
@@ -103,54 +107,6 @@ struct ExtensionRangeSorter {
}
};
-// Returns true if the "required" restriction check should be ignored for the
-// given field.
-inline static bool ShouldIgnoreRequiredFieldCheck(const FieldDescriptor* field,
- const Options& options) {
- return false;
-}
-
-// Returns true if the message type has any required fields. If it doesn't,
-// we can optimize out calls to its IsInitialized() method.
-//
-// already_seen is used to avoid checking the same type multiple times
-// (and also to protect against recursion).
-static bool HasRequiredFields(const Descriptor* type, const Options& options,
- hash_set<const Descriptor*>* already_seen) {
- if (already_seen->count(type) > 0) {
- // Since the first occurrence of a required field causes the whole
- // function to return true, we can assume that if the type is already
- // in the cache it didn't have any required fields.
- return false;
- }
- already_seen->insert(type);
-
- // If the type has extensions, an extension with message type could contain
- // required fields, so we have to be conservative and assume such an
- // extension exists.
- if (type->extension_range_count() > 0) return true;
-
- for (int i = 0; i < type->field_count(); i++) {
- const FieldDescriptor* field = type->field(i);
- if (field->is_required()) {
- return true;
- }
- if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE &&
- !ShouldIgnoreRequiredFieldCheck(field, options)) {
- if (HasRequiredFields(field->message_type(), options, already_seen)) {
- return true;
- }
- }
- }
-
- return false;
-}
-
-static bool HasRequiredFields(const Descriptor* type, const Options& options) {
- hash_set<const Descriptor*> already_seen;
- return HasRequiredFields(type, options, &already_seen);
-}
-
// This returns an estimate of the compiler's alignment for the field. This
// can't guarantee to be correct because the generated code could be compiled on
// different systems with different alignment rules. The estimates below assume
@@ -288,10 +244,13 @@ bool CanConstructByZeroing(const FieldDescriptor* field,
// order, fields of similiar family (see below) are together and within each
// family, alignment padding is minimized.
//
-// We try to do this while keeping each field as close as possible to its
-// declaration order (from the .proto file) so that we don't reduce cache
-// locality much for function that access each field in order. This is also the
-// only (weak) signal we have for author intent concerning field layout.
+// We try to do this while keeping each field as close as possible to its field
+// number order so that we don't reduce cache locality much for function that
+// access each field in order. Originally, OptimizePadding used declaration
+// order for its decisions, but generated code minus the serializer/parsers uses
+// the output of OptimizePadding as well (stored in
+// MessageGenerator::optimized_order_). Since the serializers use field number
+// order, we use that as a tie-breaker.
//
// TODO(ckennelly): If/when we have profiles available for the compiler, use
// those rather than respect declaration order.
@@ -346,10 +305,11 @@ void OptimizePadding(std::vector<const FieldDescriptor*>* fields,
f = ZERO_INITIALIZABLE;
}
+ const int j = field->number();
switch (EstimateAlignmentSize(field)) {
- case 1: aligned_to_1[f].push_back(FieldGroup(i, field)); break;
- case 4: aligned_to_4[f].push_back(FieldGroup(i, field)); break;
- case 8: aligned_to_8[f].push_back(FieldGroup(i, field)); break;
+ case 1: aligned_to_1[f].push_back(FieldGroup(j, field)); break;
+ case 4: aligned_to_4[f].push_back(FieldGroup(j, field)); break;
+ case 8: aligned_to_8[f].push_back(FieldGroup(j, field)); break;
default:
GOOGLE_LOG(FATAL) << "Unknown alignment size.";
}
@@ -366,7 +326,7 @@ void OptimizePadding(std::vector<const FieldDescriptor*>* fields,
}
aligned_to_4[f].push_back(field_group);
}
- // Sort by preferred location to keep fields as close to their declaration
+ // Sort by preferred location to keep fields as close to their field number
// order as possible. Using stable_sort ensures that the output is
// consistent across runs.
std::stable_sort(aligned_to_4[f].begin(), aligned_to_4[f].end());
@@ -406,9 +366,6 @@ void OptimizePadding(std::vector<const FieldDescriptor*>* fields,
}
}
-string MessageTypeProtoName(const FieldDescriptor* field) {
- return field->message_type()->full_name();
-}
// Emits an if-statement with a condition that evaluates to true if |field| is
// considered non-default (will be sent over the wire), for message types
@@ -495,30 +452,99 @@ bool HasPrivateHasMethod(const FieldDescriptor* field) {
}
+bool TableDrivenEnabled(const Descriptor* descriptor, const Options& options) {
+ if (!options.table_driven_parsing) {
+ return false;
+ }
+
+ // Consider table-driven parsing. We only do this if:
+ // - There are no extensions
+ if (descriptor->extension_range_count() != 0) {
+ return false;
+ }
+
+ // - We are not using UnknownFieldSet (part of the non-lite library).
+ if (UseUnknownFieldSet(descriptor->file(), options)) {
+ return false;
+ }
+
+ // - We have has_bits for fields. This avoids a check on every field we set
+ // when are present (the common case).
+ if (!HasFieldPresence(descriptor->file())) {
+ return false;
+ }
+
+ const double table_sparseness = 0.5;
+ int max_field_number = 0;
+ for (int i = 0; i < descriptor->field_count(); i++) {
+ const FieldDescriptor* field = descriptor->field(i);
+ if (max_field_number < field->number()) {
+ max_field_number = field->number();
+ }
+
+ // - There are no map fields.
+ if (field->is_map()) {
+ return false;
+ }
+
+ // - There are no oneof fields.
+ if (field->containing_oneof()) {
+ return false;
+ }
+
+ // - There are no weak fields.
+ if (field->options().weak()) {
+ return false;
+ }
+ }
+
+ // - There range of field numbers is "small"
+ if (max_field_number >= (2 << 14)) {
+ return false;
+ }
+
+ // - Field numbers are relatively dense within the actual number of fields
+ if (max_field_number * table_sparseness >= descriptor->field_count()) {
+ return false;
+ }
+
+ // - This is not a MapEntryMessage.
+ if (IsMapEntryMessage(descriptor)) {
+ return false;
+ }
+
+ return true;
+}
+
} // anonymous namespace
// ===================================================================
MessageGenerator::MessageGenerator(const Descriptor* descriptor,
- const Options& options)
+ const Options& options,
+ SCCAnalyzer* scc_analyzer)
: descriptor_(descriptor),
classname_(ClassName(descriptor, false)),
options_(options),
field_generators_(descriptor, options),
max_has_bit_index_(0),
nested_generators_(new google::protobuf::scoped_ptr<
- MessageGenerator>[descriptor->nested_type_count()]),
+ MessageGenerator>[descriptor->nested_type_count()]),
enum_generators_(
new google::protobuf::scoped_ptr<EnumGenerator>[descriptor->enum_type_count()]),
extension_generators_(new google::protobuf::scoped_ptr<
- ExtensionGenerator>[descriptor->extension_count()]),
- use_dependent_base_(false) {
-
+ ExtensionGenerator>[descriptor->extension_count()]),
+ use_dependent_base_(false),
+ num_weak_fields_(0),
+ scc_analyzer_(scc_analyzer) {
// Compute optimized field order to be used for layout and initialization
// purposes.
for (int i = 0; i < descriptor_->field_count(); i++) {
- if (!descriptor_->field(i)->containing_oneof()) {
- optimized_order_.push_back(descriptor_->field(i));
+ const FieldDescriptor* field = descriptor_->field(i);
+ if (field->options().weak()) {
+ num_weak_fields_++;
+ } else if (!field->containing_oneof()) {
+ optimized_order_.push_back(field);
}
}
OptimizePadding(&optimized_order_, options_);
@@ -538,8 +564,8 @@ MessageGenerator::MessageGenerator(const Descriptor* descriptor,
}
for (int i = 0; i < descriptor->nested_type_count(); i++) {
- nested_generators_[i].reset(
- new MessageGenerator(descriptor->nested_type(i), options));
+ nested_generators_[i].reset(new MessageGenerator(descriptor->nested_type(i),
+ options, scc_analyzer));
}
for (int i = 0; i < descriptor->enum_type_count(); i++) {
@@ -565,6 +591,8 @@ MessageGenerator::MessageGenerator(const Descriptor* descriptor,
// Always make oneofs dependent.
use_dependent_base_ = true;
}
+
+ table_driven_ = TableDrivenEnabled(descriptor_, options_);
}
MessageGenerator::~MessageGenerator() {}
@@ -586,6 +614,7 @@ void MessageGenerator::Flatten(std::vector<MessageGenerator*>* list) {
for (int i = 0; i < descriptor_->nested_type_count(); i++) {
nested_generators_[i]->Flatten(list);
}
+ index_in_file_messages_ = list->size();
list->push_back(this);
}
@@ -602,7 +631,6 @@ void MessageGenerator::AddGenerators(
void MessageGenerator::FillMessageForwardDeclarations(
std::map<string, const Descriptor*>* class_names) {
- if (IsMapEntryMessage(descriptor_)) return;
(*class_names)[classname_] = descriptor_;
}
@@ -644,7 +672,7 @@ GenerateFieldAccessorDeclarations(io::Printer* printer) {
ordered_fields.begin(), optimized_order_.begin(), optimized_order_.end());
for (int i = 0; i < descriptor_->field_count(); i++) {
const FieldDescriptor* field = descriptor_->field(i);
- if (field->containing_oneof() == NULL) {
+ if (field->containing_oneof() == NULL && !field->options().weak()) {
continue;
}
ordered_fields.push_back(field);
@@ -777,6 +805,15 @@ void MessageGenerator::
GenerateSingularFieldHasBits(const FieldDescriptor* field,
std::map<string, string> vars,
io::Printer* printer) {
+ if (field->options().weak()) {
+ printer->Print(
+ vars,
+ "$inline$"
+ "bool $classname$::has_$name$() const {\n"
+ " return _weak_field_map_.Has($number$);\n"
+ "}\n");
+ return;
+ }
if (HasFieldPresence(descriptor_->file())) {
// N.B.: without field presence, we do not use has-bits or generate
// has_$name$() methods.
@@ -896,7 +933,7 @@ GenerateFieldClear(const FieldDescriptor* field,
field_generators_.get(field)
.GenerateClearingCode(printer);
if (HasFieldPresence(descriptor_->file())) {
- if (!field->is_repeated()) {
+ if (!field->is_repeated() && !field->options().weak()) {
printer->Print(vars,
"$this_message$clear_has_$name$();\n");
}
@@ -1049,6 +1086,29 @@ GenerateClassDefinition(io::Printer* printer) {
"}\n"
"\n");
+ // Generate move constructor and move assignment operator for types other than
+ // Any.
+ #ifdef PROTO_EXPERIMENTAL_ENABLE_MOVE
+ if (!IsAnyMessage(descriptor_)) {
+ printer->Print(vars,
+ "#if LANG_CXX11\n"
+ "$classname$($classname$&& from)\n"
+ " : $classname$() {\n"
+ " *this = ::std::move(from);\n"
+ "}\n"
+ "\n"
+ "inline $classname$& operator=($classname$&& from) {\n"
+ " if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) {\n"
+ " InternalSwap(&from);\n"
+ " } else {\n"
+ " CopyFrom(from);\n"
+ " }\n"
+ " return *this;\n"
+ "}\n"
+ "#endif\n");
+ }
+ #endif
+
if (PreserveUnknownFields(descriptor_)) {
string type = UseUnknownFieldSet(descriptor_->file(), options_)
? "::google::protobuf::UnknownFieldSet"
@@ -1119,12 +1179,15 @@ GenerateClassDefinition(io::Printer* printer) {
}
// TODO(gerbens) make this private, while still granting other protos access.
+ vars["message_index"] = SimpleItoa(index_in_file_messages_);
printer->Print(
vars,
"static inline const $classname$* internal_default_instance() {\n"
" return reinterpret_cast<const $classname$*>(\n"
" &_$classname$_default_instance_);\n"
"}\n"
+ "static PROTOBUF_CONSTEXPR int const kIndexInFileMessages =\n"
+ " $message_index$;\n"
"\n");
@@ -1199,14 +1262,8 @@ GenerateClassDefinition(io::Printer* printer) {
}
if (HasFastArraySerialization(descriptor_->file(), options_)) {
printer->Print(
- "::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(\n"
- " bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;\n"
- "::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)\n"
- " const PROTOBUF_FINAL {\n"
- " return InternalSerializeWithCachedSizesToArray(\n"
- " ::google::protobuf::io::CodedOutputStream::"
- "IsDefaultSerializationDeterministic(), output);\n"
- "}\n");
+ "::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(\n"
+ " bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;\n");
}
}
@@ -1312,7 +1369,8 @@ GenerateClassDefinition(io::Printer* printer) {
for (int i = 0; i < descriptor_->field_count(); i++) {
- if (!descriptor_->field(i)->is_repeated()) {
+ if (!descriptor_->field(i)->is_repeated() &&
+ !descriptor_->field(i)->options().weak()) {
// set_has_***() generated in all proto1/2 code and in oneofs (only) for
// messages without true field presence.
if (HasFieldPresence(descriptor_->file()) ||
@@ -1451,6 +1509,10 @@ GenerateClassDefinition(io::Printer* printer) {
"\n");
}
+ if (num_weak_fields_) {
+ printer->Print(
+ "::google::protobuf::internal::WeakFieldMap _weak_field_map_;\n");
+ }
// Generate _any_metadata_ for the Any type.
if (IsAnyMessage(descriptor_)) {
printer->Print(vars,
@@ -1459,6 +1521,7 @@ GenerateClassDefinition(io::Printer* printer) {
// The TableStruct struct needs access to the private parts, in order to
// construct the offsets of all members.
+ //
// Some InitDefault and Shutdown are defined as static member functions of
// TableStruct such that they are also allowed to access private members.
printer->Print(
@@ -1511,8 +1574,9 @@ GenerateInlineMethods(io::Printer* printer, bool is_inline) {
void MessageGenerator::
GenerateExtraDefaultFields(io::Printer* printer) {
- // Generate oneof default instance for reflection usage.
- if (descriptor_->oneof_decl_count() > 0) {
+ // Generate oneof default instance and weak field instances for reflection
+ // usage.
+ if (descriptor_->oneof_decl_count() > 0 || num_weak_fields_ > 0) {
printer->Print("public:\n");
for (int i = 0; i < descriptor_->oneof_decl_count(); i++) {
for (int j = 0; j < descriptor_->oneof_decl(i)->field_count(); j++) {
@@ -1525,9 +1589,71 @@ GenerateExtraDefaultFields(io::Printer* printer) {
field_generators_.get(field).GeneratePrivateMembers(printer);
}
}
+ for (int i = 0; i < descriptor_->field_count(); i++) {
+ const FieldDescriptor* field = descriptor_->field(i);
+ if (field->options().weak()) {
+ printer->Print(
+ " const ::google::protobuf::Message* $name$_;\n", "name", FieldName(field));
+ }
+ }
}
}
+bool MessageGenerator::GenerateParseTable(io::Printer* printer, size_t offset,
+ size_t aux_offset) {
+ if (!table_driven_) {
+ printer->Print("{ NULL, NULL, 0, -1, -1, false },\n");
+ return false;
+ }
+
+ std::map<string, string> vars;
+
+ vars["classname"] = classname_;
+ vars["offset"] = SimpleItoa(offset);
+ vars["aux_offset"] = SimpleItoa(aux_offset);
+
+ int max_field_number = 0;
+ for (int i = 0; i < descriptor_->field_count(); i++) {
+ const FieldDescriptor* field = descriptor_->field(i);
+ if (max_field_number < field->number()) {
+ max_field_number = field->number();
+ }
+ }
+
+ vars["max_field_number"] = SimpleItoa(max_field_number);
+
+ printer->Print("{\n");
+ printer->Indent();
+
+ printer->Print(vars,
+ "TableStruct::entries + $offset$,\n"
+ "TableStruct::aux + $aux_offset$,\n"
+ "$max_field_number$,\n");
+
+ if (!HasFieldPresence(descriptor_->file())) {
+ // If we don't have field presence, then _has_bits_ does not exist.
+ printer->Print(vars, "-1,\n");
+ } else {
+ printer->Print(vars,
+ "GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(\n"
+ " $classname$, _has_bits_),\n");
+ }
+
+ printer->Print(vars,
+ "GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(\n"
+ " $classname$, _internal_metadata_),\n");
+
+ if (UseUnknownFieldSet(descriptor_->file(), options_)) {
+ printer->Print(vars, "true,\n");
+ } else {
+ printer->Print(vars, "false,\n");
+ }
+
+ printer->Outdent();
+ printer->Print("},\n");
+ return true;
+}
+
void MessageGenerator::GenerateSchema(io::Printer* printer, int offset,
int has_offset) {
if (IsMapEntryMessage(descriptor_)) return;
@@ -1545,46 +1671,7 @@ void MessageGenerator::GenerateSchema(io::Printer* printer, int offset,
}
void MessageGenerator::
-GenerateTypeRegistrations(io::Printer* printer) {
- // Register this message type with the message factory.
- if (IsMapEntryMessage(descriptor_)) {
- std::map<string, string> vars;
- CollectMapInfo(descriptor_, &vars);
- vars["classname"] = classname_;
- vars["file_namespace"] = FileLevelNamespace(descriptor_->file()->name());
-
- const FieldDescriptor* val = descriptor_->FindFieldByName("value");
- if (descriptor_->file()->syntax() == FileDescriptor::SYNTAX_PROTO2 &&
- val->type() == FieldDescriptor::TYPE_ENUM) {
- const EnumValueDescriptor* default_value = val->default_value_enum();
- vars["default_enum_value"] = Int32ToString(default_value->number());
- } else {
- vars["default_enum_value"] = "0";
- }
-
- vars["index_in_metadata"] = SimpleItoa(index_in_metadata_);
-
- printer->Print(
- vars,
- "const ::google::protobuf::Descriptor* $classname$_descriptor = "
- "$file_namespace$::file_level_metadata[$index_in_metadata$].descriptor;"
- "\n"
- "::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n"
- " $classname$_descriptor,\n"
- " ::google::protobuf::internal::MapEntry<\n"
- " $key$,\n"
- " $val$,\n"
- " $key_wire_type$,\n"
- " $val_wire_type$,\n"
- " $default_enum_value$>::CreateDefaultInstance(\n"
- " $classname$_descriptor));\n");
- }
-}
-
-void MessageGenerator::
GenerateDefaultInstanceAllocator(io::Printer* printer) {
- if (IsMapEntryMessage(descriptor_)) return;
-
// Construct the default instances of all fields, as they will be used
// when creating the default instance of the entire message.
for (int i = 0; i < descriptor_->field_count(); i++) {
@@ -1601,7 +1688,15 @@ GenerateDefaultInstanceAllocator(io::Printer* printer) {
void MessageGenerator::
GenerateDefaultInstanceInitializer(io::Printer* printer) {
- if (IsMapEntryMessage(descriptor_)) return;
+ if (IsMapEntryMessage(descriptor_)) {
+ printer->Print(
+ "_$classname$_default_instance_.get_mutable()->set_default_instance(_$"
+ "classname$_default_instance_.get_mutable());\n"
+ "_$classname$_default_instance_.get_mutable()->InitAsDefaultInstance();"
+ "\n",
+ "classname", classname_);
+ return;
+ }
// The default instance needs all of its embedded message pointers
// cross-linked to other default instances. We can't do this initialization
@@ -1617,7 +1712,7 @@ GenerateDefaultInstanceInitializer(io::Printer* printer) {
(field->containing_oneof() == NULL ||
HasDescriptorMethods(descriptor_->file(), options_))) {
string name;
- if (field->containing_oneof()) {
+ if (field->containing_oneof() || field->options().weak()) {
name = "_" + classname_ + "_default_instance_.";
} else {
name = "_" + classname_ + "_default_instance_.get_mutable()->";
@@ -1645,7 +1740,7 @@ GenerateShutdownCode(io::Printer* printer) {
if (HasDescriptorMethods(descriptor_->file(), options_)) {
printer->Print("delete file_level_metadata[$index$].reflection;\n", "index",
- SimpleItoa(index_in_metadata_));
+ SimpleItoa(index_in_file_messages_));
}
// Handle default instances of fields.
@@ -1657,7 +1752,31 @@ GenerateShutdownCode(io::Printer* printer) {
void MessageGenerator::
GenerateClassMethods(io::Printer* printer) {
- if (IsMapEntryMessage(descriptor_)) return;
+ if (IsMapEntryMessage(descriptor_)) {
+ if (HasDescriptorMethods(descriptor_->file(), options_)) {
+ printer->Print(
+ "$parent$::$classname$::$classname$() {}\n"
+ "$parent$::$classname$::$classname$(::google::protobuf::Arena* arena) : "
+ "SuperType(arena) {}\n"
+ "::google::protobuf::Metadata $parent$::$classname$::GetMetadata() const {\n"
+ " $file_namespace$::protobuf_AssignDescriptorsOnce();\n"
+ " return $file_namespace$::file_level_metadata[$index$];\n"
+ "}\n"
+ "void $parent$::$classname$::MergeFrom(\n"
+ " const ::google::protobuf::Message& other) {\n"
+ " ::google::protobuf::Message::MergeFrom(other);\n"
+ "}\n"
+ "void $parent$::$classname$::MergeFrom(const $classname$& other) {\n"
+ " MergeFromInternal(other);\n"
+ "}\n"
+ "\n",
+ "file_namespace", FileLevelNamespace(descriptor_->file()->name()),
+ "parent", ClassName(descriptor_->containing_type(), false),
+ "classname", classname_, "index",
+ SimpleItoa(index_in_file_messages_));
+ }
+ return;
+ }
if (IsAnyMessage(descriptor_)) {
printer->Print(
@@ -1739,11 +1858,12 @@ GenerateClassMethods(io::Printer* printer) {
printer->Print(
"::google::protobuf::Metadata $classname$::GetMetadata() const {\n"
" $file_namespace$::protobuf_AssignDescriptorsOnce();\n"
- " return $file_namespace$::file_level_metadata[$index$];\n"
+ " return "
+ "$file_namespace$::file_level_metadata[kIndexInFileMessages];\n"
"}\n"
"\n",
- "classname", classname_, "index", SimpleItoa(index_in_metadata_),
- "file_namespace", FileLevelNamespace(descriptor_->file()->name()));
+ "classname", classname_, "file_namespace",
+ FileLevelNamespace(descriptor_->file()->name()));
} else {
printer->Print(
"::std::string $classname$::GetTypeName() const {\n"
@@ -1756,6 +1876,185 @@ GenerateClassMethods(io::Printer* printer) {
}
+size_t MessageGenerator::GenerateParseOffsets(io::Printer* printer) {
+ if (!table_driven_) {
+ return 0;
+ }
+
+ // Field "0" is special: We use it in our switch statement of processing
+ // types to handle the successful end tag case.
+ printer->Print("{0, 0, 0, ::google::protobuf::internal::kInvalidMask, 0, 0},\n");
+ int last_field_number = 1;
+
+ std::vector<const FieldDescriptor*> ordered_fields =
+ SortFieldsByNumber(descriptor_);
+
+ for (int i = 0; i < descriptor_->field_count(); i++) {
+ const FieldDescriptor* field = ordered_fields[i];
+ GOOGLE_CHECK_GE(field->number(), last_field_number);
+
+ for (; last_field_number < field->number(); last_field_number++) {
+ printer->Print(
+ "{ 0, 0, ::google::protobuf::internal::kInvalidMask,\n"
+ " ::google::protobuf::internal::kInvalidMask, 0, 0 },\n");
+ }
+ last_field_number++;
+
+ unsigned char normal_wiretype, packed_wiretype, processing_type;
+ normal_wiretype = WireFormat::WireTypeForFieldType(field->type());
+
+ if (field->is_packable()) {
+ packed_wiretype = WireFormatLite::WIRETYPE_LENGTH_DELIMITED;
+ } else {
+ packed_wiretype = internal::kNotPackedMask;
+ }
+
+ processing_type = static_cast<unsigned>(field->type());
+ if (field->type() == FieldDescriptor::TYPE_STRING) {
+ switch (EffectiveStringCType(field)) {
+ case FieldOptions::STRING:
+ default:
+ break;
+ }
+ } else if (field->type() == FieldDescriptor::TYPE_BYTES) {
+ switch (EffectiveStringCType(field)) {
+ case FieldOptions::STRING:
+ default:
+ break;
+ }
+ }
+
+ processing_type |= static_cast<unsigned>(
+ field->is_repeated() ? internal::kRepeatedMask : 0);
+ const unsigned char tag_size =
+ WireFormat::TagSize(field->number(), field->type());
+
+ std::map<string, string> vars;
+ vars["classname"] = classname_;
+ vars["name"] = FieldName(field);
+ vars["has"] = SimpleItoa(has_bit_indices_[field->index()]);
+ vars["nwtype"] = SimpleItoa(normal_wiretype);
+ vars["pwtype"] = SimpleItoa(packed_wiretype);
+ vars["ptype"] = SimpleItoa(processing_type);
+ vars["tag_size"] = SimpleItoa(tag_size);
+
+ printer->Print(vars,
+ "{\n"
+ " GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(\n"
+ " $classname$, $name$_),\n"
+ " static_cast< ::google::protobuf::uint32>($has$),\n"
+ " $nwtype$, $pwtype$, $ptype$, $tag_size$\n"
+ "},\n");
+ }
+
+ return last_field_number;
+}
+
+size_t MessageGenerator::GenerateParseAuxTable(io::Printer* printer) {
+ if (!table_driven_) {
+ return 0;
+ }
+
+ std::vector<const FieldDescriptor*> ordered_fields =
+ SortFieldsByNumber(descriptor_);
+
+ printer->Print("::google::protobuf::internal::AuxillaryParseTableField(),\n");
+ int last_field_number = 1;
+ for (int i = 0; i < descriptor_->field_count(); i++) {
+ const FieldDescriptor* field = ordered_fields[i];
+
+ GOOGLE_CHECK_GE(field->number(), last_field_number);
+ for (; last_field_number < field->number(); last_field_number++) {
+ printer->Print("::google::protobuf::internal::AuxillaryParseTableField(),\n");
+ }
+
+ std::map<string, string> vars;
+ SetCommonFieldVariables(field, &vars, options_);
+
+ switch (field->cpp_type()) {
+ case FieldDescriptor::CPPTYPE_ENUM:
+ vars["type"] = ClassName(field->enum_type(), true);
+ printer->Print(
+ vars,
+ "{::google::protobuf::internal::AuxillaryParseTableField::enum_aux{"
+ "$type$_IsValid, \"$type$\" }},\n");
+ last_field_number++;
+ break;
+ case FieldDescriptor::CPPTYPE_MESSAGE: {
+ std::vector<string> package_parts;
+
+ const Descriptor* outer = field->message_type();
+ while (outer->containing_type() != NULL) {
+ outer = outer->containing_type();
+ }
+
+ package_parts = Split(
+ outer->full_name(), ".", true);
+ // outer->full_name() contains the class itself. Remove it as it is
+ // used in the name of the default instance variable.
+ GOOGLE_DCHECK_NE(package_parts.size(), 0);
+ package_parts.back().clear();
+
+ vars["classname"] = ClassName(field->message_type(), false);
+ vars["ns"] = Join(package_parts, "::");
+ vars["type"] = FieldMessageTypeName(field);
+ vars["file_namespace"] = FileLevelNamespace(outer->file()->name());
+
+ printer->Print(vars,
+ "{::google::protobuf::internal::AuxillaryParseTableField::message_aux{\n"
+ " &::$ns$_$classname$_default_instance_,\n");
+
+ bool dont_emit_table =
+ !TableDrivenEnabled(field->message_type(), options_);
+
+ if (dont_emit_table) {
+ printer->Print(" NULL,\n");
+ } else {
+ printer->Print(vars,
+ " ::$ns$$file_namespace$::TableStruct::schema +\n"
+ " ::$ns$$classname$::kIndexInFileMessages,\n");
+ }
+
+ printer->Print("}},\n");
+ last_field_number++;
+ break;
+ }
+ case FieldDescriptor::CPPTYPE_STRING:
+ switch (EffectiveStringCType(field)) {
+ case FieldOptions::STRING:
+ vars["default"] =
+ field->default_value_string().empty()
+ ? "&::google::protobuf::internal::fixed_address_empty_string"
+ : "&" + classname_ + "::_default_" + FieldName(field) + "_";
+ break;
+ case FieldOptions::CORD:
+ case FieldOptions::STRING_PIECE:
+ vars["default"] =
+ "\"" + CEscape(field->default_value_string()) + "\"";
+ break;
+ }
+ vars["full_name"] = field->full_name();
+ vars["strict"] =
+ field->file()->syntax() == FileDescriptor::SYNTAX_PROTO3
+ ? "true" : "false";
+ vars["type"] = field->full_name();
+ printer->Print(vars,
+ "{::google::protobuf::internal::AuxillaryParseTableField::string_aux{\n"
+ " $default$,\n"
+ " \"$full_name$\",\n"
+ " $strict$,\n"
+ " \"$type$\"\n"
+ "}},\n");
+ last_field_number++;
+ break;
+ default:
+ break;
+ }
+ }
+
+ return last_field_number;
+}
+
std::pair<size_t, size_t> MessageGenerator::GenerateOffsets(
io::Printer* printer) {
if (IsMapEntryMessage(descriptor_)) return std::make_pair(0, 0);
@@ -1765,7 +2064,8 @@ std::pair<size_t, size_t> MessageGenerator::GenerateOffsets(
if (HasFieldPresence(descriptor_->file())) {
printer->Print(
variables,
- "GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET($classname$, _has_bits_),\n");
+ "GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET($classname$, "
+ "_has_bits_),\n");
} else {
printer->Print("~0u, // no _has_bits_\n");
}
@@ -1775,34 +2075,41 @@ std::pair<size_t, size_t> MessageGenerator::GenerateOffsets(
if (descriptor_->extension_range_count() > 0) {
printer->Print(
variables,
- "GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET($classname$, _extensions_),\n");
+ "GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET($classname$, "
+ "_extensions_),\n");
} else {
printer->Print("~0u, // no _extensions_\n");
}
if (descriptor_->oneof_decl_count() > 0) {
printer->Print(variables,
- "GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET($classname$, "
- "_oneof_case_[0]),\n");
+ "GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET("
+ "$classname$, _oneof_case_[0]),\n");
} else {
printer->Print("~0u, // no _oneof_case_\n");
}
-
- const int kNumGenericOffsets = 4; // the number of fixed offsets above
+ if (num_weak_fields_ > 0) {
+ printer->Print(variables,
+ "GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET($classname$,"
+ " _weak_field_map_),\n");
+ } else {
+ printer->Print("~0u, // no _weak_field_map_\n");
+ }
+ const int kNumGenericOffsets = 5; // the number of fixed offsets above
const size_t offsets = kNumGenericOffsets +
descriptor_->field_count() +
descriptor_->oneof_decl_count();
size_t entries = offsets;
for (int i = 0; i < descriptor_->field_count(); i++) {
const FieldDescriptor* field = descriptor_->field(i);
- if (field->containing_oneof()) {
+ if (field->containing_oneof() || field->options().weak()) {
printer->Print(
- "PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET("
+ "GOOGLE_PROTOBUF_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET("
"(&_$classname$_default_instance_), $name$_),\n",
"classname", classname_, "name", FieldName(field));
} else {
printer->Print(
"GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET($classname$, "
- "$name$_),\n",
+ "$name$_),\n",
"classname", classname_,
"name", FieldName(field));
}
@@ -1844,19 +2151,6 @@ GenerateSharedConstructorCode(io::Printer* printer) {
need_to_clear_cached_size = false;
}
- // TODO(gerbens) Clean this hack, and why do i need a reference to a pointer??
- for (int i = 0; i < descriptor_->nested_type_count(); i++) {
- if (HasDescriptorMethods(descriptor_->file(), options_) &&
- IsMapEntryMessage(descriptor_->nested_type(i))) {
- printer->Print(
- "const ::google::protobuf::Descriptor*& $type$_descriptor = "
- "$file_namespace$::file_level_metadata[$index$].descriptor;\n",
- "type", ClassName(descriptor_->nested_type(i), false), "index",
- SimpleItoa(nested_generators_[i]->index_in_metadata_),
- "file_namespace", FileLevelNamespace(descriptor_->file()->name()));
- }
- }
-
std::vector<bool> processed(optimized_order_.size(), false);
GenerateConstructorBody(printer, processed, false);
@@ -1906,6 +2200,9 @@ GenerateSharedDestructorCode(io::Printer* printer) {
"oneof_name", descriptor_->oneof_decl(i)->name());
}
+ if (num_weak_fields_) {
+ printer->Print("_weak_field_map_.ClearAll();\n");
+ }
printer->Outdent();
printer->Print(
"}\n"
@@ -1956,6 +2253,12 @@ GenerateArenaDestructorCode(io::Printer* printer) {
}
}
}
+ if (num_weak_fields_) {
+ // _this is the object being destructed (we are inside a static method
+ // here).
+ printer->Print("_this->_weak_field_map_.ClearAll();\n");
+ need_registration = true;
+ }
printer->Outdent();
printer->Print(
@@ -2077,12 +2380,18 @@ GenerateStructors(io::Printer* printer) {
if (IsAnyMessage(descriptor_)) {
initializer_with_arena += ",\n _any_metadata_(&type_url_, &value_)";
}
+ if (num_weak_fields_ > 0) {
+ initializer_with_arena += ", _weak_field_map_(arena)";
+ }
string initializer_null;
initializer_null = ", _internal_metadata_(NULL)";
if (IsAnyMessage(descriptor_)) {
initializer_null += ", _any_metadata_(&type_url_, &value_)";
}
+ if (num_weak_fields_ > 0) {
+ initializer_null += ", _weak_field_map_(NULL)";
+ }
printer->Print(
"$classname$::$classname$()\n"
@@ -2165,6 +2474,9 @@ GenerateStructors(io::Printer* printer) {
if (IsAnyMessage(descriptor_)) {
printer->Print(",\n_any_metadata_(&type_url_, &value_)");
}
+ if (num_weak_fields_ > 0) {
+ printer->Print(",\n_weak_field_map_(from._weak_field_map_)");
+ }
printer->Outdent();
printer->Outdent();
@@ -2177,19 +2489,6 @@ GenerateStructors(io::Printer* printer) {
printer->Print("_extensions_.MergeFrom(from._extensions_);\n");
}
- // TODO(gerbens) Clean this hack, and why do i need a reference to a pointer??
- for (int i = 0; i < descriptor_->nested_type_count(); i++) {
- if (HasDescriptorMethods(descriptor_->file(), options_) &&
- IsMapEntryMessage(descriptor_->nested_type(i))) {
- printer->Print(
- "const ::google::protobuf::Descriptor*& $type$_descriptor = "
- "$file_namespace$::file_level_metadata[$index$].descriptor;\n",
- "type", ClassName(descriptor_->nested_type(i), false), "index",
- SimpleItoa(nested_generators_[i]->index_in_metadata_),
- "file_namespace", FileLevelNamespace(descriptor_->file()->name()));
- }
- }
-
GenerateConstructorBody(printer, processed, true);
// Copy oneof fields. Oneof field requires oneof case check.
@@ -2268,11 +2567,13 @@ GenerateStructors(io::Printer* printer) {
printer->Print(
"const ::google::protobuf::Descriptor* $classname$::descriptor() {\n"
" $file_namespace$::protobuf_AssignDescriptorsOnce();\n"
- " return $file_namespace$::file_level_metadata[$index$].descriptor;\n"
+ " return "
+ "$file_namespace$::file_level_metadata[kIndexInFileMessages]."
+ "descriptor;\n"
"}\n"
"\n",
- "index", SimpleItoa(index_in_metadata_), "classname", classname_,
- "file_namespace", FileLevelNamespace(descriptor_->file()->name()));
+ "classname", classname_, "file_namespace",
+ FileLevelNamespace(descriptor_->file()->name()));
}
printer->Print(
@@ -2504,6 +2805,10 @@ GenerateClear(io::Printer* printer) {
"oneof_name", descriptor_->oneof_decl(i)->name());
}
+ if (num_weak_fields_) {
+ printer->Print("_weak_field_map_.ClearAll();\n");
+ }
+
if (HasFieldPresence(descriptor_->file())) {
// Step 5: Everything else.
printer->Print("_has_bits_.Clear();\n");
@@ -2647,6 +2952,10 @@ GenerateSwap(io::Printer* printer) {
if (descriptor_->extension_range_count() > 0) {
printer->Print("_extensions_.Swap(&other->_extensions_);\n");
}
+ if (num_weak_fields_) {
+ printer->Print(
+ "_weak_field_map_.UnsafeArenaSwap(&other->_weak_field_map_);\n");
+ }
} else {
printer->Print("GetReflection()->Swap(this, other);");
}
@@ -2714,7 +3023,14 @@ GenerateMergeFrom(io::Printer* printer) {
}
printer->Print(
- "_internal_metadata_.MergeFrom(from._internal_metadata_);\n");
+ "_internal_metadata_.MergeFrom(from._internal_metadata_);\n"
+ "::google::protobuf::uint32 cached_has_bits = 0;\n"
+ "(void) cached_has_bits;\n\n");
+
+ // cached_has_bit_index maintains that:
+ // cached_has_bits = from._has_bits_[cached_has_bit_index]
+ // for cached_has_bit_index >= 0
+ int cached_has_bit_index = -1;
int last_i = -1;
for (int i = 0; i < optimized_order_.size(); ) {
@@ -2734,7 +3050,7 @@ GenerateMergeFrom(io::Printer* printer) {
generator.GenerateMergingCode(printer);
}
- // Merge Optional and Required fields (after a _has_bit check).
+ // Merge Optional and Required fields (after a _has_bit_ check).
int last_chunk = -1;
int last_chunk_start = -1;
int last_chunk_end = -1;
@@ -2779,23 +3095,43 @@ GenerateMergeFrom(io::Printer* printer) {
GOOGLE_DCHECK_LE(2, count);
GOOGLE_DCHECK_GE(8, count);
+ if (cached_has_bit_index != last_chunk / 4) {
+ int new_index = last_chunk / 4;
+ printer->Print("cached_has_bits = from._has_bits_[$new_index$];\n",
+ "new_index", SimpleItoa(new_index));
+ cached_has_bit_index = new_index;
+ }
+
printer->Print(
- "if (from._has_bits_[$index$ / 32] & $mask$u) {\n",
- "index", SimpleItoa(last_chunk * 8),
+ "if (cached_has_bits & $mask$u) {\n",
"mask", SimpleItoa(last_chunk_mask));
printer->Indent();
}
// Go back and emit clears for each of the fields we processed.
+ bool deferred_has_bit_changes = false;
for (int j = last_chunk_start; j <= last_chunk_end; j++) {
const FieldDescriptor* field = optimized_order_[j];
const FieldGenerator& generator = field_generators_.get(field);
bool have_enclosing_if = false;
if (HasFieldPresence(descriptor_->file())) {
- printer->Print(
- "if (from.has_$name$()) {\n",
- "name", FieldName(field));
+ // Attempt to use the state of cached_has_bits, if possible.
+ int has_bit_index = has_bit_indices_[field->index()];
+ if (!field->options().weak() &&
+ cached_has_bit_index == has_bit_index / 32) {
+ const string mask = StrCat(
+ strings::Hex(1u << (has_bit_index % 32),
+ strings::ZERO_PAD_8));
+
+ printer->Print(
+ "if (cached_has_bits & 0x$mask$u) {\n", "mask", mask);
+ } else {
+ printer->Print(
+ "if (from.has_$name$()) {\n",
+ "name", FieldName(field));
+ }
+
printer->Indent();
have_enclosing_if = true;
} else {
@@ -2805,7 +3141,17 @@ GenerateMergeFrom(io::Printer* printer) {
printer, "from.", field);
}
- generator.GenerateMergingCode(printer);
+ if (have_outer_if && IsPOD(field)) {
+ // GenerateCopyConstructorCode for enum and primitive scalar fields
+ // does not do _has_bits_ modifications. We defer _has_bits_
+ // manipulation until the end of the outer if.
+ //
+ // This can reduce the number of loads/stores by up to 7 per 8 fields.
+ deferred_has_bit_changes = true;
+ generator.GenerateCopyConstructorCode(printer);
+ } else {
+ generator.GenerateMergingCode(printer);
+ }
if (have_enclosing_if) {
printer->Outdent();
@@ -2814,6 +3160,14 @@ GenerateMergeFrom(io::Printer* printer) {
}
if (have_outer_if) {
+ if (deferred_has_bit_changes) {
+ // Flush the has bits for the primitives we deferred.
+ GOOGLE_CHECK_LE(0, cached_has_bit_index);
+ printer->Print(
+ "_has_bits_[$index$] |= cached_has_bits;\n",
+ "index", SimpleItoa(cached_has_bit_index));
+ }
+
printer->Outdent();
printer->Print("}\n");
}
@@ -2849,6 +3203,9 @@ GenerateMergeFrom(io::Printer* printer) {
printer->Print(
"}\n");
}
+ if (num_weak_fields_) {
+ printer->Print("_weak_field_map_.MergeFrom(from._weak_field_map_);\n");
+ }
printer->Outdent();
printer->Print("}\n");
@@ -2913,13 +3270,36 @@ GenerateMergeFromCodedStream(io::Printer* printer) {
return;
}
+ std::vector<const FieldDescriptor*> ordered_fields =
+ SortFieldsByNumber(descriptor_);
+
printer->Print(
"bool $classname$::MergePartialFromCodedStream(\n"
- " ::google::protobuf::io::CodedInputStream* input) {\n"
- "#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure\n"
- " ::google::protobuf::uint32 tag;\n",
+ " ::google::protobuf::io::CodedInputStream* input) {\n",
"classname", classname_);
+ if (table_driven_) {
+ printer->Indent();
+
+ printer->Print(
+ "return ::google::protobuf::internal::MergePartialFromCodedStream(\n"
+ " this,\n"
+ " $file_namespace$::TableStruct::schema[\n"
+ " $classname$::kIndexInFileMessages],\n"
+ " input);\n",
+ "classname", classname_,
+ "file_namespace", FileLevelNamespace(descriptor_->file()->name()));
+
+ printer->Outdent();
+
+ printer->Print("}\n");
+ return;
+ }
+
+ printer->Print(
+ "#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure\n"
+ " ::google::protobuf::uint32 tag;\n");
+
if (PreserveUnknownFields(descriptor_) &&
!UseUnknownFieldSet(descriptor_->file(), options_)) {
// Use LazyStringOutputString to avoid initializing unknown fields string
@@ -2928,7 +3308,8 @@ GenerateMergeFromCodedStream(io::Printer* printer) {
printer->Print(
" ::google::protobuf::io::LazyStringOutputStream unknown_fields_string(\n"
" ::google::protobuf::NewPermanentCallback(&_internal_metadata_,\n"
- " &::google::protobuf::internal::InternalMetadataWithArenaLite::mutable_unknown_fields));\n"
+ " &::google::protobuf::internal::InternalMetadataWithArenaLite::\n"
+ " mutable_unknown_fields));\n"
" ::google::protobuf::io::CodedOutputStream unknown_fields_stream(\n"
" &unknown_fields_string, false);\n",
"classname", classname_);
@@ -2942,8 +3323,6 @@ GenerateMergeFromCodedStream(io::Printer* printer) {
printer->Print("for (;;) {\n");
printer->Indent();
- std::vector<const FieldDescriptor*> ordered_fields =
- SortFieldsByNumber(descriptor_);
uint32 maxtag = descriptor_->field_count() == 0 ? 0 :
WireFormat::MakeTag(ordered_fields[descriptor_->field_count() - 1]);
const int kCutoff0 = 127; // fits in 1-byte varint
@@ -3004,20 +3383,8 @@ GenerateMergeFromCodedStream(io::Printer* printer) {
printer->Indent();
- // Find repeated messages and groups now, to simplify what follows.
- hash_set<int> fields_with_parse_loop;
- for (int i = 0; i < ordered_fields.size(); i++) {
- const FieldDescriptor* field = ordered_fields[i];
- if (field->is_repeated() &&
- (field->type() == FieldDescriptor::TYPE_MESSAGE ||
- field->type() == FieldDescriptor::TYPE_GROUP)) {
- fields_with_parse_loop.insert(i);
- }
- }
-
for (int i = 0; i < ordered_fields.size(); i++) {
const FieldDescriptor* field = ordered_fields[i];
- const bool loops = fields_with_parse_loop.count(i) > 0;
PrintFieldComment(printer, field);
@@ -3030,11 +3397,7 @@ GenerateMergeFromCodedStream(io::Printer* printer) {
// Emit code to parse the common, expected case.
printer->Print("if (static_cast< ::google::protobuf::uint8>(tag) ==\n"
" static_cast< ::google::protobuf::uint8>($commontag$u)) {\n",
- "commontag", SimpleItoa(WireFormat::MakeTag(field)));
-
- if (loops) {
- printer->Print(" DO_(input->IncrementRecursionDepth());\n");
- }
+ "commontag", SimpleItoa(WireFormat::MakeTag(field)));
printer->Indent();
if (field->is_packed()) {
@@ -3074,12 +3437,6 @@ GenerateMergeFromCodedStream(io::Printer* printer) {
" goto handle_unusual;\n"
"}\n");
- // For repeated messages/groups, we need to decrement recursion depth.
- if (loops) {
- printer->Print(
- "input->UnsafeDecrementRecursionDepth();\n");
- }
-
printer->Print(
"break;\n");
@@ -3194,7 +3551,7 @@ void MessageGenerator::GenerateSerializeOneofFields(
bool to_array) {
GOOGLE_CHECK(!fields.empty());
if (fields.size() == 1) {
- GenerateSerializeOneField(printer, fields[0], to_array);
+ GenerateSerializeOneField(printer, fields[0], to_array, -1);
return;
}
// We have multiple mutually exclusive choices. Emit a switch statement.
@@ -3227,14 +3584,31 @@ void MessageGenerator::GenerateSerializeOneofFields(
}
void MessageGenerator::GenerateSerializeOneField(
- io::Printer* printer, const FieldDescriptor* field, bool to_array) {
- PrintFieldComment(printer, field);
+ io::Printer* printer, const FieldDescriptor* field, bool to_array,
+ int cached_has_bits_index) {
+ if (!field->options().weak()) {
+ // For weakfields, PrintFieldComment is called during iteration.
+ PrintFieldComment(printer, field);
+ }
bool have_enclosing_if = false;
- if (!field->is_repeated() && HasFieldPresence(descriptor_->file())) {
- printer->Print(
- "if (has_$name$()) {\n",
- "name", FieldName(field));
+ if (field->options().weak()) {
+ } else if (!field->is_repeated() && HasFieldPresence(descriptor_->file())) {
+ // Attempt to use the state of cached_has_bits, if possible.
+ int has_bit_index = has_bit_indices_[field->index()];
+ if (cached_has_bits_index == has_bit_index / 32) {
+ const string mask = StrCat(
+ strings::Hex(1u << (has_bit_index % 32),
+ strings::ZERO_PAD_8));
+
+ printer->Print(
+ "if (cached_has_bits & 0x$mask$u) {\n", "mask", mask);
+ } else {
+ printer->Print(
+ "if (has_$name$()) {\n",
+ "name", FieldName(field));
+ }
+
printer->Indent();
have_enclosing_if = true;
} else if (!HasFieldPresence(descriptor_->file())) {
@@ -3341,7 +3715,6 @@ GenerateSerializeWithCachedSizesToArray(io::Printer* printer) {
"classname", classname_);
printer->Indent();
- printer->Print("(void)deterministic; // Unused\n");
printer->Print(
"// @@protoc_insertion_point(serialize_to_array_start:$full_name$)\n",
"full_name", descriptor_->full_name());
@@ -3372,7 +3745,8 @@ GenerateSerializeWithCachedSizesBody(io::Printer* printer, bool to_array) {
: mg_(mg),
printer_(printer),
to_array_(to_array),
- eager_(!HasFieldPresence(mg->descriptor_->file())) {}
+ eager_(!HasFieldPresence(mg->descriptor_->file())),
+ cached_has_bit_index_(-1) {}
~LazySerializerEmitter() { Flush(); }
@@ -3383,7 +3757,27 @@ GenerateSerializeWithCachedSizesBody(io::Printer* printer, bool to_array) {
Flush();
}
if (field->containing_oneof() == NULL) {
- mg_->GenerateSerializeOneField(printer_, field, to_array_);
+ // TODO(ckennelly): Defer non-oneof fields similarly to oneof fields.
+
+ if (!field->options().weak() && !field->is_repeated() && !eager_) {
+ // We speculatively load the entire _has_bits_[index] contents, even
+ // if it is for only one field. Deferring non-oneof emitting would
+ // allow us to determine whether this is going to be useful.
+ int has_bit_index = mg_->has_bit_indices_[field->index()];
+ if (cached_has_bit_index_ != has_bit_index / 32) {
+ // Reload.
+ int new_index = has_bit_index / 32;
+
+ printer_->Print(
+ "cached_has_bits = _has_bits_[$new_index$];\n",
+ "new_index", SimpleItoa(new_index));
+
+ cached_has_bit_index_ = new_index;
+ }
+ }
+
+ mg_->GenerateSerializeOneField(
+ printer_, field, to_array_, cached_has_bit_index_);
} else {
v_.push_back(field);
}
@@ -3409,6 +3803,11 @@ GenerateSerializeWithCachedSizesBody(io::Printer* printer, bool to_array) {
const bool to_array_;
const bool eager_;
std::vector<const FieldDescriptor*> v_;
+
+ // cached_has_bit_index_ maintains that:
+ // cached_has_bits = from._has_bits_[cached_has_bit_index_]
+ // for cached_has_bit_index_ >= 0
+ int cached_has_bit_index_;
};
std::vector<const FieldDescriptor*> ordered_fields =
@@ -3420,29 +3819,51 @@ GenerateSerializeWithCachedSizesBody(io::Printer* printer, bool to_array) {
}
std::sort(sorted_extensions.begin(), sorted_extensions.end(),
ExtensionRangeSorter());
+ if (num_weak_fields_) {
+ printer->Print(
+ "::google::protobuf::internal::WeakFieldMap::FieldWriter field_writer("
+ "_weak_field_map_);\n");
+ }
+
+ printer->Print(
+ "::google::protobuf::uint32 cached_has_bits = 0;\n"
+ "(void) cached_has_bits;\n\n");
// Merge the fields and the extension ranges, both sorted by field number.
{
LazySerializerEmitter e(this, printer, to_array);
+ const FieldDescriptor* last_weak_field = NULL;
int i, j;
for (i = 0, j = 0;
i < ordered_fields.size() || j < sorted_extensions.size();) {
- if (i == descriptor_->field_count()) {
- e.Flush();
- GenerateSerializeOneExtensionRange(printer,
- sorted_extensions[j++],
- to_array);
- } else if (j == sorted_extensions.size()) {
- e.Emit(ordered_fields[i++]);
- } else if (ordered_fields[i]->number() < sorted_extensions[j]->start) {
- e.Emit(ordered_fields[i++]);
- } else {
+ if ((j == sorted_extensions.size()) ||
+ (i < descriptor_->field_count() &&
+ ordered_fields[i]->number() < sorted_extensions[j]->start)) {
+ const FieldDescriptor* field = ordered_fields[i++];
+ if (field->options().weak()) {
+ last_weak_field = field;
+ PrintFieldComment(printer, field);
+ } else {
+ if (last_weak_field != NULL) {
+ e.Emit(last_weak_field);
+ last_weak_field = NULL;
+ }
+ e.Emit(field);
+ }
+ } else {
+ if (last_weak_field != NULL) {
+ e.Emit(last_weak_field);
+ last_weak_field = NULL;
+ }
e.Flush();
GenerateSerializeOneExtensionRange(printer,
sorted_extensions[j++],
to_array);
}
}
+ if (last_weak_field != NULL) {
+ e.Emit(last_weak_field);
+ }
}
if (PreserveUnknownFields(descriptor_)) {
@@ -3783,6 +4204,11 @@ GenerateByteSize(io::Printer* printer) {
"}\n");
}
+ if (num_weak_fields_) {
+ // TagSize + MessageSize
+ printer->Print("total_size += _weak_field_map_.ByteSizeLong();\n");
+ }
+
// We update _cached_size_ even though this is a const method. In theory,
// this is not thread-compatible, because concurrent writes have undefined
// results. In practice, since any concurrent writes will be writing the
@@ -3840,26 +4266,28 @@ GenerateIsInitialized(io::Printer* printer) {
// TODO(ckennelly): Push this down into a generator?
if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE &&
!ShouldIgnoreRequiredFieldCheck(field, options_) &&
- HasRequiredFields(field->message_type(), options_)) {
+ scc_analyzer_->HasRequiredFields(field->message_type())) {
if (field->is_repeated()) {
printer->Print(
"if (!::google::protobuf::internal::AllAreInitialized(this->$name$()))"
" return false;\n",
"name", FieldName(field));
+ } else if (field->options().weak()) {
+ continue;
} else {
- GOOGLE_CHECK(field->options().weak() || !field->containing_oneof());
- // For weak fields, use the data member (::google::protobuf::Message*) instead
- // of the getter to avoid a link dependency on the weak message type
- // which is only forward declared.
+ GOOGLE_CHECK(!field->containing_oneof());
printer->Print(
"if (has_$name$()) {\n"
" if (!this->$name$_->IsInitialized()) return false;\n"
"}\n",
- "name", FieldName(field));
+ "name", FieldName(field));
}
}
}
-
+ if (num_weak_fields_) {
+ // For Weak fields.
+ printer->Print("if (!_weak_field_map_.IsInitialized()) return false;\n");
+ }
// Go through the oneof fields, emitting a switch if any might have required
// fields.
for (int i = 0; i < descriptor_->oneof_decl_count(); i++) {
@@ -3871,7 +4299,7 @@ GenerateIsInitialized(io::Printer* printer) {
if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE &&
!ShouldIgnoreRequiredFieldCheck(field, options_) &&
- HasRequiredFields(field->message_type(), options_)) {
+ scc_analyzer_->HasRequiredFields(field->message_type())) {
has_required_fields = true;
break;
}
@@ -3894,17 +4322,10 @@ GenerateIsInitialized(io::Printer* printer) {
if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE &&
!ShouldIgnoreRequiredFieldCheck(field, options_) &&
- HasRequiredFields(field->message_type(), options_)) {
+ scc_analyzer_->HasRequiredFields(field->message_type())) {
GOOGLE_CHECK(!(field->options().weak() || !field->containing_oneof()));
if (field->options().weak()) {
- // For weak fields, use the data member (::google::protobuf::Message*) instead
- // of the getter to avoid a link dependency on the weak message type
- // which is only forward declared.
- printer->Print(
- "if (has_$name$()) {\n"
- " if (!this->$name$_->IsInitialized()) return false;\n"
- "}\n",
- "name", FieldName(field));
+ // Just skip.
} else {
printer->Print(
"if (has_$name$()) {\n"
diff --git a/src/google/protobuf/compiler/cpp/cpp_message.h b/src/google/protobuf/compiler/cpp/cpp_message.h
index 1a804a16..23aaeeb0 100644
--- a/src/google/protobuf/compiler/cpp/cpp_message.h
+++ b/src/google/protobuf/compiler/cpp/cpp_message.h
@@ -42,6 +42,7 @@
#include <set>
#include <string>
#include <google/protobuf/compiler/cpp/cpp_field.h>
+#include <google/protobuf/compiler/cpp/cpp_helpers.h>
#include <google/protobuf/compiler/cpp/cpp_options.h>
namespace google {
@@ -61,7 +62,8 @@ class ExtensionGenerator; // extension.h
class MessageGenerator {
public:
// See generator.cc for the meaning of dllexport_decl.
- MessageGenerator(const Descriptor* descriptor, const Options& options);
+ MessageGenerator(const Descriptor* descriptor, const Options& options,
+ SCCAnalyzer* scc_analyzer);
~MessageGenerator();
// Appends the pre-order walk of the nested generators to list.
@@ -94,10 +96,6 @@ class MessageGenerator {
// Generate extra fields
void GenerateExtraDefaultFields(io::Printer* printer);
- // Generate code that calls MessageFactory::InternalRegisterGeneratedMessage()
- // for all types.
- void GenerateTypeRegistrations(io::Printer* printer);
-
// Generates code that allocates the message's default instance.
void GenerateDefaultInstanceAllocator(io::Printer* printer);
@@ -121,6 +119,15 @@ class MessageGenerator {
void GenerateDependentFieldAccessorDefinitions(io::Printer* printer);
void GenerateFieldAccessorDefinitions(io::Printer* printer, bool is_inline);
+ // Generate the table-driven parsing array. Returns the number of entries
+ // generated.
+ size_t GenerateParseOffsets(io::Printer* printer);
+ size_t GenerateParseAuxTable(io::Printer* printer);
+ // Generates a ParseTable entry. Returns whether the proto uses table-driven
+ // parsing.
+ bool GenerateParseTable(io::Printer* printer, size_t offset,
+ size_t aux_offset);
+
// Generate the field offsets array. Returns the a pair of the total numer
// of entries generated and the index of the first has_bit entry.
std::pair<size_t, size_t> GenerateOffsets(io::Printer* printer);
@@ -155,9 +162,14 @@ class MessageGenerator {
void GenerateIsInitialized(io::Printer* printer);
// Helpers for GenerateSerializeWithCachedSizes().
+ //
+ // cached_has_bit_index maintains that:
+ // cached_has_bits = _has_bits_[cached_has_bit_index]
+ // for cached_has_bit_index >= 0
void GenerateSerializeOneField(io::Printer* printer,
const FieldDescriptor* field,
- bool unbounded);
+ bool unbounded,
+ int cached_has_bits_index);
// Generate a switch statement to serialize 2+ fields from the same oneof.
// Or, if fields.size() == 1, just call GenerateSerializeOneField().
void GenerateSerializeOneofFields(
@@ -197,7 +209,7 @@ class MessageGenerator {
// optimized_order_ is the order we layout the message's fields in the class.
// This is reused to initialize the fields in-order for cache efficiency.
//
- // optimized_order_ excludes oneof fields.
+ // optimized_order_ excludes oneof fields and weak fields.
std::vector<const FieldDescriptor *> optimized_order_;
std::vector<int> has_bit_indices_;
int max_has_bit_index_;
@@ -206,8 +218,13 @@ class MessageGenerator {
google::protobuf::scoped_array<google::protobuf::scoped_ptr<ExtensionGenerator> > extension_generators_;
int num_required_fields_;
bool use_dependent_base_;
+ int num_weak_fields_;
+ // table_driven_ indicates the generated message uses table-driven parsing.
+ bool table_driven_;
+
+ int index_in_file_messages_;
- int index_in_metadata_;
+ SCCAnalyzer* scc_analyzer_;
friend class FileGenerator;
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageGenerator);
diff --git a/src/google/protobuf/compiler/cpp/cpp_message_field.cc b/src/google/protobuf/compiler/cpp/cpp_message_field.cc
index c3d1745c..fc3c4564 100644
--- a/src/google/protobuf/compiler/cpp/cpp_message_field.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_message_field.cc
@@ -35,6 +35,7 @@
#include <google/protobuf/compiler/cpp/cpp_message_field.h>
#include <google/protobuf/compiler/cpp/cpp_helpers.h>
#include <google/protobuf/io/printer.h>
+
#include <google/protobuf/stubs/strutil.h>
namespace google {
@@ -583,7 +584,7 @@ GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const {
printer->Print(variables_,
"target = ::google::protobuf::internal::WireFormatLite::\n"
" InternalWrite$declared_type$NoVirtualToArray(\n"
- " $number$, *$non_null_ptr_to_name$, false, target);\n");
+ " $number$, *$non_null_ptr_to_name$, deterministic, target);\n");
}
void MessageFieldGenerator::
@@ -670,15 +671,6 @@ GenerateInlineAccessorDefinitions(io::Printer* printer,
InternalGenerateInlineAccessorDefinitions(variables, printer);
}
-void MessageOneofFieldGenerator::
-GenerateNonInlineAccessorDefinitions(io::Printer* printer) const {
- std::map<string, string> variables(variables_);
- variables["field_member"] =
- variables["oneof_prefix"] + variables["name"] + "_";
-
- //printer->Print(variables,
-}
-
void MessageOneofFieldGenerator::InternalGenerateInlineAccessorDefinitions(
const std::map<string, string>& variables, io::Printer* printer) const {
printer->Print(variables,
@@ -1066,7 +1058,7 @@ GenerateMergingCode(io::Printer* printer) const {
void RepeatedMessageFieldGenerator::
GenerateSwappingCode(io::Printer* printer) const {
- printer->Print(variables_, "$name$_.UnsafeArenaSwap(&other->$name$_);\n");
+ printer->Print(variables_, "$name$_.InternalSwap(&other->$name$_);\n");
}
void RepeatedMessageFieldGenerator::
@@ -1079,12 +1071,12 @@ GenerateMergeFromCodedStream(io::Printer* printer) const {
if (descriptor_->type() == FieldDescriptor::TYPE_MESSAGE) {
printer->Print(variables_,
"DO_(::google::protobuf::internal::WireFormatLite::"
- "ReadMessageNoVirtualNoRecursionDepth(\n"
+ "ReadMessageNoVirtual(\n"
" input, add_$name$()));\n");
} else {
printer->Print(variables_,
"DO_(::google::protobuf::internal::WireFormatLite::"
- "ReadGroupNoVirtualNoRecursionDepth(\n"
+ "ReadGroupNoVirtual(\n"
" $number$, input, add_$name$()));\n");
}
}
@@ -1104,7 +1096,7 @@ GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const {
"for (unsigned int i = 0, n = this->$name$_size(); i < n; i++) {\n"
" target = ::google::protobuf::internal::WireFormatLite::\n"
" InternalWrite$declared_type$NoVirtualToArray(\n"
- " $number$, this->$name$(i), false, target);\n"
+ " $number$, this->$name$(i), deterministic, target);\n"
"}\n");
}
diff --git a/src/google/protobuf/compiler/cpp/cpp_message_field.h b/src/google/protobuf/compiler/cpp/cpp_message_field.h
index 9ca91153..cd9737f0 100644
--- a/src/google/protobuf/compiler/cpp/cpp_message_field.h
+++ b/src/google/protobuf/compiler/cpp/cpp_message_field.h
@@ -95,7 +95,7 @@ class MessageOneofFieldGenerator : public MessageFieldGenerator {
void GenerateDependentInlineAccessorDefinitions(io::Printer* printer) const;
void GenerateInlineAccessorDefinitions(io::Printer* printer,
bool is_inline) const;
- void GenerateNonInlineAccessorDefinitions(io::Printer* printer) const;
+ void GenerateNonInlineAccessorDefinitions(io::Printer* printer) const { }
void GenerateClearingCode(io::Printer* printer) const;
// MessageFieldGenerator, from which we inherit, overrides this so we need to
diff --git a/src/google/protobuf/compiler/cpp/cpp_options.h b/src/google/protobuf/compiler/cpp/cpp_options.h
index ee44fb0a..bdaa12a5 100644
--- a/src/google/protobuf/compiler/cpp/cpp_options.h
+++ b/src/google/protobuf/compiler/cpp/cpp_options.h
@@ -46,16 +46,18 @@ struct Options {
Options()
: safe_boundary_check(false),
proto_h(false),
- allow_import_public(true),
+ transitive_pb_h(true),
annotate_headers(false),
- enforce_lite(false) {}
+ enforce_lite(false),
+ table_driven_parsing(false) {}
string dllexport_decl;
bool safe_boundary_check;
bool proto_h;
- bool allow_import_public;
+ bool transitive_pb_h;
bool annotate_headers;
bool enforce_lite;
+ bool table_driven_parsing;
string annotation_pragma_name;
string annotation_guard_name;
};
diff --git a/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc b/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc
index 4a0a23f6..020c1941 100644
--- a/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc
@@ -342,7 +342,7 @@ GenerateMergingCode(io::Printer* printer) const {
void RepeatedPrimitiveFieldGenerator::
GenerateSwappingCode(io::Printer* printer) const {
- printer->Print(variables_, "$name$_.UnsafeArenaSwap(&other->$name$_);\n");
+ printer->Print(variables_, "$name$_.InternalSwap(&other->$name$_);\n");
}
void RepeatedPrimitiveFieldGenerator::
@@ -385,6 +385,9 @@ GenerateSerializeWithCachedSizes(io::Printer* printer) const {
" output->WriteVarint32(_$name$_cached_byte_size_);\n");
if (FixedSize(descriptor_->type()) > 0) {
+ // TODO(ckennelly): Use RepeatedField<T>::unsafe_data() via
+ // WireFormatLite to access the contents of this->$name$_ to save a branch
+ // here.
printer->Print(variables_,
" ::google::protobuf::internal::WireFormatLite::Write$declared_type$Array(\n"
" this->$name$().data(), this->$name$_size(), output);\n");
@@ -420,20 +423,14 @@ GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const {
" target);\n"
" target = ::google::protobuf::io::CodedOutputStream::WriteVarint32ToArray(\n"
" _$name$_cached_byte_size_, target);\n"
- "}\n");
- }
- printer->Print(variables_,
- "for (int i = 0, n = this->$name$_size(); i < n; i++) {\n");
- if (descriptor_->is_packed()) {
- printer->Print(variables_,
" target = ::google::protobuf::internal::WireFormatLite::\n"
- " Write$declared_type$NoTagToArray(this->$name$(i), target);\n");
+ " Write$declared_type$NoTagToArray(this->$name$_, target);\n"
+ "}\n");
} else {
printer->Print(variables_,
- " target = ::google::protobuf::internal::WireFormatLite::\n"
- " Write$declared_type$ToArray($number$, this->$name$(i), target);\n");
+ "target = ::google::protobuf::internal::WireFormatLite::\n"
+ " Write$declared_type$ToArray($number$, this->$name$_, target);\n");
}
- printer->Print("}\n");
}
void RepeatedPrimitiveFieldGenerator::
diff --git a/src/google/protobuf/compiler/cpp/cpp_string_field.cc b/src/google/protobuf/compiler/cpp/cpp_string_field.cc
index 664a2779..7a849e2e 100644
--- a/src/google/protobuf/compiler/cpp/cpp_string_field.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_string_field.cc
@@ -36,6 +36,7 @@
#include <google/protobuf/compiler/cpp/cpp_helpers.h>
#include <google/protobuf/io/printer.h>
#include <google/protobuf/descriptor.pb.h>
+
#include <google/protobuf/stubs/strutil.h>
namespace google {
@@ -61,6 +62,7 @@ void SetStringVariables(const FieldDescriptor* descriptor,
".get()";
(*variables)["pointer_type"] =
descriptor->type() == FieldDescriptor::TYPE_BYTES ? "void" : "char";
+ (*variables)["null_check"] = "GOOGLE_DCHECK(value != NULL);\n";
// NOTE: Escaped here to unblock proto1->proto2 migration.
// TODO(liujisi): Extend this to apply for other conflicting methods.
(*variables)["release_name"] =
@@ -190,6 +192,7 @@ GenerateInlineAccessorDefinitions(io::Printer* printer,
" // @@protoc_insertion_point(field_set:$full_name$)\n"
"}\n"
"$inline$void $classname$::set_$name$(const char* value) {\n"
+ " $null_check$"
" $set_hasbit$\n"
" $name$_.Set($default_variable$, $string_piece$(value),\n"
" GetArenaNoVirtual());\n"
@@ -267,6 +270,7 @@ GenerateInlineAccessorDefinitions(io::Printer* printer,
"}\n"
"#endif\n"
"$inline$void $classname$::set_$name$(const char* value) {\n"
+ " $null_check$"
" $set_hasbit$\n"
" $name$_.SetNoArena($default_variable$, $string_piece$(value));\n"
" // @@protoc_insertion_point(field_set_char:$full_name$)\n"
@@ -548,6 +552,7 @@ GenerateInlineAccessorDefinitions(io::Printer* printer,
" // @@protoc_insertion_point(field_set:$full_name$)\n"
"}\n"
"$inline$void $classname$::set_$name$(const char* value) {\n"
+ " $null_check$"
" if (!has_$name$()) {\n"
" clear_$oneof_name$();\n"
" set_has_$name$();\n"
@@ -664,6 +669,7 @@ GenerateInlineAccessorDefinitions(io::Printer* printer,
"}\n"
"#endif\n"
"$inline$void $classname$::set_$name$(const char* value) {\n"
+ " $null_check$"
" if (!has_$name$()) {\n"
" clear_$oneof_name$();\n"
" set_has_$name$();\n"
@@ -882,6 +888,7 @@ GenerateInlineAccessorDefinitions(io::Printer* printer,
"}\n"
"#endif\n"
"$inline$void $classname$::set_$name$(int index, const char* value) {\n"
+ " $null_check$"
" $name$_.Mutable(index)->assign(value);\n"
" // @@protoc_insertion_point(field_set_char:$full_name$)\n"
"}\n"
@@ -902,11 +909,12 @@ GenerateInlineAccessorDefinitions(io::Printer* printer,
"}\n"
"#if LANG_CXX11\n"
"$inline$void $classname$::add_$name$(::std::string&& value) {\n"
- " $name$_.Add()->assign(std::move(value));\n"
+ " $name$_.Add(std::move(value));\n"
" // @@protoc_insertion_point(field_add:$full_name$)\n"
"}\n"
"#endif\n"
"$inline$void $classname$::add_$name$(const char* value) {\n"
+ " $null_check$"
" $name$_.Add()->assign(value);\n"
" // @@protoc_insertion_point(field_add_char:$full_name$)\n"
"}\n"
@@ -939,7 +947,7 @@ GenerateMergingCode(io::Printer* printer) const {
void RepeatedStringFieldGenerator::
GenerateSwappingCode(io::Printer* printer) const {
- printer->Print(variables_, "$name$_.UnsafeArenaSwap(&other->$name$_);\n");
+ printer->Print(variables_, "$name$_.InternalSwap(&other->$name$_);\n");
}
void RepeatedStringFieldGenerator::
@@ -969,7 +977,7 @@ GenerateMergeFromCodedStream(io::Printer* printer) const {
void RepeatedStringFieldGenerator::
GenerateSerializeWithCachedSizes(io::Printer* printer) const {
printer->Print(variables_,
- "for (int i = 0, n = this->$name$_size(); i < n; i++) {\n");
+ "for (int i = 0, n = this->$name$_size(); i < n; i++) {\n");
printer->Indent();
if (descriptor_->type() == FieldDescriptor::TYPE_STRING) {
GenerateUtf8CheckCodeForString(
diff --git a/src/google/protobuf/compiler/cpp/cpp_unittest.cc b/src/google/protobuf/compiler/cpp/cpp_unittest.cc
index 6d68ec35..e56964c7 100644
--- a/src/google/protobuf/compiler/cpp/cpp_unittest.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_unittest.cc
@@ -76,7 +76,6 @@
#include <google/protobuf/stubs/callback.h>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/stubs/logging.h>
-#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/stubs/substitute.h>
#include <google/protobuf/testing/googletest.h>
#include <gtest/gtest.h>
@@ -2162,6 +2161,61 @@ TEST_F(OneofTest, MergeFrom) {
}
+TEST(HelpersTest, TestSCC) {
+ protobuf_unittest::TestMutualRecursionA a;
+ SCCAnalyzer scc_analyzer((Options()));
+ const SCC* scc = scc_analyzer.GetSCC(a.GetDescriptor());
+ std::vector<string> names;
+ for (int i = 0; i < scc->descriptors.size(); i++) {
+ names.push_back(scc->descriptors[i]->full_name());
+ }
+ ASSERT_EQ(names.size(), 4);
+ std::sort(names.begin(), names.end());
+ EXPECT_EQ(names[0], "protobuf_unittest.TestMutualRecursionA");
+ EXPECT_EQ(names[1], "protobuf_unittest.TestMutualRecursionA.SubGroup");
+ EXPECT_EQ(names[2], "protobuf_unittest.TestMutualRecursionA.SubMessage");
+ EXPECT_EQ(names[3], "protobuf_unittest.TestMutualRecursionB");
+
+ MessageAnalysis result = scc_analyzer.GetSCCAnalysis(scc);
+ EXPECT_EQ(result.is_recursive, true);
+ EXPECT_EQ(result.contains_required, false);
+ EXPECT_EQ(result.contains_cord, true); // TestAllTypes
+ EXPECT_EQ(result.contains_extension, false); // TestAllTypes
+}
+
+TEST(HelpersTest, TestSCCAnalysis) {
+ {
+ protobuf_unittest::TestRecursiveMessage msg;
+ SCCAnalyzer scc_analyzer((Options()));
+ const SCC* scc = scc_analyzer.GetSCC(msg.GetDescriptor());
+ MessageAnalysis result = scc_analyzer.GetSCCAnalysis(scc);
+ EXPECT_EQ(result.is_recursive, true);
+ EXPECT_EQ(result.contains_required, false);
+ EXPECT_EQ(result.contains_cord, false);
+ EXPECT_EQ(result.contains_extension, false);
+ }
+ {
+ protobuf_unittest::TestAllExtensions msg;
+ SCCAnalyzer scc_analyzer((Options()));
+ const SCC* scc = scc_analyzer.GetSCC(msg.GetDescriptor());
+ MessageAnalysis result = scc_analyzer.GetSCCAnalysis(scc);
+ EXPECT_EQ(result.is_recursive, false);
+ EXPECT_EQ(result.contains_required, false);
+ EXPECT_EQ(result.contains_cord, false);
+ EXPECT_EQ(result.contains_extension, true);
+ }
+ {
+ protobuf_unittest::TestRequired msg;
+ SCCAnalyzer scc_analyzer((Options()));
+ const SCC* scc = scc_analyzer.GetSCC(msg.GetDescriptor());
+ MessageAnalysis result = scc_analyzer.GetSCCAnalysis(scc);
+ EXPECT_EQ(result.is_recursive, false);
+ EXPECT_EQ(result.contains_required, true);
+ EXPECT_EQ(result.contains_cord, false);
+ EXPECT_EQ(result.contains_extension, false);
+ }
+}
+
} // namespace cpp_unittest
} // namespace cpp
} // namespace compiler
diff --git a/src/google/protobuf/compiler/importer.cc b/src/google/protobuf/compiler/importer.cc
index 462748b9..844edc1c 100644
--- a/src/google/protobuf/compiler/importer.cc
+++ b/src/google/protobuf/compiler/importer.cc
@@ -222,6 +222,7 @@ void Importer::ClearUnusedImportTrackFiles() {
pool_.ClearUnusedImportTrackFiles();
}
+
// ===================================================================
SourceTree::~SourceTree() {}
diff --git a/src/google/protobuf/compiler/importer.h b/src/google/protobuf/compiler/importer.h
index 759636e1..a4ffcf87 100644
--- a/src/google/protobuf/compiler/importer.h
+++ b/src/google/protobuf/compiler/importer.h
@@ -175,6 +175,7 @@ class LIBPROTOBUF_EXPORT Importer {
void AddUnusedImportTrackFile(const string& file_name);
void ClearUnusedImportTrackFiles();
+
private:
SourceTreeDescriptorDatabase database_;
DescriptorPool pool_;
diff --git a/src/google/protobuf/compiler/importer_unittest.cc b/src/google/protobuf/compiler/importer_unittest.cc
index 00285bcc..a96ac853 100644
--- a/src/google/protobuf/compiler/importer_unittest.cc
+++ b/src/google/protobuf/compiler/importer_unittest.cc
@@ -47,11 +47,11 @@
#include <google/protobuf/testing/file.h>
#include <google/protobuf/io/zero_copy_stream_impl.h>
#include <google/protobuf/descriptor.h>
-#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/stubs/substitute.h>
#include <google/protobuf/testing/googletest.h>
#include <gtest/gtest.h>
#include <google/protobuf/stubs/map_util.h>
+#include <google/protobuf/stubs/strutil.h>
namespace google {
namespace protobuf {
diff --git a/src/google/protobuf/compiler/java/java_enum_field_lite.cc b/src/google/protobuf/compiler/java/java_enum_field_lite.cc
index 50eed5da..1eefdcfc 100644
--- a/src/google/protobuf/compiler/java/java_enum_field_lite.cc
+++ b/src/google/protobuf/compiler/java/java_enum_field_lite.cc
@@ -314,6 +314,7 @@ GenerateParsingDoneCode(io::Printer* printer) const {
// noop for enums
}
+
void ImmutableEnumFieldLiteGenerator::
GenerateSerializationCode(io::Printer* printer) const {
printer->Print(variables_,
@@ -423,6 +424,7 @@ GenerateMembers(io::Printer* printer) const {
"}\n");
}
+
void ImmutableEnumOneofFieldLiteGenerator::
GenerateBuilderMembers(io::Printer* printer) const {
if (SupportFieldPresence(descriptor_->file())) {
@@ -707,6 +709,7 @@ GenerateMembers(io::Printer* printer) const {
}
}
+
void RepeatedImmutableEnumFieldLiteGenerator::
GenerateBuilderMembers(io::Printer* printer) const {
WriteFieldDocComment(printer, descriptor_);
diff --git a/src/google/protobuf/compiler/java/java_enum_lite.cc b/src/google/protobuf/compiler/java/java_enum_lite.cc
index 96815920..38b054e7 100644
--- a/src/google/protobuf/compiler/java/java_enum_lite.cc
+++ b/src/google/protobuf/compiler/java/java_enum_lite.cc
@@ -49,17 +49,6 @@ namespace protobuf {
namespace compiler {
namespace java {
-namespace {
-bool EnumHasCustomOptions(const EnumDescriptor* descriptor) {
- if (descriptor->options().unknown_fields().field_count() > 0) return true;
- for (int i = 0; i < descriptor->value_count(); ++i) {
- const EnumValueDescriptor* value = descriptor->value(i);
- if (value->options().unknown_fields().field_count() > 0) return true;
- }
- return false;
-}
-} // namespace
-
EnumLiteGenerator::EnumLiteGenerator(const EnumDescriptor* descriptor,
bool immutable_api, Context* context)
: descriptor_(descriptor),
@@ -139,22 +128,30 @@ void EnumLiteGenerator::Generate(io::Printer* printer) {
// -----------------------------------------------------------------
printer->Print(
- "\n"
- "public final int getNumber() {\n"
- " return value;\n"
- "}\n"
- "\n"
- "/**\n"
- " * @deprecated Use {@link #forNumber(int)} instead.\n"
- " */\n"
- "@java.lang.Deprecated\n"
- "public static $classname$ valueOf(int value) {\n"
- " return forNumber(value);\n"
- "}\n"
- "\n"
- "public static $classname$ forNumber(int value) {\n"
- " switch (value) {\n",
- "classname", descriptor_->name());
+ "\n"
+ "public final int getNumber() {\n");
+ if (SupportUnknownEnumValue(descriptor_->file())) {
+ printer->Print(
+ " if (this == UNRECOGNIZED) {\n"
+ " throw new java.lang.IllegalArgumentException(\n"
+ " \"Can't get the number of an unknown enum value.\");\n"
+ " }\n");
+ }
+ printer->Print(
+ " return value;\n"
+ "}\n"
+ "\n"
+ "/**\n"
+ " * @deprecated Use {@link #forNumber(int)} instead.\n"
+ " */\n"
+ "@java.lang.Deprecated\n"
+ "public static $classname$ valueOf(int value) {\n"
+ " return forNumber(value);\n"
+ "}\n"
+ "\n"
+ "public static $classname$ forNumber(int value) {\n"
+ " switch (value) {\n",
+ "classname", descriptor_->name());
printer->Indent();
printer->Indent();
diff --git a/src/google/protobuf/compiler/java/java_field.h b/src/google/protobuf/compiler/java/java_field.h
index 434e610c..cc1d83d9 100644
--- a/src/google/protobuf/compiler/java/java_field.h
+++ b/src/google/protobuf/compiler/java/java_field.h
@@ -119,6 +119,7 @@ class ImmutableFieldLiteGenerator {
virtual void GenerateEqualsCode(io::Printer* printer) const = 0;
virtual void GenerateHashCode(io::Printer* printer) const = 0;
+
virtual string GetBoxedType() const = 0;
private:
diff --git a/src/google/protobuf/compiler/java/java_file.cc b/src/google/protobuf/compiler/java/java_file.cc
index 86719f70..0fda166d 100644
--- a/src/google/protobuf/compiler/java/java_file.cc
+++ b/src/google/protobuf/compiler/java/java_file.cc
@@ -154,12 +154,6 @@ void CollectExtensions(const FileDescriptorProto& file_proto,
}
}
-// Compare two field descriptors, returning true if the first should come
-// before the second.
-bool CompareFieldsByName(const FieldDescriptor *a, const FieldDescriptor *b) {
- return a->full_name() < b->full_name();
-}
-
// Our static initialization methods can become very, very large.
// So large that if we aren't careful we end up blowing the JVM's
// 64K bytes of bytecode/method. Fortunately, since these static
diff --git a/src/google/protobuf/compiler/java/java_generator.cc b/src/google/protobuf/compiler/java/java_generator.cc
index 2c02d996..02141210 100644
--- a/src/google/protobuf/compiler/java/java_generator.cc
+++ b/src/google/protobuf/compiler/java/java_generator.cc
@@ -47,6 +47,7 @@
#include <google/protobuf/io/printer.h>
#include <google/protobuf/io/zero_copy_stream.h>
#include <google/protobuf/descriptor.pb.h>
+
#include <google/protobuf/stubs/strutil.h>
namespace google {
diff --git a/src/google/protobuf/compiler/java/java_helpers.cc b/src/google/protobuf/compiler/java/java_helpers.cc
index efb5fd45..8469740f 100644
--- a/src/google/protobuf/compiler/java/java_helpers.cc
+++ b/src/google/protobuf/compiler/java/java_helpers.cc
@@ -43,6 +43,7 @@
#include <google/protobuf/wire_format.h>
#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/stubs/substitute.h>
+#include <google/protobuf/stubs/hash.h> // for hash<T *>
namespace google {
namespace protobuf {
@@ -245,6 +246,7 @@ string ClassName(const FileDescriptor* descriptor) {
return name_resolver.GetClassName(descriptor, true);
}
+
string ExtraMessageInterfaces(const Descriptor* descriptor) {
string interfaces = "// @@protoc_insertion_point(message_implements:"
+ descriptor->full_name() + ")";
diff --git a/src/google/protobuf/compiler/java/java_lazy_message_field_lite.cc b/src/google/protobuf/compiler/java/java_lazy_message_field_lite.cc
index 49070ba0..51bb11f1 100644
--- a/src/google/protobuf/compiler/java/java_lazy_message_field_lite.cc
+++ b/src/google/protobuf/compiler/java/java_lazy_message_field_lite.cc
@@ -232,6 +232,7 @@ GenerateSerializedSizeCode(io::Printer* printer) const {
"}\n");
}
+
// ===================================================================
ImmutableLazyMessageOneofFieldLiteGenerator::
@@ -415,6 +416,7 @@ GenerateSerializedSizeCode(io::Printer* printer) const {
"}\n");
}
+
// ===================================================================
RepeatedImmutableLazyMessageFieldLiteGenerator::
@@ -716,6 +718,7 @@ GenerateSerializedSizeCode(io::Printer* printer) const {
"}\n");
}
+
} // namespace java
} // namespace compiler
} // namespace protobuf
diff --git a/src/google/protobuf/compiler/java/java_lazy_message_field_lite.h b/src/google/protobuf/compiler/java/java_lazy_message_field_lite.h
index 47ebeb49..65b84fbc 100644
--- a/src/google/protobuf/compiler/java/java_lazy_message_field_lite.h
+++ b/src/google/protobuf/compiler/java/java_lazy_message_field_lite.h
@@ -68,6 +68,7 @@ class ImmutableLazyMessageFieldLiteGenerator
void GenerateSerializationCode(io::Printer* printer) const;
void GenerateSerializedSizeCode(io::Printer* printer) const;
+
private:
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableLazyMessageFieldLiteGenerator);
};
@@ -87,6 +88,7 @@ class ImmutableLazyMessageOneofFieldLiteGenerator
void GenerateSerializationCode(io::Printer* printer) const;
void GenerateSerializedSizeCode(io::Printer* printer) const;
+
private:
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableLazyMessageOneofFieldLiteGenerator);
};
@@ -106,6 +108,7 @@ class RepeatedImmutableLazyMessageFieldLiteGenerator
void GenerateSerializationCode(io::Printer* printer) const;
void GenerateSerializedSizeCode(io::Printer* printer) const;
+
private:
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedImmutableLazyMessageFieldLiteGenerator);
};
diff --git a/src/google/protobuf/compiler/java/java_map_field_lite.cc b/src/google/protobuf/compiler/java/java_map_field_lite.cc
index 523052cc..36fa2b7b 100644
--- a/src/google/protobuf/compiler/java/java_map_field_lite.cc
+++ b/src/google/protobuf/compiler/java/java_map_field_lite.cc
@@ -484,6 +484,7 @@ GenerateMembers(io::Printer* printer) const {
}
}
+
void ImmutableMapFieldLiteGenerator::
GenerateBuilderMembers(io::Printer* printer) const {
printer->Print(
diff --git a/src/google/protobuf/compiler/java/java_map_field_lite.h b/src/google/protobuf/compiler/java/java_map_field_lite.h
index 63dedbc2..94aa4813 100644
--- a/src/google/protobuf/compiler/java/java_map_field_lite.h
+++ b/src/google/protobuf/compiler/java/java_map_field_lite.h
@@ -62,6 +62,7 @@ class ImmutableMapFieldLiteGenerator : public ImmutableFieldLiteGenerator {
void GenerateEqualsCode(io::Printer* printer) const;
void GenerateHashCode(io::Printer* printer) const;
+
string GetBoxedType() const;
private:
diff --git a/src/google/protobuf/compiler/java/java_message.cc b/src/google/protobuf/compiler/java/java_message.cc
index 3b8d7ab8..6e3b4a75 100644
--- a/src/google/protobuf/compiler/java/java_message.cc
+++ b/src/google/protobuf/compiler/java/java_message.cc
@@ -686,6 +686,17 @@ GenerateParseFromMethods(io::Printer* printer) {
// for code size.
printer->Print(
"public static $classname$ parseFrom(\n"
+ " java.nio.ByteBuffer data)\n"
+ " throws com.google.protobuf.InvalidProtocolBufferException {\n"
+ " return PARSER.parseFrom(data);\n"
+ "}\n"
+ "public static $classname$ parseFrom(\n"
+ " java.nio.ByteBuffer data,\n"
+ " com.google.protobuf.ExtensionRegistryLite extensionRegistry)\n"
+ " throws com.google.protobuf.InvalidProtocolBufferException {\n"
+ " return PARSER.parseFrom(data, extensionRegistry);\n"
+ "}\n"
+ "public static $classname$ parseFrom(\n"
" com.google.protobuf.ByteString data)\n"
" throws com.google.protobuf.InvalidProtocolBufferException {\n"
" return PARSER.parseFrom(data);\n"
diff --git a/src/google/protobuf/compiler/java/java_message_builder_lite.cc b/src/google/protobuf/compiler/java/java_message_builder_lite.cc
index 7e404ba1..1ad58c09 100644
--- a/src/google/protobuf/compiler/java/java_message_builder_lite.cc
+++ b/src/google/protobuf/compiler/java/java_message_builder_lite.cc
@@ -67,13 +67,6 @@ bool GenerateHasBits(const Descriptor* descriptor) {
return SupportFieldPresence(descriptor->file()) ||
HasRepeatedFields(descriptor);
}
-
-string MapValueImmutableClassdName(const Descriptor* descriptor,
- ClassNameResolver* name_resolver) {
- const FieldDescriptor* value_field = descriptor->FindFieldByName("value");
- GOOGLE_CHECK_EQ(FieldDescriptor::TYPE_MESSAGE, value_field->type());
- return name_resolver->GetImmutableClassName(value_field->message_type());
-}
} // namespace
MessageBuilderLiteGenerator::MessageBuilderLiteGenerator(
diff --git a/src/google/protobuf/compiler/java/java_message_field_lite.cc b/src/google/protobuf/compiler/java/java_message_field_lite.cc
index 0957676c..c71e9101 100644
--- a/src/google/protobuf/compiler/java/java_message_field_lite.cc
+++ b/src/google/protobuf/compiler/java/java_message_field_lite.cc
@@ -451,6 +451,7 @@ GenerateMembers(io::Printer* printer) const {
"}\n");
}
+
void ImmutableMessageOneofFieldLiteGenerator::
GenerateBuilderMembers(io::Printer* printer) const {
// The comments above the methods below are based on a hypothetical
@@ -856,6 +857,7 @@ GenerateFieldBuilderInitializationCode(io::Printer* printer) const {
"get$capitalized_name$FieldBuilder();\n");
}
+
void RepeatedImmutableMessageFieldLiteGenerator::
GenerateInitializationCode(io::Printer* printer) const {
printer->Print(variables_, "$name$_ = emptyProtobufList();\n");
diff --git a/src/google/protobuf/compiler/java/java_message_field_lite.h b/src/google/protobuf/compiler/java/java_message_field_lite.h
index dbb263de..7c814c6d 100644
--- a/src/google/protobuf/compiler/java/java_message_field_lite.h
+++ b/src/google/protobuf/compiler/java/java_message_field_lite.h
@@ -106,6 +106,7 @@ class ImmutableMessageOneofFieldLiteGenerator
void GenerateSerializationCode(io::Printer* printer) const;
void GenerateSerializedSizeCode(io::Printer* printer) const;
+
private:
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableMessageOneofFieldLiteGenerator);
};
@@ -135,6 +136,7 @@ class RepeatedImmutableMessageFieldLiteGenerator
void GenerateEqualsCode(io::Printer* printer) const;
void GenerateHashCode(io::Printer* printer) const;
+
string GetBoxedType() const;
protected:
diff --git a/src/google/protobuf/compiler/java/java_message_lite.cc b/src/google/protobuf/compiler/java/java_message_lite.cc
index e84321bb..5007ecee 100644
--- a/src/google/protobuf/compiler/java/java_message_lite.cc
+++ b/src/google/protobuf/compiler/java/java_message_lite.cc
@@ -398,6 +398,7 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) {
printer->Print(
"}\n"
+ "// fall through\n"
"case GET_DEFAULT_INSTANCE: {\n"
" return DEFAULT_INSTANCE;\n"
"}\n"
@@ -589,6 +590,19 @@ GenerateParseFromMethods(io::Printer* printer) {
// for code size.
printer->Print(
"public static $classname$ parseFrom(\n"
+ " java.nio.ByteBuffer data)\n"
+ " throws com.google.protobuf.InvalidProtocolBufferException {\n"
+ " return com.google.protobuf.GeneratedMessageLite.parseFrom(\n"
+ " DEFAULT_INSTANCE, data);\n"
+ "}\n"
+ "public static $classname$ parseFrom(\n"
+ " java.nio.ByteBuffer data,\n"
+ " com.google.protobuf.ExtensionRegistryLite extensionRegistry)\n"
+ " throws com.google.protobuf.InvalidProtocolBufferException {\n"
+ " return com.google.protobuf.GeneratedMessageLite.parseFrom(\n"
+ " DEFAULT_INSTANCE, data, extensionRegistry);\n"
+ "}\n"
+ "public static $classname$ parseFrom(\n"
" com.google.protobuf.ByteString data)\n"
" throws com.google.protobuf.InvalidProtocolBufferException {\n"
" return com.google.protobuf.GeneratedMessageLite.parseFrom(\n"
@@ -1057,21 +1071,6 @@ void ImmutableMessageLiteGenerator::GenerateDynamicMethodMergeFromStream(
// ===================================================================
-namespace {
-bool CheckHasBitsForEqualsAndHashCode(const FieldDescriptor* field) {
- if (field->is_repeated()) {
- return false;
- }
- if (SupportFieldPresence(field->file())) {
- return true;
- }
- return GetJavaType(field) == JAVATYPE_MESSAGE &&
- field->containing_oneof() == NULL;
-}
-} // namespace
-
-// ===================================================================
-
void ImmutableMessageLiteGenerator::
GenerateExtensionRegistrationCode(io::Printer* printer) {
for (int i = 0; i < descriptor_->extension_count(); i++) {
diff --git a/src/google/protobuf/compiler/java/java_primitive_field_lite.cc b/src/google/protobuf/compiler/java/java_primitive_field_lite.cc
index b04bf1c2..0e8e492f 100644
--- a/src/google/protobuf/compiler/java/java_primitive_field_lite.cc
+++ b/src/google/protobuf/compiler/java/java_primitive_field_lite.cc
@@ -297,6 +297,7 @@ GenerateFieldBuilderInitializationCode(io::Printer* printer) const {
// noop for primitives
}
+
void ImmutablePrimitiveFieldLiteGenerator::
GenerateInitializationCode(io::Printer* printer) const {
if (IsByteStringWithCustomDefaultValue(descriptor_)) {
@@ -747,6 +748,7 @@ GenerateFieldBuilderInitializationCode(io::Printer* printer) const {
// noop for primitives
}
+
void RepeatedImmutablePrimitiveFieldLiteGenerator::
GenerateInitializationCode(io::Printer* printer) const {
printer->Print(variables_, "$name$_ = $empty_list$;\n");
diff --git a/src/google/protobuf/compiler/java/java_primitive_field_lite.h b/src/google/protobuf/compiler/java/java_primitive_field_lite.h
index dc59f0cf..93416f0b 100644
--- a/src/google/protobuf/compiler/java/java_primitive_field_lite.h
+++ b/src/google/protobuf/compiler/java/java_primitive_field_lite.h
@@ -80,6 +80,7 @@ class ImmutablePrimitiveFieldLiteGenerator
void GenerateEqualsCode(io::Printer* printer) const;
void GenerateHashCode(io::Printer* printer) const;
+
string GetBoxedType() const;
protected:
@@ -110,6 +111,7 @@ class ImmutablePrimitiveOneofFieldLiteGenerator
void GenerateSerializationCode(io::Printer* printer) const;
void GenerateSerializedSizeCode(io::Printer* printer) const;
+
private:
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutablePrimitiveOneofFieldLiteGenerator);
};
@@ -142,6 +144,7 @@ class RepeatedImmutablePrimitiveFieldLiteGenerator
void GenerateEqualsCode(io::Printer* printer) const;
void GenerateHashCode(io::Printer* printer) const;
+
string GetBoxedType() const;
private:
diff --git a/src/google/protobuf/compiler/java/java_string_field_lite.cc b/src/google/protobuf/compiler/java/java_string_field_lite.cc
index 138e59b6..7e3ad1d0 100644
--- a/src/google/protobuf/compiler/java/java_string_field_lite.cc
+++ b/src/google/protobuf/compiler/java/java_string_field_lite.cc
@@ -295,6 +295,7 @@ GenerateFieldBuilderInitializationCode(io::Printer* printer) const {
// noop for strings
}
+
void ImmutableStringFieldLiteGenerator::
GenerateInitializationCode(io::Printer* printer) const {
printer->Print(variables_, "$name$_ = $default$;\n");
@@ -467,6 +468,7 @@ GenerateMembers(io::Printer* printer) const {
"}\n");
}
+
void ImmutableStringOneofFieldLiteGenerator::
GenerateBuilderMembers(io::Printer* printer) const {
if (SupportFieldPresence(descriptor_->file())) {
@@ -763,6 +765,7 @@ GenerateFieldBuilderInitializationCode(io::Printer* printer) const {
// noop for strings
}
+
void RepeatedImmutableStringFieldLiteGenerator::
GenerateInitializationCode(io::Printer* printer) const {
printer->Print(variables_, "$name$_ = $empty_list$;\n");
diff --git a/src/google/protobuf/compiler/java/java_string_field_lite.h b/src/google/protobuf/compiler/java/java_string_field_lite.h
index 80496c87..b7fb6409 100644
--- a/src/google/protobuf/compiler/java/java_string_field_lite.h
+++ b/src/google/protobuf/compiler/java/java_string_field_lite.h
@@ -78,6 +78,7 @@ class ImmutableStringFieldLiteGenerator : public ImmutableFieldLiteGenerator {
void GenerateEqualsCode(io::Printer* printer) const;
void GenerateHashCode(io::Printer* printer) const;
+
string GetBoxedType() const;
protected:
@@ -108,6 +109,7 @@ class ImmutableStringOneofFieldLiteGenerator
void GenerateSerializationCode(io::Printer* printer) const;
void GenerateSerializedSizeCode(io::Printer* printer) const;
+
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableStringOneofFieldLiteGenerator);
};
@@ -136,6 +138,7 @@ class RepeatedImmutableStringFieldLiteGenerator
void GenerateEqualsCode(io::Printer* printer) const;
void GenerateHashCode(io::Printer* printer) const;
+
string GetBoxedType() const;
private:
diff --git a/src/google/protobuf/compiler/js/embed.cc b/src/google/protobuf/compiler/js/embed.cc
index 57d38237..a725b62e 100644
--- a/src/google/protobuf/compiler/js/embed.cc
+++ b/src/google/protobuf/compiler/js/embed.cc
@@ -98,7 +98,7 @@ static void AddFile(const char* name, std::basic_ostream<char>* out) {
int main(int argc, char *argv[]) {
std::cout << "#include "
- "<google/protobuf/compiler/js/well_known_types_embed.h>\n";
+ "\"google/protobuf/compiler/js/well_known_types_embed.h\"\n";
std::cout << "struct FileToc well_known_types_js[] = {\n";
for (int i = 1; i < argc; i++) {
diff --git a/src/google/protobuf/compiler/js/js_generator.cc b/src/google/protobuf/compiler/js/js_generator.cc
index 727ed090..7c63e58f 100755
--- a/src/google/protobuf/compiler/js/js_generator.cc
+++ b/src/google/protobuf/compiler/js/js_generator.cc
@@ -198,8 +198,8 @@ string ModuleAlias(const string& filename) {
// Returns the fully normalized JavaScript path for the given
// file descriptor's package.
-string GetPath(const GeneratorOptions& options,
- const FileDescriptor* file) {
+string GetFilePath(const GeneratorOptions& options,
+ const FileDescriptor* file) {
if (!options.namespace_prefix.empty()) {
return options.namespace_prefix;
} else if (!file->package().empty()) {
@@ -231,51 +231,32 @@ string GetNestedMessageName(const Descriptor* descriptor) {
string GetPrefix(const GeneratorOptions& options,
const FileDescriptor* file_descriptor,
const Descriptor* containing_type) {
- string prefix =
- GetPath(options, file_descriptor) + GetNestedMessageName(containing_type);
+ string prefix = GetFilePath(options, file_descriptor) +
+ GetNestedMessageName(containing_type);
if (!prefix.empty()) {
prefix += ".";
}
return prefix;
}
-
// Returns the fully normalized JavaScript path for the given
// message descriptor.
-string GetPath(const GeneratorOptions& options,
- const Descriptor* descriptor) {
+string GetMessagePath(const GeneratorOptions& options,
+ const Descriptor* descriptor) {
return GetPrefix(
options, descriptor->file(),
descriptor->containing_type()) + descriptor->name();
}
-
-// Returns the fully normalized JavaScript path for the given
-// field's containing message descriptor.
-string GetPath(const GeneratorOptions& options,
- const FieldDescriptor* descriptor) {
- return GetPath(options, descriptor->containing_type());
-}
-
// Returns the fully normalized JavaScript path for the given
// enumeration descriptor.
-string GetPath(const GeneratorOptions& options,
- const EnumDescriptor* enum_descriptor) {
+string GetEnumPath(const GeneratorOptions& options,
+ const EnumDescriptor* enum_descriptor) {
return GetPrefix(
options, enum_descriptor->file(),
enum_descriptor->containing_type()) + enum_descriptor->name();
}
-
-// Returns the fully normalized JavaScript path for the given
-// enumeration value descriptor.
-string GetPath(const GeneratorOptions& options,
- const EnumValueDescriptor* value_descriptor) {
- return GetPath(
- options,
- value_descriptor->type()) + "." + value_descriptor->name();
-}
-
string MaybeCrossFileRef(const GeneratorOptions& options,
const FileDescriptor* from_file,
const Descriptor* to_message) {
@@ -288,7 +269,7 @@ string MaybeCrossFileRef(const GeneratorOptions& options,
to_message->name();
} else {
// Within a single file we use a full name.
- return GetPath(options, to_message);
+ return GetMessagePath(options, to_message);
}
}
@@ -413,7 +394,7 @@ string ToFileName(const string& input) {
// that top-level extensions should go in.
string GetExtensionFileName(const GeneratorOptions& options,
const FileDescriptor* file) {
- return options.output_dir + "/" + ToFileName(GetPath(options, file)) +
+ return options.output_dir + "/" + ToFileName(GetFilePath(options, file)) +
options.GetFileNameExtension();
}
@@ -550,14 +531,6 @@ string JSGetterName(const GeneratorOptions& options,
return name;
}
-string JSMapGetterName(const GeneratorOptions& options,
- const FieldDescriptor* field) {
- return JSIdent(options, field,
- /* is_upper_camel = */ true,
- /* is_map = */ true,
- /* drop_list = */ false);
-}
-
string JSOneofName(const OneofDescriptor* oneof) {
@@ -872,11 +845,11 @@ string ProtoTypeName(const GeneratorOptions& options,
case FieldDescriptor::TYPE_BYTES:
return "bytes";
case FieldDescriptor::TYPE_GROUP:
- return GetPath(options, field->message_type());
+ return GetMessagePath(options, field->message_type());
case FieldDescriptor::TYPE_ENUM:
- return GetPath(options, field->enum_type());
+ return GetEnumPath(options, field->enum_type());
case FieldDescriptor::TYPE_MESSAGE:
- return GetPath(options, field->message_type());
+ return GetMessagePath(options, field->message_type());
default:
return "";
}
@@ -925,9 +898,9 @@ string JSTypeName(const GeneratorOptions& options,
case FieldDescriptor::CPPTYPE_STRING:
return JSStringTypeName(options, field, bytes_mode);
case FieldDescriptor::CPPTYPE_ENUM:
- return GetPath(options, field->enum_type());
+ return GetEnumPath(options, field->enum_type());
case FieldDescriptor::CPPTYPE_MESSAGE:
- return GetPath(options, field->message_type());
+ return GetMessagePath(options, field->message_type());
default:
return "";
}
@@ -1111,7 +1084,7 @@ static const char* kRepeatedFieldArrayName = ".repeatedFields_";
string RepeatedFieldsArrayName(const GeneratorOptions& options,
const Descriptor* desc) {
return HasRepeatedFields(options, desc)
- ? (GetPath(options, desc) + kRepeatedFieldArrayName)
+ ? (GetMessagePath(options, desc) + kRepeatedFieldArrayName)
: "null";
}
@@ -1128,8 +1101,9 @@ static const char* kOneofGroupArrayName = ".oneofGroups_";
string OneofFieldsArrayName(const GeneratorOptions& options,
const Descriptor* desc) {
- return HasOneofFields(desc) ?
- (GetPath(options, desc) + kOneofGroupArrayName) : "null";
+ return HasOneofFields(desc)
+ ? (GetMessagePath(options, desc) + kOneofGroupArrayName)
+ : "null";
}
string RepeatedFieldNumberList(const GeneratorOptions& options,
@@ -1571,7 +1545,7 @@ void Generator::FindProvidesForMessage(
return;
}
- string name = GetPath(options, desc);
+ string name = GetMessagePath(options, desc);
provided->insert(name);
for (int i = 0; i < desc->enum_type_count(); i++) {
@@ -1588,7 +1562,7 @@ void Generator::FindProvidesForEnum(const GeneratorOptions& options,
io::Printer* printer,
const EnumDescriptor* enumdesc,
std::set<string>* provided) const {
- string name = GetPath(options, enumdesc);
+ string name = GetEnumPath(options, enumdesc);
provided->insert(name);
}
@@ -1604,9 +1578,8 @@ void Generator::FindProvidesForFields(
continue;
}
- string name =
- GetPath(options, field->file()) + "." +
- JSObjectFieldName(options, field);
+ string name = GetFilePath(options, field->file()) + "." +
+ JSObjectFieldName(options, field);
provided->insert(name);
}
}
@@ -1684,7 +1657,7 @@ void Generator::GenerateRequiresForLibrary(
}
if (extension->containing_type()->full_name() !=
"google.protobuf.bridge.MessageSet") {
- required.insert(GetPath(options, extension->containing_type()));
+ required.insert(GetMessagePath(options, extension->containing_type()));
}
FindRequiresForField(options, extension, &required, &forwards);
have_extensions = true;
@@ -1805,13 +1778,13 @@ void Generator::FindRequiresForField(const GeneratorOptions& options,
// dependencies, as per original codegen.
!(field->is_extension() && field->extension_scope() == NULL)) {
if (options.add_require_for_enums) {
- required->insert(GetPath(options, field->enum_type()));
+ required->insert(GetEnumPath(options, field->enum_type()));
} else {
- forwards->insert(GetPath(options, field->enum_type()));
+ forwards->insert(GetEnumPath(options, field->enum_type()));
}
} else if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
if (!IgnoreMessage(options, field->message_type())) {
- required->insert(GetPath(options, field->message_type()));
+ required->insert(GetMessagePath(options, field->message_type()));
}
}
}
@@ -1821,7 +1794,7 @@ void Generator::FindRequiresForExtension(const GeneratorOptions& options,
std::set<string>* required,
std::set<string>* forwards) const {
if (field->containing_type()->full_name() != "google.protobuf.bridge.MessageSet") {
- required->insert(GetPath(options, field->containing_type()));
+ required->insert(GetMessagePath(options, field->containing_type()));
}
FindRequiresForField(options, field, required, forwards);
}
@@ -1868,7 +1841,7 @@ void Generator::GenerateClass(const GeneratorOptions& options,
}
// Recurse on nested types. These must come *before* the extension-field
- // info generation in GenerateClassRegistration so that extensions that
+ // info generation in GenerateClassRegistration so that extensions that
// reference nested types proceed the definitions of the nested types.
for (int i = 0; i < desc->enum_type_count(); i++) {
GenerateEnum(options, printer, desc->enum_type(i));
@@ -1890,7 +1863,6 @@ void Generator::GenerateClass(const GeneratorOptions& options,
}
}
}
-
}
void Generator::GenerateClassConstructor(const GeneratorOptions& options,
@@ -1912,7 +1884,7 @@ void Generator::GenerateClassConstructor(const GeneratorOptions& options,
" * @constructor\n"
" */\n"
"$classname$ = function(opt_data) {\n",
- "classname", GetPath(options, desc));
+ "classname", GetMessagePath(options, desc));
string message_id = GetMessageId(desc);
printer->Print(
" jspb.Message.initialize(this, opt_data, $messageId$, $pivot$, "
@@ -1929,7 +1901,7 @@ void Generator::GenerateClassConstructor(const GeneratorOptions& options,
"if (goog.DEBUG && !COMPILED) {\n"
" $classname$.displayName = '$classname$';\n"
"}\n",
- "classname", GetPath(options, desc));
+ "classname", GetMessagePath(options, desc));
}
void Generator::GenerateClassFieldInfo(const GeneratorOptions& options,
@@ -1944,7 +1916,7 @@ void Generator::GenerateClassFieldInfo(const GeneratorOptions& options,
" */\n"
"$classname$$rptfieldarray$ = $rptfields$;\n"
"\n",
- "classname", GetPath(options, desc),
+ "classname", GetMessagePath(options, desc),
"rptfieldarray", kRepeatedFieldArrayName,
"rptfields", RepeatedFieldNumberList(options, desc));
}
@@ -1965,7 +1937,7 @@ void Generator::GenerateClassFieldInfo(const GeneratorOptions& options,
" */\n"
"$classname$$oneofgrouparray$ = $oneofgroups$;\n"
"\n",
- "classname", GetPath(options, desc),
+ "classname", GetMessagePath(options, desc),
"oneofgrouparray", kOneofGroupArrayName,
"oneofgroups", OneofGroupList(desc));
@@ -1985,7 +1957,7 @@ void Generator::GenerateClassXid(const GeneratorOptions& options,
"\n"
"\n"
"$class$.prototype.messageXid = xid('$class$');\n",
- "class", GetPath(options, desc));
+ "class", GetMessagePath(options, desc));
}
void Generator::GenerateOneofCaseDefinition(
@@ -1998,7 +1970,7 @@ void Generator::GenerateOneofCaseDefinition(
" */\n"
"$classname$.$oneof$Case = {\n"
" $upcase$_NOT_SET: 0",
- "classname", GetPath(options, oneof->containing_type()),
+ "classname", GetMessagePath(options, oneof->containing_type()),
"oneof", JSOneofName(oneof),
"upcase", ToEnumCase(oneof->name()));
@@ -2026,7 +1998,7 @@ void Generator::GenerateOneofCaseDefinition(
"computeOneofCase(this, $class$.oneofGroups_[$oneofindex$]));\n"
"};\n"
"\n",
- "class", GetPath(options, oneof->containing_type()),
+ "class", GetMessagePath(options, oneof->containing_type()),
"oneof", JSOneofName(oneof),
"oneofindex", JSOneofIndex(oneof));
}
@@ -2068,7 +2040,7 @@ void Generator::GenerateClassToObject(const GeneratorOptions& options,
" */\n"
"$classname$.toObject = function(includeInstance, msg) {\n"
" var f, obj = {",
- "classname", GetPath(options, desc));
+ "classname", GetMessagePath(options, desc));
bool first = true;
for (int i = 0; i < desc->field_count(); i++) {
@@ -2100,7 +2072,7 @@ void Generator::GenerateClassToObject(const GeneratorOptions& options,
" $extObject$, $class$.prototype.getExtension,\n"
" includeInstance);\n",
"extObject", JSExtensionsObjectName(options, desc->file(), desc),
- "class", GetPath(options, desc));
+ "class", GetMessagePath(options, desc));
}
printer->Print(
@@ -2112,7 +2084,7 @@ void Generator::GenerateClassToObject(const GeneratorOptions& options,
"}\n"
"\n"
"\n",
- "classname", GetPath(options, desc));
+ "classname", GetMessagePath(options, desc));
}
void Generator::GenerateFieldValueExpression(io::Printer* printer,
@@ -2173,7 +2145,7 @@ void Generator::GenerateClassFieldToObject(const GeneratorOptions& options,
string value_to_object;
if (value_field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
value_to_object =
- GetPath(options, value_field->message_type()) + ".toObject";
+ GetMessagePath(options, value_field->message_type()) + ".toObject";
} else {
value_to_object = "undefined";
}
@@ -2235,7 +2207,7 @@ void Generator::GenerateClassFromObject(const GeneratorOptions& options,
" */\n"
"$classname$.fromObject = function(obj) {\n"
" var f, msg = new $classname$();\n",
- "classname", GetPath(options, desc));
+ "classname", GetMessagePath(options, desc));
for (int i = 0; i < desc->field_count(); i++) {
const FieldDescriptor* field = desc->field(i);
@@ -2263,7 +2235,7 @@ void Generator::GenerateClassFieldFromObject(
"$fieldclass$.fromObject));\n",
"name", JSObjectFieldName(options, field),
"index", JSFieldIndex(field),
- "fieldclass", GetPath(options, value_field->message_type()));
+ "fieldclass", GetMessagePath(options, value_field->message_type()));
} else {
// `msg` is a newly-constructed message object that has not yet built any
// map containers wrapping underlying arrays, so we can simply directly
@@ -2354,7 +2326,7 @@ void GenerateBytesWrapper(const GeneratorOptions& options,
"fielddef", FieldDefinition(options, field),
"comment", FieldComments(field, bytes_mode),
"type", type,
- "class", GetPath(options, field->containing_type()),
+ "class", GetMessagePath(options, field->containing_type()),
"name", JSGetterName(options, field, bytes_mode),
"list", field->is_repeated() ? "List" : "",
"suffix", JSByteGetterSuffix(bytes_mode),
@@ -2395,7 +2367,7 @@ void Generator::GenerateClassField(const GeneratorOptions& options,
printer->Print(
"$class$.prototype.get$name$ = function(opt_noLazyCreate) {\n"
" return /** @type {!jspb.Map<$keytype$,$valuetype$>} */ (\n",
- "class", GetPath(options, field->containing_type()),
+ "class", GetMessagePath(options, field->containing_type()),
"name", JSGetterName(options, field),
"keytype", key_type,
"valuetype", value_type);
@@ -2404,9 +2376,10 @@ void Generator::GenerateClassField(const GeneratorOptions& options,
"index", JSFieldIndex(field));
if (value_field->type() == FieldDescriptor::TYPE_MESSAGE) {
- printer->Print(",\n"
+ printer->Print(
+ ",\n"
" $messageType$",
- "messageType", GetPath(options, value_field->message_type()));
+ "messageType", GetMessagePath(options, value_field->message_type()));
} else {
printer->Print(",\n"
" null");
@@ -2443,7 +2416,7 @@ void Generator::GenerateClassField(const GeneratorOptions& options,
"};\n"
"\n"
"\n",
- "class", GetPath(options, field->containing_type()),
+ "class", GetMessagePath(options, field->containing_type()),
"name", JSGetterName(options, field),
"type", JSFieldTypeAnnotation(options, field,
/* is_setter_argument = */ false,
@@ -2464,7 +2437,7 @@ void Generator::GenerateClassField(const GeneratorOptions& options,
/* force_present = */ false,
/* singular_if_not_packed = */ false),
"returndoc", JSReturnDoc(options, field),
- "class", GetPath(options, field->containing_type()),
+ "class", GetMessagePath(options, field->containing_type()),
"name", JSGetterName(options, field),
"oneoftag", (field->containing_oneof() ? "Oneof" : ""),
"repeatedtag", (field->is_repeated() ? "Repeated" : ""));
@@ -2520,7 +2493,7 @@ void Generator::GenerateClassField(const GeneratorOptions& options,
printer->Print(
"$class$.prototype.get$name$ = function() {\n",
- "class", GetPath(options, field->containing_type()),
+ "class", GetMessagePath(options, field->containing_type()),
"name", JSGetterName(options, field));
if (untyped) {
@@ -2585,7 +2558,7 @@ void Generator::GenerateClassField(const GeneratorOptions& options,
printer->Print(
"$class$.prototype.set$name$ = function(value) {\n"
" jspb.Message.set$oneoftag$Field(this, $index$",
- "class", GetPath(options, field->containing_type()),
+ "class", GetMessagePath(options, field->containing_type()),
"name", JSGetterName(options, field),
"oneoftag", (field->containing_oneof() ? "Oneof" : ""),
"index", JSFieldIndex(field));
@@ -2626,7 +2599,7 @@ void Generator::GenerateClassField(const GeneratorOptions& options,
"};\n"
"\n"
"\n",
- "class", GetPath(options, field->containing_type()),
+ "class", GetMessagePath(options, field->containing_type()),
"name", JSGetterName(options, field),
"returnvalue", JSReturnClause(field));
} else if (field->is_repeated() ||
@@ -2639,7 +2612,7 @@ void Generator::GenerateClassField(const GeneratorOptions& options,
"};\n"
"\n"
"\n",
- "class", GetPath(options, field->containing_type()),
+ "class", GetMessagePath(options, field->containing_type()),
"name", JSGetterName(options, field),
"clearedvalue", (field->is_repeated() ? "[]" : "undefined"),
"returnvalue", JSReturnClause(field));
@@ -2650,7 +2623,7 @@ void Generator::GenerateClassField(const GeneratorOptions& options,
"$class$.prototype.clear$name$ = function() {\n"
" jspb.Message.set$maybeoneof$Field(this, "
"$index$$maybeoneofgroup$, ",
- "class", GetPath(options, field->containing_type()),
+ "class", GetMessagePath(options, field->containing_type()),
"name", JSGetterName(options, field),
"maybeoneof", (field->containing_oneof() ? "Oneof" : ""),
"maybeoneofgroup", (field->containing_oneof() ?
@@ -2676,7 +2649,7 @@ void Generator::GenerateClassField(const GeneratorOptions& options,
"};\n"
"\n"
"\n",
- "class", GetPath(options, field->containing_type()),
+ "class", GetMessagePath(options, field->containing_type()),
"name", JSGetterName(options, field),
"index", JSFieldIndex(field));
}
@@ -2692,8 +2665,8 @@ void Generator::GenerateRepeatedPrimitiveHelperMethods(
" */\n"
"$class$.prototype.add$name$ = function(value, opt_index) {\n"
" jspb.Message.addToRepeatedField(this, $index$",
- "class", GetPath(options, field->containing_type()), "name",
- JSGetterName(options, field, BYTES_DEFAULT,
+ "class", GetMessagePath(options, field->containing_type()),
+ "name", JSGetterName(options, field, BYTES_DEFAULT,
/* drop_list = */ true),
"optionaltype", JSTypeName(options, field, BYTES_DEFAULT), "index",
JSFieldIndex(field));
@@ -2719,9 +2692,9 @@ void Generator::GenerateRepeatedMessageHelperMethods(
" */\n"
"$class$.prototype.add$name$ = function(opt_value, opt_index) {\n"
" return jspb.Message.addTo$repeatedtag$WrapperField(",
- "optionaltype", JSTypeName(options, field, BYTES_DEFAULT), "class",
- GetPath(options, field->containing_type()), "name",
- JSGetterName(options, field, BYTES_DEFAULT,
+ "optionaltype", JSTypeName(options, field, BYTES_DEFAULT),
+ "class", GetMessagePath(options, field->containing_type()),
+ "name", JSGetterName(options, field, BYTES_DEFAULT,
/* drop_list = */ true),
"repeatedtag", (field->is_repeated() ? "Repeated" : ""));
@@ -2732,7 +2705,7 @@ void Generator::GenerateRepeatedMessageHelperMethods(
"\n",
"index", JSFieldIndex(field), "oneofgroup",
(field->containing_oneof() ? (", " + JSOneofArray(options, field)) : ""),
- "ctor", GetPath(options, field->message_type()));
+ "ctor", GetMessagePath(options, field->message_type()));
}
void Generator::GenerateClassExtensionFieldInfo(const GeneratorOptions& options,
@@ -2758,7 +2731,7 @@ void Generator::GenerateClassExtensionFieldInfo(const GeneratorOptions& options,
" */\n"
"$class$.extensions = {};\n"
"\n",
- "class", GetPath(options, desc));
+ "class", GetMessagePath(options, desc));
printer->Print(
"\n"
@@ -2779,7 +2752,7 @@ void Generator::GenerateClassExtensionFieldInfo(const GeneratorOptions& options,
" */\n"
"$class$.extensionsBinary = {};\n"
"\n",
- "class", GetPath(options, desc));
+ "class", GetMessagePath(options, desc));
}
}
@@ -2817,7 +2790,7 @@ void Generator::GenerateClassDeserializeBinary(const GeneratorOptions& options,
" }\n"
" var field = reader.getFieldNumber();\n"
" switch (field) {\n",
- "class", GetPath(options, desc));
+ "class", GetMessagePath(options, desc));
for (int i = 0; i < desc->field_count(); i++) {
if (!IgnoreField(desc->field(i))) {
@@ -2834,7 +2807,7 @@ void Generator::GenerateClassDeserializeBinary(const GeneratorOptions& options,
" $class$.prototype.setExtension);\n"
" break;\n",
"extobj", JSExtensionsObjectName(options, desc->file(), desc),
- "class", GetPath(options, desc));
+ "class", GetMessagePath(options, desc));
} else {
printer->Print(
" reader.skipField();\n"
@@ -2873,7 +2846,7 @@ void Generator::GenerateClassDeserializeBinaryField(
if (value_field->type() == FieldDescriptor::TYPE_MESSAGE) {
printer->Print(", $messageType$.deserializeBinaryFromReader",
- "messageType", GetPath(options, value_field->message_type()));
+ "messageType", GetMessagePath(options, value_field->message_type()));
}
printer->Print(");\n");
@@ -2941,7 +2914,7 @@ void Generator::GenerateClassSerializeBinary(const GeneratorOptions& options,
"$class$.serializeBinaryToWriter = function(message, "
"writer) {\n"
" var f = undefined;\n",
- "class", GetPath(options, desc));
+ "class", GetMessagePath(options, desc));
for (int i = 0; i < desc->field_count(); i++) {
if (!IgnoreField(desc->field(i))) {
@@ -2954,7 +2927,7 @@ void Generator::GenerateClassSerializeBinary(const GeneratorOptions& options,
" jspb.Message.serializeBinaryExtensions(message, writer,\n"
" $extobj$Binary, $class$.prototype.getExtension);\n",
"extobj", JSExtensionsObjectName(options, desc->file(), desc),
- "class", GetPath(options, desc));
+ "class", GetMessagePath(options, desc));
}
printer->Print(
@@ -3049,7 +3022,7 @@ void Generator::GenerateClassSerializeBinaryField(
if (value_field->type() == FieldDescriptor::TYPE_MESSAGE) {
printer->Print(", $messageType$.serializeBinaryToWriter",
- "messageType", GetPath(options, value_field->message_type()));
+ "messageType", GetMessagePath(options, value_field->message_type()));
}
printer->Print(");\n");
@@ -3088,7 +3061,7 @@ void Generator::GenerateEnum(const GeneratorOptions& options,
" * @enum {number}\n"
" */\n"
"$name$ = {\n",
- "name", GetPath(options, enumdesc));
+ "name", GetEnumPath(options, enumdesc));
for (int i = 0; i < enumdesc->value_count(); i++) {
const EnumValueDescriptor* value = enumdesc->value(i);
@@ -3108,9 +3081,9 @@ void Generator::GenerateExtension(const GeneratorOptions& options,
io::Printer* printer,
const FieldDescriptor* field) const {
string extension_scope =
- (field->extension_scope() ?
- GetPath(options, field->extension_scope()) :
- GetPath(options, field->file()));
+ (field->extension_scope()
+ ? GetMessagePath(options, field->extension_scope())
+ : GetFilePath(options, field->file()));
printer->Print(
"\n"
@@ -3347,7 +3320,7 @@ void Generator::GenerateFile(const GeneratorOptions& options,
IgnoreField(file->extension(i))) {
continue;
}
- provided.insert(GetPath(options, file) + "." +
+ provided.insert(GetFilePath(options, file) + "." +
JSObjectFieldName(options, file->extension(i)));
extensions.insert(file->extension(i));
}
@@ -3371,7 +3344,7 @@ void Generator::GenerateFile(const GeneratorOptions& options,
if (options.import_style == GeneratorOptions::kImportCommonJs) {
printer->Print("goog.object.extend(exports, $package$);\n",
- "package", GetPath(options, file));
+ "package", GetFilePath(options, file));
}
// Emit well-known type methods.
diff --git a/src/google/protobuf/compiler/js/well_known_types/timestamp.js b/src/google/protobuf/compiler/js/well_known_types/timestamp.js
index 77c07bb4..b7e43f19 100644
--- a/src/google/protobuf/compiler/js/well_known_types/timestamp.js
+++ b/src/google/protobuf/compiler/js/well_known_types/timestamp.js
@@ -48,7 +48,6 @@ proto.google.protobuf.Timestamp.prototype.toDate = function() {
* @param {!Date} value The value to set.
*/
proto.google.protobuf.Timestamp.prototype.fromDate = function(value) {
- var millis = value.getTime();
this.setSeconds(Math.floor(value.getTime() / 1000));
this.setNanos(value.getMilliseconds() * 1000000);
};
diff --git a/src/google/protobuf/compiler/mock_code_generator.cc b/src/google/protobuf/compiler/mock_code_generator.cc
index a4b522ce..0ddb99e5 100644
--- a/src/google/protobuf/compiler/mock_code_generator.cc
+++ b/src/google/protobuf/compiler/mock_code_generator.cc
@@ -40,27 +40,21 @@
#endif
#include <vector>
+#include <google/protobuf/stubs/strutil.h>
+
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/testing/file.h>
#include <google/protobuf/testing/file.h>
#include <google/protobuf/testing/file.h>
+#include <google/protobuf/compiler/plugin.pb.h>
#include <google/protobuf/io/printer.h>
#include <google/protobuf/io/zero_copy_stream.h>
#include <google/protobuf/descriptor.pb.h>
#include <google/protobuf/descriptor.h>
-#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/stubs/substitute.h>
#include <gtest/gtest.h>
-#ifdef major
-#undef major
-#endif
-#ifdef minor
-#undef minor
-#endif
-#include <google/protobuf/compiler/plugin.pb.h>
-
namespace google {
namespace protobuf {
namespace compiler {
diff --git a/src/google/protobuf/compiler/parser_unittest.cc b/src/google/protobuf/compiler/parser_unittest.cc
index 20140f8e..d5e31325 100644
--- a/src/google/protobuf/compiler/parser_unittest.cc
+++ b/src/google/protobuf/compiler/parser_unittest.cc
@@ -42,14 +42,13 @@
#include <google/protobuf/compiler/parser.h>
+#include <google/protobuf/unittest.pb.h>
+#include <google/protobuf/unittest_custom_options.pb.h>
#include <google/protobuf/io/tokenizer.h>
#include <google/protobuf/io/zero_copy_stream_impl.h>
#include <google/protobuf/descriptor.pb.h>
-#include <google/protobuf/wire_format.h>
#include <google/protobuf/text_format.h>
-#include <google/protobuf/unittest.pb.h>
-#include <google/protobuf/unittest_custom_options.pb.h>
-#include <google/protobuf/stubs/strutil.h>
+#include <google/protobuf/wire_format.h>
#include <google/protobuf/stubs/substitute.h>
#include <google/protobuf/stubs/map_util.h>
diff --git a/src/google/protobuf/compiler/plugin.pb.cc b/src/google/protobuf/compiler/plugin.pb.cc
index d044fbbe..f7dc1b70 100644
--- a/src/google/protobuf/compiler/plugin.pb.cc
+++ b/src/google/protobuf/compiler/plugin.pb.cc
@@ -38,11 +38,29 @@ namespace {
} // namespace
+PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::ParseTableField
+ const TableStruct::entries[] = {
+ {0, 0, 0, ::google::protobuf::internal::kInvalidMask, 0, 0},
+};
+
+PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::AuxillaryParseTableField
+ const TableStruct::aux[] = {
+ ::google::protobuf::internal::AuxillaryParseTableField(),
+};
+PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::ParseTable const
+ TableStruct::schema[] = {
+ { NULL, NULL, 0, -1, -1, false },
+ { NULL, NULL, 0, -1, -1, false },
+ { NULL, NULL, 0, -1, -1, false },
+ { NULL, NULL, 0, -1, -1, false },
+};
+
const ::google::protobuf::uint32 TableStruct::offsets[] = {
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Version, _has_bits_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Version, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
+ ~0u, // no _weak_field_map_
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Version, major_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Version, minor_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Version, patch_),
@@ -55,6 +73,7 @@ const ::google::protobuf::uint32 TableStruct::offsets[] = {
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
+ ~0u, // no _weak_field_map_
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, file_to_generate_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, parameter_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, proto_file_),
@@ -67,6 +86,7 @@ const ::google::protobuf::uint32 TableStruct::offsets[] = {
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse_File, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
+ ~0u, // no _weak_field_map_
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse_File, name_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse_File, insertion_point_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse_File, content_),
@@ -77,6 +97,7 @@ const ::google::protobuf::uint32 TableStruct::offsets[] = {
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
+ ~0u, // no _weak_field_map_
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse, error_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse, file_),
0,
@@ -84,10 +105,10 @@ const ::google::protobuf::uint32 TableStruct::offsets[] = {
};
static const ::google::protobuf::internal::MigrationSchema schemas[] = {
- { 0, 8, sizeof(Version)},
- { 12, 20, sizeof(CodeGeneratorRequest)},
- { 24, 31, sizeof(CodeGeneratorResponse_File)},
- { 34, 40, sizeof(CodeGeneratorResponse)},
+ { 0, 9, sizeof(Version)},
+ { 13, 22, sizeof(CodeGeneratorRequest)},
+ { 26, 34, sizeof(CodeGeneratorResponse_File)},
+ { 37, 44, sizeof(CodeGeneratorResponse)},
};
static ::google::protobuf::Message const * const file_default_instances[] = {
@@ -246,7 +267,7 @@ void Version::SetCachedSize(int size) const {
}
const ::google::protobuf::Descriptor* Version::descriptor() {
protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::protobuf_AssignDescriptorsOnce();
- return protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::file_level_metadata[0].descriptor;
+ return protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::file_level_metadata[kIndexInFileMessages].descriptor;
}
const Version& Version::default_instance() {
@@ -369,23 +390,27 @@ failure:
void Version::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.protobuf.compiler.Version)
+ ::google::protobuf::uint32 cached_has_bits = 0;
+ (void) cached_has_bits;
+
+ cached_has_bits = _has_bits_[0];
// optional int32 major = 1;
- if (has_major()) {
+ if (cached_has_bits & 0x00000002u) {
::google::protobuf::internal::WireFormatLite::WriteInt32(1, this->major(), output);
}
// optional int32 minor = 2;
- if (has_minor()) {
+ if (cached_has_bits & 0x00000004u) {
::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->minor(), output);
}
// optional int32 patch = 3;
- if (has_patch()) {
+ if (cached_has_bits & 0x00000008u) {
::google::protobuf::internal::WireFormatLite::WriteInt32(3, this->patch(), output);
}
// optional string suffix = 4;
- if (has_suffix()) {
+ if (cached_has_bits & 0x00000001u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->suffix().data(), this->suffix().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
@@ -403,25 +428,28 @@ void Version::SerializeWithCachedSizes(
::google::protobuf::uint8* Version::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.compiler.Version)
+ ::google::protobuf::uint32 cached_has_bits = 0;
+ (void) cached_has_bits;
+
+ cached_has_bits = _has_bits_[0];
// optional int32 major = 1;
- if (has_major()) {
+ if (cached_has_bits & 0x00000002u) {
target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(1, this->major(), target);
}
// optional int32 minor = 2;
- if (has_minor()) {
+ if (cached_has_bits & 0x00000004u) {
target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->minor(), target);
}
// optional int32 patch = 3;
- if (has_patch()) {
+ if (cached_has_bits & 0x00000008u) {
target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(3, this->patch(), target);
}
// optional string suffix = 4;
- if (has_suffix()) {
+ if (cached_has_bits & 0x00000001u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->suffix().data(), this->suffix().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
@@ -504,20 +532,25 @@ void Version::MergeFrom(const Version& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.Version)
GOOGLE_DCHECK_NE(&from, this);
_internal_metadata_.MergeFrom(from._internal_metadata_);
- if (from._has_bits_[0 / 32] & 15u) {
- if (from.has_suffix()) {
+ ::google::protobuf::uint32 cached_has_bits = 0;
+ (void) cached_has_bits;
+
+ cached_has_bits = from._has_bits_[0];
+ if (cached_has_bits & 15u) {
+ if (cached_has_bits & 0x00000001u) {
set_has_suffix();
suffix_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.suffix_);
}
- if (from.has_major()) {
- set_major(from.major());
+ if (cached_has_bits & 0x00000002u) {
+ major_ = from.major_;
}
- if (from.has_minor()) {
- set_minor(from.minor());
+ if (cached_has_bits & 0x00000004u) {
+ minor_ = from.minor_;
}
- if (from.has_patch()) {
- set_patch(from.patch());
+ if (cached_has_bits & 0x00000008u) {
+ patch_ = from.patch_;
}
+ _has_bits_[0] |= cached_has_bits;
}
}
@@ -555,7 +588,7 @@ void Version::InternalSwap(Version* other) {
::google::protobuf::Metadata Version::GetMetadata() const {
protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::protobuf_AssignDescriptorsOnce();
- return protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::file_level_metadata[0];
+ return protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::file_level_metadata[kIndexInFileMessages];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
@@ -665,6 +698,7 @@ void Version::set_suffix(::std::string&& value) {
}
#endif
void Version::set_suffix(const char* value) {
+ GOOGLE_DCHECK(value != NULL);
set_has_suffix();
suffix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
// @@protoc_insertion_point(field_set_char:google.protobuf.compiler.Version.suffix)
@@ -759,7 +793,7 @@ void CodeGeneratorRequest::SetCachedSize(int size) const {
}
const ::google::protobuf::Descriptor* CodeGeneratorRequest::descriptor() {
protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::protobuf_AssignDescriptorsOnce();
- return protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::file_level_metadata[1].descriptor;
+ return protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::file_level_metadata[kIndexInFileMessages].descriptor;
}
const CodeGeneratorRequest& CodeGeneratorRequest::default_instance() {
@@ -852,13 +886,11 @@ bool CodeGeneratorRequest::MergePartialFromCodedStream(
case 15: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(122u)) {
- DO_(input->IncrementRecursionDepth());
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
input, add_proto_file()));
} else {
goto handle_unusual;
}
- input->UnsafeDecrementRecursionDepth();
break;
}
@@ -887,6 +919,9 @@ failure:
void CodeGeneratorRequest::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.protobuf.compiler.CodeGeneratorRequest)
+ ::google::protobuf::uint32 cached_has_bits = 0;
+ (void) cached_has_bits;
+
// repeated string file_to_generate = 1;
for (int i = 0, n = this->file_to_generate_size(); i < n; i++) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
@@ -897,8 +932,9 @@ void CodeGeneratorRequest::SerializeWithCachedSizes(
1, this->file_to_generate(i), output);
}
+ cached_has_bits = _has_bits_[0];
// optional string parameter = 2;
- if (has_parameter()) {
+ if (cached_has_bits & 0x00000001u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->parameter().data(), this->parameter().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
@@ -908,7 +944,7 @@ void CodeGeneratorRequest::SerializeWithCachedSizes(
}
// optional .google.protobuf.compiler.Version compiler_version = 3;
- if (has_compiler_version()) {
+ if (cached_has_bits & 0x00000002u) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
3, *this->compiler_version_, output);
}
@@ -928,8 +964,10 @@ void CodeGeneratorRequest::SerializeWithCachedSizes(
::google::protobuf::uint8* CodeGeneratorRequest::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.compiler.CodeGeneratorRequest)
+ ::google::protobuf::uint32 cached_has_bits = 0;
+ (void) cached_has_bits;
+
// repeated string file_to_generate = 1;
for (int i = 0, n = this->file_to_generate_size(); i < n; i++) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
@@ -940,8 +978,9 @@ void CodeGeneratorRequest::SerializeWithCachedSizes(
WriteStringToArray(1, this->file_to_generate(i), target);
}
+ cached_has_bits = _has_bits_[0];
// optional string parameter = 2;
- if (has_parameter()) {
+ if (cached_has_bits & 0x00000001u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->parameter().data(), this->parameter().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
@@ -952,17 +991,17 @@ void CodeGeneratorRequest::SerializeWithCachedSizes(
}
// optional .google.protobuf.compiler.Version compiler_version = 3;
- if (has_compiler_version()) {
+ if (cached_has_bits & 0x00000002u) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageNoVirtualToArray(
- 3, *this->compiler_version_, false, target);
+ 3, *this->compiler_version_, deterministic, target);
}
// repeated .google.protobuf.FileDescriptorProto proto_file = 15;
for (unsigned int i = 0, n = this->proto_file_size(); i < n; i++) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageNoVirtualToArray(
- 15, this->proto_file(i), false, target);
+ 15, this->proto_file(i), deterministic, target);
}
if (_internal_metadata_.have_unknown_fields()) {
@@ -1043,14 +1082,18 @@ void CodeGeneratorRequest::MergeFrom(const CodeGeneratorRequest& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.CodeGeneratorRequest)
GOOGLE_DCHECK_NE(&from, this);
_internal_metadata_.MergeFrom(from._internal_metadata_);
+ ::google::protobuf::uint32 cached_has_bits = 0;
+ (void) cached_has_bits;
+
file_to_generate_.MergeFrom(from.file_to_generate_);
proto_file_.MergeFrom(from.proto_file_);
- if (from._has_bits_[0 / 32] & 3u) {
- if (from.has_parameter()) {
+ cached_has_bits = from._has_bits_[0];
+ if (cached_has_bits & 3u) {
+ if (cached_has_bits & 0x00000001u) {
set_has_parameter();
parameter_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.parameter_);
}
- if (from.has_compiler_version()) {
+ if (cached_has_bits & 0x00000002u) {
mutable_compiler_version()->::google::protobuf::compiler::Version::MergeFrom(from.compiler_version());
}
}
@@ -1080,8 +1123,8 @@ void CodeGeneratorRequest::Swap(CodeGeneratorRequest* other) {
InternalSwap(other);
}
void CodeGeneratorRequest::InternalSwap(CodeGeneratorRequest* other) {
- file_to_generate_.UnsafeArenaSwap(&other->file_to_generate_);
- proto_file_.UnsafeArenaSwap(&other->proto_file_);
+ file_to_generate_.InternalSwap(&other->file_to_generate_);
+ proto_file_.InternalSwap(&other->proto_file_);
parameter_.Swap(&other->parameter_);
std::swap(compiler_version_, other->compiler_version_);
std::swap(_has_bits_[0], other->_has_bits_[0]);
@@ -1091,7 +1134,7 @@ void CodeGeneratorRequest::InternalSwap(CodeGeneratorRequest* other) {
::google::protobuf::Metadata CodeGeneratorRequest::GetMetadata() const {
protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::protobuf_AssignDescriptorsOnce();
- return protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::file_level_metadata[1];
+ return protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::file_level_metadata[kIndexInFileMessages];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
@@ -1123,6 +1166,7 @@ void CodeGeneratorRequest::set_file_to_generate(int index, ::std::string&& value
}
#endif
void CodeGeneratorRequest::set_file_to_generate(int index, const char* value) {
+ GOOGLE_DCHECK(value != NULL);
file_to_generate_.Mutable(index)->assign(value);
// @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)
}
@@ -1141,11 +1185,12 @@ void CodeGeneratorRequest::add_file_to_generate(const ::std::string& value) {
}
#if LANG_CXX11
void CodeGeneratorRequest::add_file_to_generate(::std::string&& value) {
- file_to_generate_.Add()->assign(std::move(value));
+ file_to_generate_.Add(std::move(value));
// @@protoc_insertion_point(field_add:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)
}
#endif
void CodeGeneratorRequest::add_file_to_generate(const char* value) {
+ GOOGLE_DCHECK(value != NULL);
file_to_generate_.Add()->assign(value);
// @@protoc_insertion_point(field_add_char:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)
}
@@ -1196,6 +1241,7 @@ void CodeGeneratorRequest::set_parameter(::std::string&& value) {
}
#endif
void CodeGeneratorRequest::set_parameter(const char* value) {
+ GOOGLE_DCHECK(value != NULL);
set_has_parameter();
parameter_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
// @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorRequest.parameter)
@@ -1365,7 +1411,7 @@ void CodeGeneratorResponse_File::SetCachedSize(int size) const {
}
const ::google::protobuf::Descriptor* CodeGeneratorResponse_File::descriptor() {
protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::protobuf_AssignDescriptorsOnce();
- return protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::file_level_metadata[2].descriptor;
+ return protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::file_level_metadata[kIndexInFileMessages].descriptor;
}
const CodeGeneratorResponse_File& CodeGeneratorResponse_File::default_instance() {
@@ -1484,8 +1530,12 @@ failure:
void CodeGeneratorResponse_File::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.protobuf.compiler.CodeGeneratorResponse.File)
+ ::google::protobuf::uint32 cached_has_bits = 0;
+ (void) cached_has_bits;
+
+ cached_has_bits = _has_bits_[0];
// optional string name = 1;
- if (has_name()) {
+ if (cached_has_bits & 0x00000001u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->name().data(), this->name().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
@@ -1495,7 +1545,7 @@ void CodeGeneratorResponse_File::SerializeWithCachedSizes(
}
// optional string insertion_point = 2;
- if (has_insertion_point()) {
+ if (cached_has_bits & 0x00000002u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->insertion_point().data(), this->insertion_point().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
@@ -1505,7 +1555,7 @@ void CodeGeneratorResponse_File::SerializeWithCachedSizes(
}
// optional string content = 15;
- if (has_content()) {
+ if (cached_has_bits & 0x00000004u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->content().data(), this->content().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
@@ -1523,10 +1573,13 @@ void CodeGeneratorResponse_File::SerializeWithCachedSizes(
::google::protobuf::uint8* CodeGeneratorResponse_File::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.compiler.CodeGeneratorResponse.File)
+ ::google::protobuf::uint32 cached_has_bits = 0;
+ (void) cached_has_bits;
+
+ cached_has_bits = _has_bits_[0];
// optional string name = 1;
- if (has_name()) {
+ if (cached_has_bits & 0x00000001u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->name().data(), this->name().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
@@ -1537,7 +1590,7 @@ void CodeGeneratorResponse_File::SerializeWithCachedSizes(
}
// optional string insertion_point = 2;
- if (has_insertion_point()) {
+ if (cached_has_bits & 0x00000002u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->insertion_point().data(), this->insertion_point().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
@@ -1548,7 +1601,7 @@ void CodeGeneratorResponse_File::SerializeWithCachedSizes(
}
// optional string content = 15;
- if (has_content()) {
+ if (cached_has_bits & 0x00000004u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->content().data(), this->content().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
@@ -1624,16 +1677,20 @@ void CodeGeneratorResponse_File::MergeFrom(const CodeGeneratorResponse_File& fro
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.CodeGeneratorResponse.File)
GOOGLE_DCHECK_NE(&from, this);
_internal_metadata_.MergeFrom(from._internal_metadata_);
- if (from._has_bits_[0 / 32] & 7u) {
- if (from.has_name()) {
+ ::google::protobuf::uint32 cached_has_bits = 0;
+ (void) cached_has_bits;
+
+ cached_has_bits = from._has_bits_[0];
+ if (cached_has_bits & 7u) {
+ if (cached_has_bits & 0x00000001u) {
set_has_name();
name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);
}
- if (from.has_insertion_point()) {
+ if (cached_has_bits & 0x00000002u) {
set_has_insertion_point();
insertion_point_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.insertion_point_);
}
- if (from.has_content()) {
+ if (cached_has_bits & 0x00000004u) {
set_has_content();
content_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.content_);
}
@@ -1673,7 +1730,7 @@ void CodeGeneratorResponse_File::InternalSwap(CodeGeneratorResponse_File* other)
::google::protobuf::Metadata CodeGeneratorResponse_File::GetMetadata() const {
protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::protobuf_AssignDescriptorsOnce();
- return protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::file_level_metadata[2];
+ return protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::file_level_metadata[kIndexInFileMessages];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
@@ -1711,6 +1768,7 @@ void CodeGeneratorResponse_File::set_name(::std::string&& value) {
}
#endif
void CodeGeneratorResponse_File::set_name(const char* value) {
+ GOOGLE_DCHECK(value != NULL);
set_has_name();
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
// @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorResponse.File.name)
@@ -1773,6 +1831,7 @@ void CodeGeneratorResponse_File::set_insertion_point(::std::string&& value) {
}
#endif
void CodeGeneratorResponse_File::set_insertion_point(const char* value) {
+ GOOGLE_DCHECK(value != NULL);
set_has_insertion_point();
insertion_point_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
// @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)
@@ -1835,6 +1894,7 @@ void CodeGeneratorResponse_File::set_content(::std::string&& value) {
}
#endif
void CodeGeneratorResponse_File::set_content(const char* value) {
+ GOOGLE_DCHECK(value != NULL);
set_has_content();
content_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
// @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorResponse.File.content)
@@ -1917,7 +1977,7 @@ void CodeGeneratorResponse::SetCachedSize(int size) const {
}
const ::google::protobuf::Descriptor* CodeGeneratorResponse::descriptor() {
protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::protobuf_AssignDescriptorsOnce();
- return protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::file_level_metadata[3].descriptor;
+ return protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::file_level_metadata[kIndexInFileMessages].descriptor;
}
const CodeGeneratorResponse& CodeGeneratorResponse::default_instance() {
@@ -1974,13 +2034,11 @@ bool CodeGeneratorResponse::MergePartialFromCodedStream(
case 15: {
if (static_cast< ::google::protobuf::uint8>(tag) ==
static_cast< ::google::protobuf::uint8>(122u)) {
- DO_(input->IncrementRecursionDepth());
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
input, add_file()));
} else {
goto handle_unusual;
}
- input->UnsafeDecrementRecursionDepth();
break;
}
@@ -2009,8 +2067,12 @@ failure:
void CodeGeneratorResponse::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.protobuf.compiler.CodeGeneratorResponse)
+ ::google::protobuf::uint32 cached_has_bits = 0;
+ (void) cached_has_bits;
+
+ cached_has_bits = _has_bits_[0];
// optional string error = 1;
- if (has_error()) {
+ if (cached_has_bits & 0x00000001u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->error().data(), this->error().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
@@ -2034,10 +2096,13 @@ void CodeGeneratorResponse::SerializeWithCachedSizes(
::google::protobuf::uint8* CodeGeneratorResponse::InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.compiler.CodeGeneratorResponse)
+ ::google::protobuf::uint32 cached_has_bits = 0;
+ (void) cached_has_bits;
+
+ cached_has_bits = _has_bits_[0];
// optional string error = 1;
- if (has_error()) {
+ if (cached_has_bits & 0x00000001u) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->error().data(), this->error().length(),
::google::protobuf::internal::WireFormat::SERIALIZE,
@@ -2051,7 +2116,7 @@ void CodeGeneratorResponse::SerializeWithCachedSizes(
for (unsigned int i = 0, n = this->file_size(); i < n; i++) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageNoVirtualToArray(
- 15, this->file(i), false, target);
+ 15, this->file(i), deterministic, target);
}
if (_internal_metadata_.have_unknown_fields()) {
@@ -2115,6 +2180,9 @@ void CodeGeneratorResponse::MergeFrom(const CodeGeneratorResponse& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.CodeGeneratorResponse)
GOOGLE_DCHECK_NE(&from, this);
_internal_metadata_.MergeFrom(from._internal_metadata_);
+ ::google::protobuf::uint32 cached_has_bits = 0;
+ (void) cached_has_bits;
+
file_.MergeFrom(from.file_);
if (from.has_error()) {
set_has_error();
@@ -2145,7 +2213,7 @@ void CodeGeneratorResponse::Swap(CodeGeneratorResponse* other) {
InternalSwap(other);
}
void CodeGeneratorResponse::InternalSwap(CodeGeneratorResponse* other) {
- file_.UnsafeArenaSwap(&other->file_);
+ file_.InternalSwap(&other->file_);
error_.Swap(&other->error_);
std::swap(_has_bits_[0], other->_has_bits_[0]);
_internal_metadata_.Swap(&other->_internal_metadata_);
@@ -2154,7 +2222,7 @@ void CodeGeneratorResponse::InternalSwap(CodeGeneratorResponse* other) {
::google::protobuf::Metadata CodeGeneratorResponse::GetMetadata() const {
protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::protobuf_AssignDescriptorsOnce();
- return protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::file_level_metadata[3];
+ return protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::file_level_metadata[kIndexInFileMessages];
}
#if PROTOBUF_INLINE_NOT_IN_HEADERS
@@ -2192,6 +2260,7 @@ void CodeGeneratorResponse::set_error(::std::string&& value) {
}
#endif
void CodeGeneratorResponse::set_error(const char* value) {
+ GOOGLE_DCHECK(value != NULL);
set_has_error();
error_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
// @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorResponse.error)
diff --git a/src/google/protobuf/compiler/plugin.pb.h b/src/google/protobuf/compiler/plugin.pb.h
index ff8b949f..c9abc256 100644
--- a/src/google/protobuf/compiler/plugin.pb.h
+++ b/src/google/protobuf/compiler/plugin.pb.h
@@ -22,6 +22,7 @@
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/arena.h>
#include <google/protobuf/arenastring.h>
+#include <google/protobuf/generated_message_table_driven.h>
#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/metadata.h>
#include <google/protobuf/message.h>
@@ -137,6 +138,9 @@ namespace compiler {
namespace protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto {
// Internal implementation detail -- do not call these.
struct LIBPROTOC_EXPORT TableStruct {
+ static const ::google::protobuf::internal::ParseTableField entries[];
+ static const ::google::protobuf::internal::AuxillaryParseTableField aux[];
+ static const ::google::protobuf::internal::ParseTable schema[];
static const ::google::protobuf::uint32 offsets[];
static void InitDefaultsImpl();
static void Shutdown();
@@ -174,6 +178,8 @@ class LIBPROTOC_EXPORT Version : public ::google::protobuf::Message /* @@protoc_
return reinterpret_cast<const Version*>(
&_Version_default_instance_);
}
+ static PROTOBUF_CONSTEXPR int const kIndexInFileMessages =
+ 0;
void Swap(Version* other);
@@ -196,11 +202,6 @@ class LIBPROTOC_EXPORT Version : public ::google::protobuf::Message /* @@protoc_
::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
- const PROTOBUF_FINAL {
- return InternalSerializeWithCachedSizesToArray(
- ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
- }
int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
@@ -307,6 +308,8 @@ class LIBPROTOC_EXPORT CodeGeneratorRequest : public ::google::protobuf::Message
return reinterpret_cast<const CodeGeneratorRequest*>(
&_CodeGeneratorRequest_default_instance_);
}
+ static PROTOBUF_CONSTEXPR int const kIndexInFileMessages =
+ 1;
void Swap(CodeGeneratorRequest* other);
@@ -329,11 +332,6 @@ class LIBPROTOC_EXPORT CodeGeneratorRequest : public ::google::protobuf::Message
::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
- const PROTOBUF_FINAL {
- return InternalSerializeWithCachedSizesToArray(
- ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
- }
int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
@@ -458,6 +456,8 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse_File : public ::google::protobuf::M
return reinterpret_cast<const CodeGeneratorResponse_File*>(
&_CodeGeneratorResponse_File_default_instance_);
}
+ static PROTOBUF_CONSTEXPR int const kIndexInFileMessages =
+ 2;
void Swap(CodeGeneratorResponse_File* other);
@@ -480,11 +480,6 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse_File : public ::google::protobuf::M
::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
- const PROTOBUF_FINAL {
- return InternalSerializeWithCachedSizesToArray(
- ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
- }
int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
@@ -597,6 +592,8 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse : public ::google::protobuf::Messag
return reinterpret_cast<const CodeGeneratorResponse*>(
&_CodeGeneratorResponse_default_instance_);
}
+ static PROTOBUF_CONSTEXPR int const kIndexInFileMessages =
+ 3;
void Swap(CodeGeneratorResponse* other);
@@ -619,11 +616,6 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse : public ::google::protobuf::Messag
::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output)
- const PROTOBUF_FINAL {
- return InternalSerializeWithCachedSizesToArray(
- ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output);
- }
int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
@@ -798,6 +790,7 @@ inline void Version::set_suffix(::std::string&& value) {
}
#endif
inline void Version::set_suffix(const char* value) {
+ GOOGLE_DCHECK(value != NULL);
set_has_suffix();
suffix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
// @@protoc_insertion_point(field_set_char:google.protobuf.compiler.Version.suffix)
@@ -858,6 +851,7 @@ inline void CodeGeneratorRequest::set_file_to_generate(int index, ::std::string&
}
#endif
inline void CodeGeneratorRequest::set_file_to_generate(int index, const char* value) {
+ GOOGLE_DCHECK(value != NULL);
file_to_generate_.Mutable(index)->assign(value);
// @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)
}
@@ -876,11 +870,12 @@ inline void CodeGeneratorRequest::add_file_to_generate(const ::std::string& valu
}
#if LANG_CXX11
inline void CodeGeneratorRequest::add_file_to_generate(::std::string&& value) {
- file_to_generate_.Add()->assign(std::move(value));
+ file_to_generate_.Add(std::move(value));
// @@protoc_insertion_point(field_add:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)
}
#endif
inline void CodeGeneratorRequest::add_file_to_generate(const char* value) {
+ GOOGLE_DCHECK(value != NULL);
file_to_generate_.Add()->assign(value);
// @@protoc_insertion_point(field_add_char:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)
}
@@ -931,6 +926,7 @@ inline void CodeGeneratorRequest::set_parameter(::std::string&& value) {
}
#endif
inline void CodeGeneratorRequest::set_parameter(const char* value) {
+ GOOGLE_DCHECK(value != NULL);
set_has_parameter();
parameter_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
// @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorRequest.parameter)
@@ -1072,6 +1068,7 @@ inline void CodeGeneratorResponse_File::set_name(::std::string&& value) {
}
#endif
inline void CodeGeneratorResponse_File::set_name(const char* value) {
+ GOOGLE_DCHECK(value != NULL);
set_has_name();
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
// @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorResponse.File.name)
@@ -1134,6 +1131,7 @@ inline void CodeGeneratorResponse_File::set_insertion_point(::std::string&& valu
}
#endif
inline void CodeGeneratorResponse_File::set_insertion_point(const char* value) {
+ GOOGLE_DCHECK(value != NULL);
set_has_insertion_point();
insertion_point_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
// @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)
@@ -1196,6 +1194,7 @@ inline void CodeGeneratorResponse_File::set_content(::std::string&& value) {
}
#endif
inline void CodeGeneratorResponse_File::set_content(const char* value) {
+ GOOGLE_DCHECK(value != NULL);
set_has_content();
content_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
// @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorResponse.File.content)
@@ -1262,6 +1261,7 @@ inline void CodeGeneratorResponse::set_error(::std::string&& value) {
}
#endif
inline void CodeGeneratorResponse::set_error(const char* value) {
+ GOOGLE_DCHECK(value != NULL);
set_has_error();
error_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
// @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorResponse.error)
diff --git a/src/google/protobuf/compiler/plugin.proto b/src/google/protobuf/compiler/plugin.proto
index bf91d76e..f04dc73c 100644
--- a/src/google/protobuf/compiler/plugin.proto
+++ b/src/google/protobuf/compiler/plugin.proto
@@ -84,6 +84,9 @@ message CodeGeneratorRequest {
// the entire set into memory at once. However, as of this writing, this
// is not similarly optimized on protoc's end -- it will store all fields in
// memory at once before sending them to the plugin.
+ //
+ // Type names of fields and extensions in the FileDescriptorProto are always
+ // fully qualified.
repeated FileDescriptorProto proto_file = 15;
// The version number of protocol compiler.
diff --git a/src/google/protobuf/compiler/profile.pb.cc b/src/google/protobuf/compiler/profile.pb.cc
new file mode 100644
index 00000000..c185e4f9
--- /dev/null
+++ b/src/google/protobuf/compiler/profile.pb.cc
@@ -0,0 +1,1442 @@
+// Generated by the protocol buffer compiler. DO NOT EDIT!
+// source: google/protobuf/compiler/profile.proto
+
+#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION
+#include <google/protobuf/compiler/profile.pb.h>
+
+#include <algorithm>
+
+#include <google/protobuf/stubs/common.h>
+#include <google/protobuf/stubs/port.h>
+#include <google/protobuf/stubs/once.h>
+#include <google/protobuf/io/coded_stream.h>
+#include <google/protobuf/wire_format_lite_inl.h>
+#include <google/protobuf/descriptor.h>
+#include <google/protobuf/generated_message_reflection.h>
+#include <google/protobuf/reflection_ops.h>
+#include <google/protobuf/wire_format.h>
+// @@protoc_insertion_point(includes)
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+class FieldAccessInfoDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<FieldAccessInfo> {
+} _FieldAccessInfo_default_instance_;
+class MessageAccessInfoDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<MessageAccessInfo> {
+} _MessageAccessInfo_default_instance_;
+class AccessInfoDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<AccessInfo> {
+} _AccessInfo_default_instance_;
+
+namespace protobuf_google_2fprotobuf_2fcompiler_2fprofile_2eproto {
+
+
+namespace {
+
+::google::protobuf::Metadata file_level_metadata[3];
+
+} // namespace
+
+PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::ParseTableField
+ const TableStruct::entries[] = {
+ {0, 0, 0, ::google::protobuf::internal::kInvalidMask, 0, 0},
+};
+
+PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::AuxillaryParseTableField
+ const TableStruct::aux[] = {
+ ::google::protobuf::internal::AuxillaryParseTableField(),
+};
+PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::ParseTable const
+ TableStruct::schema[] = {
+ { NULL, NULL, 0, -1, -1, false },
+ { NULL, NULL, 0, -1, -1, false },
+ { NULL, NULL, 0, -1, -1, false },
+};
+
+const ::google::protobuf::uint32 TableStruct::offsets[] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldAccessInfo, _has_bits_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldAccessInfo, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ ~0u, // no _weak_field_map_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldAccessInfo, name_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldAccessInfo, getters_count_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldAccessInfo, setters_count_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldAccessInfo, configs_count_),
+ 0,
+ 1,
+ 2,
+ 3,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageAccessInfo, _has_bits_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageAccessInfo, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ ~0u, // no _weak_field_map_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageAccessInfo, name_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageAccessInfo, count_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageAccessInfo, field_),
+ 0,
+ 1,
+ ~0u,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(AccessInfo, _has_bits_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(AccessInfo, _internal_metadata_),
+ ~0u, // no _extensions_
+ ~0u, // no _oneof_case_
+ ~0u, // no _weak_field_map_
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(AccessInfo, message_),
+ ~0u,
+};
+
+static const ::google::protobuf::internal::MigrationSchema schemas[] = {
+ { 0, 9, sizeof(FieldAccessInfo)},
+ { 13, 21, sizeof(MessageAccessInfo)},
+ { 24, 30, sizeof(AccessInfo)},
+};
+
+static ::google::protobuf::Message const * const file_default_instances[] = {
+ reinterpret_cast<const ::google::protobuf::Message*>(&_FieldAccessInfo_default_instance_),
+ reinterpret_cast<const ::google::protobuf::Message*>(&_MessageAccessInfo_default_instance_),
+ reinterpret_cast<const ::google::protobuf::Message*>(&_AccessInfo_default_instance_),
+};
+
+namespace {
+
+void protobuf_AssignDescriptors() {
+ AddDescriptors();
+ ::google::protobuf::MessageFactory* factory = NULL;
+ AssignDescriptors(
+ "google/protobuf/compiler/profile.proto", schemas, file_default_instances, TableStruct::offsets, factory,
+ file_level_metadata, NULL, NULL);
+}
+
+void protobuf_AssignDescriptorsOnce() {
+ static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
+ ::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors);
+}
+
+void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD;
+void protobuf_RegisterTypes(const ::std::string&) {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 3);
+}
+
+} // namespace
+
+void TableStruct::Shutdown() {
+ _FieldAccessInfo_default_instance_.Shutdown();
+ delete file_level_metadata[0].reflection;
+ _MessageAccessInfo_default_instance_.Shutdown();
+ delete file_level_metadata[1].reflection;
+ _AccessInfo_default_instance_.Shutdown();
+ delete file_level_metadata[2].reflection;
+}
+
+void TableStruct::InitDefaultsImpl() {
+ GOOGLE_PROTOBUF_VERIFY_VERSION;
+
+ ::google::protobuf::internal::InitProtobufDefaults();
+ _FieldAccessInfo_default_instance_.DefaultConstruct();
+ _MessageAccessInfo_default_instance_.DefaultConstruct();
+ _AccessInfo_default_instance_.DefaultConstruct();
+}
+
+void InitDefaults() {
+ static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
+ ::google::protobuf::GoogleOnceInit(&once, &TableStruct::InitDefaultsImpl);
+}
+void AddDescriptorsImpl() {
+ InitDefaults();
+ static const char descriptor[] = {
+ "\n&google/protobuf/compiler/profile.proto"
+ "\022\030google.protobuf.compiler\"d\n\017FieldAcces"
+ "sInfo\022\014\n\004name\030\001 \001(\t\022\025\n\rgetters_count\030\002 \001"
+ "(\004\022\025\n\rsetters_count\030\003 \001(\004\022\025\n\rconfigs_cou"
+ "nt\030\004 \001(\004\"j\n\021MessageAccessInfo\022\014\n\004name\030\001 "
+ "\001(\t\022\r\n\005count\030\002 \001(\004\0228\n\005field\030\003 \003(\0132).goog"
+ "le.protobuf.compiler.FieldAccessInfo\"J\n\n"
+ "AccessInfo\022<\n\007message\030\001 \003(\0132+.google.pro"
+ "tobuf.compiler.MessageAccessInfo"
+ };
+ ::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
+ descriptor, 352);
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
+ "google/protobuf/compiler/profile.proto", &protobuf_RegisterTypes);
+ ::google::protobuf::internal::OnShutdown(&TableStruct::Shutdown);
+}
+
+void AddDescriptors() {
+ static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
+ ::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl);
+}
+// Force AddDescriptors() to be called at static initialization time.
+struct StaticDescriptorInitializer {
+ StaticDescriptorInitializer() {
+ AddDescriptors();
+ }
+} static_descriptor_initializer;
+
+} // namespace protobuf_google_2fprotobuf_2fcompiler_2fprofile_2eproto
+
+
+// ===================================================================
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int FieldAccessInfo::kNameFieldNumber;
+const int FieldAccessInfo::kGettersCountFieldNumber;
+const int FieldAccessInfo::kSettersCountFieldNumber;
+const int FieldAccessInfo::kConfigsCountFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+FieldAccessInfo::FieldAccessInfo()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
+ protobuf_google_2fprotobuf_2fcompiler_2fprofile_2eproto::InitDefaults();
+ }
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:google.protobuf.compiler.FieldAccessInfo)
+}
+FieldAccessInfo::FieldAccessInfo(const FieldAccessInfo& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL),
+ _has_bits_(from._has_bits_),
+ _cached_size_(0) {
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ if (from.has_name()) {
+ name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);
+ }
+ ::memcpy(&getters_count_, &from.getters_count_,
+ reinterpret_cast<char*>(&configs_count_) -
+ reinterpret_cast<char*>(&getters_count_) + sizeof(configs_count_));
+ // @@protoc_insertion_point(copy_constructor:google.protobuf.compiler.FieldAccessInfo)
+}
+
+void FieldAccessInfo::SharedCtor() {
+ _cached_size_ = 0;
+ name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ ::memset(&getters_count_, 0, reinterpret_cast<char*>(&configs_count_) -
+ reinterpret_cast<char*>(&getters_count_) + sizeof(configs_count_));
+}
+
+FieldAccessInfo::~FieldAccessInfo() {
+ // @@protoc_insertion_point(destructor:google.protobuf.compiler.FieldAccessInfo)
+ SharedDtor();
+}
+
+void FieldAccessInfo::SharedDtor() {
+ name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+
+void FieldAccessInfo::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* FieldAccessInfo::descriptor() {
+ protobuf_google_2fprotobuf_2fcompiler_2fprofile_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fcompiler_2fprofile_2eproto::file_level_metadata[kIndexInFileMessages].descriptor;
+}
+
+const FieldAccessInfo& FieldAccessInfo::default_instance() {
+ protobuf_google_2fprotobuf_2fcompiler_2fprofile_2eproto::InitDefaults();
+ return *internal_default_instance();
+}
+
+FieldAccessInfo* FieldAccessInfo::New(::google::protobuf::Arena* arena) const {
+ FieldAccessInfo* n = new FieldAccessInfo;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void FieldAccessInfo::Clear() {
+// @@protoc_insertion_point(message_clear_start:google.protobuf.compiler.FieldAccessInfo)
+ if (has_name()) {
+ GOOGLE_DCHECK(!name_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
+ (*name_.UnsafeRawStringPointer())->clear();
+ }
+ if (_has_bits_[0 / 32] & 14u) {
+ ::memset(&getters_count_, 0, reinterpret_cast<char*>(&configs_count_) -
+ reinterpret_cast<char*>(&getters_count_) + sizeof(configs_count_));
+ }
+ _has_bits_.Clear();
+ _internal_metadata_.Clear();
+}
+
+bool FieldAccessInfo::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:google.protobuf.compiler.FieldAccessInfo)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // optional string name = 1;
+ case 1: {
+ if (static_cast< ::google::protobuf::uint8>(tag) ==
+ static_cast< ::google::protobuf::uint8>(10u)) {
+ DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+ input, this->mutable_name()));
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->name().data(), this->name().length(),
+ ::google::protobuf::internal::WireFormat::PARSE,
+ "google.protobuf.compiler.FieldAccessInfo.name");
+ } else {
+ goto handle_unusual;
+ }
+ break;
+ }
+
+ // optional uint64 getters_count = 2;
+ case 2: {
+ if (static_cast< ::google::protobuf::uint8>(tag) ==
+ static_cast< ::google::protobuf::uint8>(16u)) {
+ set_has_getters_count();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::uint64, ::google::protobuf::internal::WireFormatLite::TYPE_UINT64>(
+ input, &getters_count_)));
+ } else {
+ goto handle_unusual;
+ }
+ break;
+ }
+
+ // optional uint64 setters_count = 3;
+ case 3: {
+ if (static_cast< ::google::protobuf::uint8>(tag) ==
+ static_cast< ::google::protobuf::uint8>(24u)) {
+ set_has_setters_count();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::uint64, ::google::protobuf::internal::WireFormatLite::TYPE_UINT64>(
+ input, &setters_count_)));
+ } else {
+ goto handle_unusual;
+ }
+ break;
+ }
+
+ // optional uint64 configs_count = 4;
+ case 4: {
+ if (static_cast< ::google::protobuf::uint8>(tag) ==
+ static_cast< ::google::protobuf::uint8>(32u)) {
+ set_has_configs_count();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::uint64, ::google::protobuf::internal::WireFormatLite::TYPE_UINT64>(
+ input, &configs_count_)));
+ } else {
+ goto handle_unusual;
+ }
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:google.protobuf.compiler.FieldAccessInfo)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:google.protobuf.compiler.FieldAccessInfo)
+ return false;
+#undef DO_
+}
+
+void FieldAccessInfo::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:google.protobuf.compiler.FieldAccessInfo)
+ ::google::protobuf::uint32 cached_has_bits = 0;
+ (void) cached_has_bits;
+
+ cached_has_bits = _has_bits_[0];
+ // optional string name = 1;
+ if (cached_has_bits & 0x00000001u) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->name().data(), this->name().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "google.protobuf.compiler.FieldAccessInfo.name");
+ ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
+ 1, this->name(), output);
+ }
+
+ // optional uint64 getters_count = 2;
+ if (cached_has_bits & 0x00000002u) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt64(2, this->getters_count(), output);
+ }
+
+ // optional uint64 setters_count = 3;
+ if (cached_has_bits & 0x00000004u) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt64(3, this->setters_count(), output);
+ }
+
+ // optional uint64 configs_count = 4;
+ if (cached_has_bits & 0x00000008u) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt64(4, this->configs_count(), output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:google.protobuf.compiler.FieldAccessInfo)
+}
+
+::google::protobuf::uint8* FieldAccessInfo::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.compiler.FieldAccessInfo)
+ ::google::protobuf::uint32 cached_has_bits = 0;
+ (void) cached_has_bits;
+
+ cached_has_bits = _has_bits_[0];
+ // optional string name = 1;
+ if (cached_has_bits & 0x00000001u) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->name().data(), this->name().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "google.protobuf.compiler.FieldAccessInfo.name");
+ target =
+ ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
+ 1, this->name(), target);
+ }
+
+ // optional uint64 getters_count = 2;
+ if (cached_has_bits & 0x00000002u) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteUInt64ToArray(2, this->getters_count(), target);
+ }
+
+ // optional uint64 setters_count = 3;
+ if (cached_has_bits & 0x00000004u) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteUInt64ToArray(3, this->setters_count(), target);
+ }
+
+ // optional uint64 configs_count = 4;
+ if (cached_has_bits & 0x00000008u) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteUInt64ToArray(4, this->configs_count(), target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.compiler.FieldAccessInfo)
+ return target;
+}
+
+size_t FieldAccessInfo::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:google.protobuf.compiler.FieldAccessInfo)
+ size_t total_size = 0;
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ if (_has_bits_[0 / 32] & 15u) {
+ // optional string name = 1;
+ if (has_name()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->name());
+ }
+
+ // optional uint64 getters_count = 2;
+ if (has_getters_count()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::UInt64Size(
+ this->getters_count());
+ }
+
+ // optional uint64 setters_count = 3;
+ if (has_setters_count()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::UInt64Size(
+ this->setters_count());
+ }
+
+ // optional uint64 configs_count = 4;
+ if (has_configs_count()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::UInt64Size(
+ this->configs_count());
+ }
+
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void FieldAccessInfo::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.compiler.FieldAccessInfo)
+ GOOGLE_DCHECK_NE(&from, this);
+ const FieldAccessInfo* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const FieldAccessInfo>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.compiler.FieldAccessInfo)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.compiler.FieldAccessInfo)
+ MergeFrom(*source);
+ }
+}
+
+void FieldAccessInfo::MergeFrom(const FieldAccessInfo& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.FieldAccessInfo)
+ GOOGLE_DCHECK_NE(&from, this);
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ ::google::protobuf::uint32 cached_has_bits = 0;
+ (void) cached_has_bits;
+
+ cached_has_bits = from._has_bits_[0];
+ if (cached_has_bits & 15u) {
+ if (cached_has_bits & 0x00000001u) {
+ set_has_name();
+ name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);
+ }
+ if (cached_has_bits & 0x00000002u) {
+ getters_count_ = from.getters_count_;
+ }
+ if (cached_has_bits & 0x00000004u) {
+ setters_count_ = from.setters_count_;
+ }
+ if (cached_has_bits & 0x00000008u) {
+ configs_count_ = from.configs_count_;
+ }
+ _has_bits_[0] |= cached_has_bits;
+ }
+}
+
+void FieldAccessInfo::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.compiler.FieldAccessInfo)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void FieldAccessInfo::CopyFrom(const FieldAccessInfo& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.compiler.FieldAccessInfo)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+bool FieldAccessInfo::IsInitialized() const {
+ return true;
+}
+
+void FieldAccessInfo::Swap(FieldAccessInfo* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void FieldAccessInfo::InternalSwap(FieldAccessInfo* other) {
+ name_.Swap(&other->name_);
+ std::swap(getters_count_, other->getters_count_);
+ std::swap(setters_count_, other->setters_count_);
+ std::swap(configs_count_, other->configs_count_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata FieldAccessInfo::GetMetadata() const {
+ protobuf_google_2fprotobuf_2fcompiler_2fprofile_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fcompiler_2fprofile_2eproto::file_level_metadata[kIndexInFileMessages];
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// FieldAccessInfo
+
+// optional string name = 1;
+bool FieldAccessInfo::has_name() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void FieldAccessInfo::set_has_name() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void FieldAccessInfo::clear_has_name() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void FieldAccessInfo::clear_name() {
+ name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_name();
+}
+const ::std::string& FieldAccessInfo::name() const {
+ // @@protoc_insertion_point(field_get:google.protobuf.compiler.FieldAccessInfo.name)
+ return name_.GetNoArena();
+}
+void FieldAccessInfo::set_name(const ::std::string& value) {
+ set_has_name();
+ name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:google.protobuf.compiler.FieldAccessInfo.name)
+}
+#if LANG_CXX11
+void FieldAccessInfo::set_name(::std::string&& value) {
+ set_has_name();
+ name_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.FieldAccessInfo.name)
+}
+#endif
+void FieldAccessInfo::set_name(const char* value) {
+ GOOGLE_DCHECK(value != NULL);
+ set_has_name();
+ name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.FieldAccessInfo.name)
+}
+void FieldAccessInfo::set_name(const char* value, size_t size) {
+ set_has_name();
+ name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.FieldAccessInfo.name)
+}
+::std::string* FieldAccessInfo::mutable_name() {
+ set_has_name();
+ // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.FieldAccessInfo.name)
+ return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+::std::string* FieldAccessInfo::release_name() {
+ // @@protoc_insertion_point(field_release:google.protobuf.compiler.FieldAccessInfo.name)
+ clear_has_name();
+ return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void FieldAccessInfo::set_allocated_name(::std::string* name) {
+ if (name != NULL) {
+ set_has_name();
+ } else {
+ clear_has_name();
+ }
+ name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);
+ // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.FieldAccessInfo.name)
+}
+
+// optional uint64 getters_count = 2;
+bool FieldAccessInfo::has_getters_count() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+void FieldAccessInfo::set_has_getters_count() {
+ _has_bits_[0] |= 0x00000002u;
+}
+void FieldAccessInfo::clear_has_getters_count() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+void FieldAccessInfo::clear_getters_count() {
+ getters_count_ = GOOGLE_ULONGLONG(0);
+ clear_has_getters_count();
+}
+::google::protobuf::uint64 FieldAccessInfo::getters_count() const {
+ // @@protoc_insertion_point(field_get:google.protobuf.compiler.FieldAccessInfo.getters_count)
+ return getters_count_;
+}
+void FieldAccessInfo::set_getters_count(::google::protobuf::uint64 value) {
+ set_has_getters_count();
+ getters_count_ = value;
+ // @@protoc_insertion_point(field_set:google.protobuf.compiler.FieldAccessInfo.getters_count)
+}
+
+// optional uint64 setters_count = 3;
+bool FieldAccessInfo::has_setters_count() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+void FieldAccessInfo::set_has_setters_count() {
+ _has_bits_[0] |= 0x00000004u;
+}
+void FieldAccessInfo::clear_has_setters_count() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+void FieldAccessInfo::clear_setters_count() {
+ setters_count_ = GOOGLE_ULONGLONG(0);
+ clear_has_setters_count();
+}
+::google::protobuf::uint64 FieldAccessInfo::setters_count() const {
+ // @@protoc_insertion_point(field_get:google.protobuf.compiler.FieldAccessInfo.setters_count)
+ return setters_count_;
+}
+void FieldAccessInfo::set_setters_count(::google::protobuf::uint64 value) {
+ set_has_setters_count();
+ setters_count_ = value;
+ // @@protoc_insertion_point(field_set:google.protobuf.compiler.FieldAccessInfo.setters_count)
+}
+
+// optional uint64 configs_count = 4;
+bool FieldAccessInfo::has_configs_count() const {
+ return (_has_bits_[0] & 0x00000008u) != 0;
+}
+void FieldAccessInfo::set_has_configs_count() {
+ _has_bits_[0] |= 0x00000008u;
+}
+void FieldAccessInfo::clear_has_configs_count() {
+ _has_bits_[0] &= ~0x00000008u;
+}
+void FieldAccessInfo::clear_configs_count() {
+ configs_count_ = GOOGLE_ULONGLONG(0);
+ clear_has_configs_count();
+}
+::google::protobuf::uint64 FieldAccessInfo::configs_count() const {
+ // @@protoc_insertion_point(field_get:google.protobuf.compiler.FieldAccessInfo.configs_count)
+ return configs_count_;
+}
+void FieldAccessInfo::set_configs_count(::google::protobuf::uint64 value) {
+ set_has_configs_count();
+ configs_count_ = value;
+ // @@protoc_insertion_point(field_set:google.protobuf.compiler.FieldAccessInfo.configs_count)
+}
+
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int MessageAccessInfo::kNameFieldNumber;
+const int MessageAccessInfo::kCountFieldNumber;
+const int MessageAccessInfo::kFieldFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+MessageAccessInfo::MessageAccessInfo()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
+ protobuf_google_2fprotobuf_2fcompiler_2fprofile_2eproto::InitDefaults();
+ }
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:google.protobuf.compiler.MessageAccessInfo)
+}
+MessageAccessInfo::MessageAccessInfo(const MessageAccessInfo& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL),
+ _has_bits_(from._has_bits_),
+ _cached_size_(0),
+ field_(from.field_) {
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ if (from.has_name()) {
+ name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);
+ }
+ count_ = from.count_;
+ // @@protoc_insertion_point(copy_constructor:google.protobuf.compiler.MessageAccessInfo)
+}
+
+void MessageAccessInfo::SharedCtor() {
+ _cached_size_ = 0;
+ name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ count_ = GOOGLE_ULONGLONG(0);
+}
+
+MessageAccessInfo::~MessageAccessInfo() {
+ // @@protoc_insertion_point(destructor:google.protobuf.compiler.MessageAccessInfo)
+ SharedDtor();
+}
+
+void MessageAccessInfo::SharedDtor() {
+ name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+
+void MessageAccessInfo::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* MessageAccessInfo::descriptor() {
+ protobuf_google_2fprotobuf_2fcompiler_2fprofile_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fcompiler_2fprofile_2eproto::file_level_metadata[kIndexInFileMessages].descriptor;
+}
+
+const MessageAccessInfo& MessageAccessInfo::default_instance() {
+ protobuf_google_2fprotobuf_2fcompiler_2fprofile_2eproto::InitDefaults();
+ return *internal_default_instance();
+}
+
+MessageAccessInfo* MessageAccessInfo::New(::google::protobuf::Arena* arena) const {
+ MessageAccessInfo* n = new MessageAccessInfo;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void MessageAccessInfo::Clear() {
+// @@protoc_insertion_point(message_clear_start:google.protobuf.compiler.MessageAccessInfo)
+ field_.Clear();
+ if (has_name()) {
+ GOOGLE_DCHECK(!name_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
+ (*name_.UnsafeRawStringPointer())->clear();
+ }
+ count_ = GOOGLE_ULONGLONG(0);
+ _has_bits_.Clear();
+ _internal_metadata_.Clear();
+}
+
+bool MessageAccessInfo::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:google.protobuf.compiler.MessageAccessInfo)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // optional string name = 1;
+ case 1: {
+ if (static_cast< ::google::protobuf::uint8>(tag) ==
+ static_cast< ::google::protobuf::uint8>(10u)) {
+ DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+ input, this->mutable_name()));
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->name().data(), this->name().length(),
+ ::google::protobuf::internal::WireFormat::PARSE,
+ "google.protobuf.compiler.MessageAccessInfo.name");
+ } else {
+ goto handle_unusual;
+ }
+ break;
+ }
+
+ // optional uint64 count = 2;
+ case 2: {
+ if (static_cast< ::google::protobuf::uint8>(tag) ==
+ static_cast< ::google::protobuf::uint8>(16u)) {
+ set_has_count();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::uint64, ::google::protobuf::internal::WireFormatLite::TYPE_UINT64>(
+ input, &count_)));
+ } else {
+ goto handle_unusual;
+ }
+ break;
+ }
+
+ // repeated .google.protobuf.compiler.FieldAccessInfo field = 3;
+ case 3: {
+ if (static_cast< ::google::protobuf::uint8>(tag) ==
+ static_cast< ::google::protobuf::uint8>(26u)) {
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, add_field()));
+ } else {
+ goto handle_unusual;
+ }
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:google.protobuf.compiler.MessageAccessInfo)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:google.protobuf.compiler.MessageAccessInfo)
+ return false;
+#undef DO_
+}
+
+void MessageAccessInfo::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:google.protobuf.compiler.MessageAccessInfo)
+ ::google::protobuf::uint32 cached_has_bits = 0;
+ (void) cached_has_bits;
+
+ cached_has_bits = _has_bits_[0];
+ // optional string name = 1;
+ if (cached_has_bits & 0x00000001u) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->name().data(), this->name().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "google.protobuf.compiler.MessageAccessInfo.name");
+ ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
+ 1, this->name(), output);
+ }
+
+ // optional uint64 count = 2;
+ if (cached_has_bits & 0x00000002u) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt64(2, this->count(), output);
+ }
+
+ // repeated .google.protobuf.compiler.FieldAccessInfo field = 3;
+ for (unsigned int i = 0, n = this->field_size(); i < n; i++) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 3, this->field(i), output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:google.protobuf.compiler.MessageAccessInfo)
+}
+
+::google::protobuf::uint8* MessageAccessInfo::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.compiler.MessageAccessInfo)
+ ::google::protobuf::uint32 cached_has_bits = 0;
+ (void) cached_has_bits;
+
+ cached_has_bits = _has_bits_[0];
+ // optional string name = 1;
+ if (cached_has_bits & 0x00000001u) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->name().data(), this->name().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "google.protobuf.compiler.MessageAccessInfo.name");
+ target =
+ ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
+ 1, this->name(), target);
+ }
+
+ // optional uint64 count = 2;
+ if (cached_has_bits & 0x00000002u) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteUInt64ToArray(2, this->count(), target);
+ }
+
+ // repeated .google.protobuf.compiler.FieldAccessInfo field = 3;
+ for (unsigned int i = 0, n = this->field_size(); i < n; i++) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 3, this->field(i), deterministic, target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.compiler.MessageAccessInfo)
+ return target;
+}
+
+size_t MessageAccessInfo::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:google.protobuf.compiler.MessageAccessInfo)
+ size_t total_size = 0;
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ // repeated .google.protobuf.compiler.FieldAccessInfo field = 3;
+ {
+ unsigned int count = this->field_size();
+ total_size += 1UL * count;
+ for (unsigned int i = 0; i < count; i++) {
+ total_size +=
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ this->field(i));
+ }
+ }
+
+ if (_has_bits_[0 / 32] & 3u) {
+ // optional string name = 1;
+ if (has_name()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->name());
+ }
+
+ // optional uint64 count = 2;
+ if (has_count()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::UInt64Size(
+ this->count());
+ }
+
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void MessageAccessInfo::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.compiler.MessageAccessInfo)
+ GOOGLE_DCHECK_NE(&from, this);
+ const MessageAccessInfo* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const MessageAccessInfo>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.compiler.MessageAccessInfo)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.compiler.MessageAccessInfo)
+ MergeFrom(*source);
+ }
+}
+
+void MessageAccessInfo::MergeFrom(const MessageAccessInfo& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.MessageAccessInfo)
+ GOOGLE_DCHECK_NE(&from, this);
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ ::google::protobuf::uint32 cached_has_bits = 0;
+ (void) cached_has_bits;
+
+ field_.MergeFrom(from.field_);
+ cached_has_bits = from._has_bits_[0];
+ if (cached_has_bits & 3u) {
+ if (cached_has_bits & 0x00000001u) {
+ set_has_name();
+ name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);
+ }
+ if (cached_has_bits & 0x00000002u) {
+ count_ = from.count_;
+ }
+ _has_bits_[0] |= cached_has_bits;
+ }
+}
+
+void MessageAccessInfo::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.compiler.MessageAccessInfo)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void MessageAccessInfo::CopyFrom(const MessageAccessInfo& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.compiler.MessageAccessInfo)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+bool MessageAccessInfo::IsInitialized() const {
+ return true;
+}
+
+void MessageAccessInfo::Swap(MessageAccessInfo* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void MessageAccessInfo::InternalSwap(MessageAccessInfo* other) {
+ field_.InternalSwap(&other->field_);
+ name_.Swap(&other->name_);
+ std::swap(count_, other->count_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata MessageAccessInfo::GetMetadata() const {
+ protobuf_google_2fprotobuf_2fcompiler_2fprofile_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fcompiler_2fprofile_2eproto::file_level_metadata[kIndexInFileMessages];
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// MessageAccessInfo
+
+// optional string name = 1;
+bool MessageAccessInfo::has_name() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void MessageAccessInfo::set_has_name() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void MessageAccessInfo::clear_has_name() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void MessageAccessInfo::clear_name() {
+ name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_name();
+}
+const ::std::string& MessageAccessInfo::name() const {
+ // @@protoc_insertion_point(field_get:google.protobuf.compiler.MessageAccessInfo.name)
+ return name_.GetNoArena();
+}
+void MessageAccessInfo::set_name(const ::std::string& value) {
+ set_has_name();
+ name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:google.protobuf.compiler.MessageAccessInfo.name)
+}
+#if LANG_CXX11
+void MessageAccessInfo::set_name(::std::string&& value) {
+ set_has_name();
+ name_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.MessageAccessInfo.name)
+}
+#endif
+void MessageAccessInfo::set_name(const char* value) {
+ GOOGLE_DCHECK(value != NULL);
+ set_has_name();
+ name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.MessageAccessInfo.name)
+}
+void MessageAccessInfo::set_name(const char* value, size_t size) {
+ set_has_name();
+ name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.MessageAccessInfo.name)
+}
+::std::string* MessageAccessInfo::mutable_name() {
+ set_has_name();
+ // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.MessageAccessInfo.name)
+ return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+::std::string* MessageAccessInfo::release_name() {
+ // @@protoc_insertion_point(field_release:google.protobuf.compiler.MessageAccessInfo.name)
+ clear_has_name();
+ return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void MessageAccessInfo::set_allocated_name(::std::string* name) {
+ if (name != NULL) {
+ set_has_name();
+ } else {
+ clear_has_name();
+ }
+ name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);
+ // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.MessageAccessInfo.name)
+}
+
+// optional uint64 count = 2;
+bool MessageAccessInfo::has_count() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+void MessageAccessInfo::set_has_count() {
+ _has_bits_[0] |= 0x00000002u;
+}
+void MessageAccessInfo::clear_has_count() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+void MessageAccessInfo::clear_count() {
+ count_ = GOOGLE_ULONGLONG(0);
+ clear_has_count();
+}
+::google::protobuf::uint64 MessageAccessInfo::count() const {
+ // @@protoc_insertion_point(field_get:google.protobuf.compiler.MessageAccessInfo.count)
+ return count_;
+}
+void MessageAccessInfo::set_count(::google::protobuf::uint64 value) {
+ set_has_count();
+ count_ = value;
+ // @@protoc_insertion_point(field_set:google.protobuf.compiler.MessageAccessInfo.count)
+}
+
+// repeated .google.protobuf.compiler.FieldAccessInfo field = 3;
+int MessageAccessInfo::field_size() const {
+ return field_.size();
+}
+void MessageAccessInfo::clear_field() {
+ field_.Clear();
+}
+const ::google::protobuf::compiler::FieldAccessInfo& MessageAccessInfo::field(int index) const {
+ // @@protoc_insertion_point(field_get:google.protobuf.compiler.MessageAccessInfo.field)
+ return field_.Get(index);
+}
+::google::protobuf::compiler::FieldAccessInfo* MessageAccessInfo::mutable_field(int index) {
+ // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.MessageAccessInfo.field)
+ return field_.Mutable(index);
+}
+::google::protobuf::compiler::FieldAccessInfo* MessageAccessInfo::add_field() {
+ // @@protoc_insertion_point(field_add:google.protobuf.compiler.MessageAccessInfo.field)
+ return field_.Add();
+}
+::google::protobuf::RepeatedPtrField< ::google::protobuf::compiler::FieldAccessInfo >*
+MessageAccessInfo::mutable_field() {
+ // @@protoc_insertion_point(field_mutable_list:google.protobuf.compiler.MessageAccessInfo.field)
+ return &field_;
+}
+const ::google::protobuf::RepeatedPtrField< ::google::protobuf::compiler::FieldAccessInfo >&
+MessageAccessInfo::field() const {
+ // @@protoc_insertion_point(field_list:google.protobuf.compiler.MessageAccessInfo.field)
+ return field_;
+}
+
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int AccessInfo::kMessageFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+AccessInfo::AccessInfo()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
+ protobuf_google_2fprotobuf_2fcompiler_2fprofile_2eproto::InitDefaults();
+ }
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:google.protobuf.compiler.AccessInfo)
+}
+AccessInfo::AccessInfo(const AccessInfo& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL),
+ _has_bits_(from._has_bits_),
+ _cached_size_(0),
+ message_(from.message_) {
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ // @@protoc_insertion_point(copy_constructor:google.protobuf.compiler.AccessInfo)
+}
+
+void AccessInfo::SharedCtor() {
+ _cached_size_ = 0;
+}
+
+AccessInfo::~AccessInfo() {
+ // @@protoc_insertion_point(destructor:google.protobuf.compiler.AccessInfo)
+ SharedDtor();
+}
+
+void AccessInfo::SharedDtor() {
+}
+
+void AccessInfo::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* AccessInfo::descriptor() {
+ protobuf_google_2fprotobuf_2fcompiler_2fprofile_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fcompiler_2fprofile_2eproto::file_level_metadata[kIndexInFileMessages].descriptor;
+}
+
+const AccessInfo& AccessInfo::default_instance() {
+ protobuf_google_2fprotobuf_2fcompiler_2fprofile_2eproto::InitDefaults();
+ return *internal_default_instance();
+}
+
+AccessInfo* AccessInfo::New(::google::protobuf::Arena* arena) const {
+ AccessInfo* n = new AccessInfo;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void AccessInfo::Clear() {
+// @@protoc_insertion_point(message_clear_start:google.protobuf.compiler.AccessInfo)
+ message_.Clear();
+ _has_bits_.Clear();
+ _internal_metadata_.Clear();
+}
+
+bool AccessInfo::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:google.protobuf.compiler.AccessInfo)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // repeated .google.protobuf.compiler.MessageAccessInfo message = 1;
+ case 1: {
+ if (static_cast< ::google::protobuf::uint8>(tag) ==
+ static_cast< ::google::protobuf::uint8>(10u)) {
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, add_message()));
+ } else {
+ goto handle_unusual;
+ }
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:google.protobuf.compiler.AccessInfo)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:google.protobuf.compiler.AccessInfo)
+ return false;
+#undef DO_
+}
+
+void AccessInfo::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:google.protobuf.compiler.AccessInfo)
+ ::google::protobuf::uint32 cached_has_bits = 0;
+ (void) cached_has_bits;
+
+ // repeated .google.protobuf.compiler.MessageAccessInfo message = 1;
+ for (unsigned int i = 0, n = this->message_size(); i < n; i++) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 1, this->message(i), output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:google.protobuf.compiler.AccessInfo)
+}
+
+::google::protobuf::uint8* AccessInfo::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.compiler.AccessInfo)
+ ::google::protobuf::uint32 cached_has_bits = 0;
+ (void) cached_has_bits;
+
+ // repeated .google.protobuf.compiler.MessageAccessInfo message = 1;
+ for (unsigned int i = 0, n = this->message_size(); i < n; i++) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 1, this->message(i), deterministic, target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.compiler.AccessInfo)
+ return target;
+}
+
+size_t AccessInfo::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:google.protobuf.compiler.AccessInfo)
+ size_t total_size = 0;
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ // repeated .google.protobuf.compiler.MessageAccessInfo message = 1;
+ {
+ unsigned int count = this->message_size();
+ total_size += 1UL * count;
+ for (unsigned int i = 0; i < count; i++) {
+ total_size +=
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ this->message(i));
+ }
+ }
+
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void AccessInfo::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.compiler.AccessInfo)
+ GOOGLE_DCHECK_NE(&from, this);
+ const AccessInfo* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const AccessInfo>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.compiler.AccessInfo)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.compiler.AccessInfo)
+ MergeFrom(*source);
+ }
+}
+
+void AccessInfo::MergeFrom(const AccessInfo& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.AccessInfo)
+ GOOGLE_DCHECK_NE(&from, this);
+ _internal_metadata_.MergeFrom(from._internal_metadata_);
+ ::google::protobuf::uint32 cached_has_bits = 0;
+ (void) cached_has_bits;
+
+ message_.MergeFrom(from.message_);
+}
+
+void AccessInfo::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.compiler.AccessInfo)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void AccessInfo::CopyFrom(const AccessInfo& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.compiler.AccessInfo)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+bool AccessInfo::IsInitialized() const {
+ return true;
+}
+
+void AccessInfo::Swap(AccessInfo* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void AccessInfo::InternalSwap(AccessInfo* other) {
+ message_.InternalSwap(&other->message_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata AccessInfo::GetMetadata() const {
+ protobuf_google_2fprotobuf_2fcompiler_2fprofile_2eproto::protobuf_AssignDescriptorsOnce();
+ return protobuf_google_2fprotobuf_2fcompiler_2fprofile_2eproto::file_level_metadata[kIndexInFileMessages];
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// AccessInfo
+
+// repeated .google.protobuf.compiler.MessageAccessInfo message = 1;
+int AccessInfo::message_size() const {
+ return message_.size();
+}
+void AccessInfo::clear_message() {
+ message_.Clear();
+}
+const ::google::protobuf::compiler::MessageAccessInfo& AccessInfo::message(int index) const {
+ // @@protoc_insertion_point(field_get:google.protobuf.compiler.AccessInfo.message)
+ return message_.Get(index);
+}
+::google::protobuf::compiler::MessageAccessInfo* AccessInfo::mutable_message(int index) {
+ // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.AccessInfo.message)
+ return message_.Mutable(index);
+}
+::google::protobuf::compiler::MessageAccessInfo* AccessInfo::add_message() {
+ // @@protoc_insertion_point(field_add:google.protobuf.compiler.AccessInfo.message)
+ return message_.Add();
+}
+::google::protobuf::RepeatedPtrField< ::google::protobuf::compiler::MessageAccessInfo >*
+AccessInfo::mutable_message() {
+ // @@protoc_insertion_point(field_mutable_list:google.protobuf.compiler.AccessInfo.message)
+ return &message_;
+}
+const ::google::protobuf::RepeatedPtrField< ::google::protobuf::compiler::MessageAccessInfo >&
+AccessInfo::message() const {
+ // @@protoc_insertion_point(field_list:google.protobuf.compiler.AccessInfo.message)
+ return message_;
+}
+
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// @@protoc_insertion_point(namespace_scope)
+
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
+
+// @@protoc_insertion_point(global_scope)
diff --git a/src/google/protobuf/compiler/profile.pb.h b/src/google/protobuf/compiler/profile.pb.h
new file mode 100644
index 00000000..c2ce5efc
--- /dev/null
+++ b/src/google/protobuf/compiler/profile.pb.h
@@ -0,0 +1,728 @@
+// Generated by the protocol buffer compiler. DO NOT EDIT!
+// source: google/protobuf/compiler/profile.proto
+
+#ifndef PROTOBUF_google_2fprotobuf_2fcompiler_2fprofile_2eproto__INCLUDED
+#define PROTOBUF_google_2fprotobuf_2fcompiler_2fprofile_2eproto__INCLUDED
+
+#include <string>
+
+#include <google/protobuf/stubs/common.h>
+
+#if GOOGLE_PROTOBUF_VERSION < 3002000
+#error This file was generated by a newer version of protoc which is
+#error incompatible with your Protocol Buffer headers. Please update
+#error your headers.
+#endif
+#if 3002000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
+#error This file was generated by an older version of protoc which is
+#error incompatible with your Protocol Buffer headers. Please
+#error regenerate this file with a newer version of protoc.
+#endif
+
+#include <google/protobuf/io/coded_stream.h>
+#include <google/protobuf/arena.h>
+#include <google/protobuf/arenastring.h>
+#include <google/protobuf/generated_message_table_driven.h>
+#include <google/protobuf/generated_message_util.h>
+#include <google/protobuf/metadata.h>
+#include <google/protobuf/message.h>
+#include <google/protobuf/repeated_field.h> // IWYU pragma: export
+#include <google/protobuf/extension_set.h> // IWYU pragma: export
+#include <google/protobuf/unknown_field_set.h>
+// @@protoc_insertion_point(includes)
+namespace google {
+namespace protobuf {
+namespace compiler {
+class AccessInfo;
+class AccessInfoDefaultTypeInternal;
+LIBPROTOC_EXPORT extern AccessInfoDefaultTypeInternal _AccessInfo_default_instance_;
+class FieldAccessInfo;
+class FieldAccessInfoDefaultTypeInternal;
+LIBPROTOC_EXPORT extern FieldAccessInfoDefaultTypeInternal _FieldAccessInfo_default_instance_;
+class MessageAccessInfo;
+class MessageAccessInfoDefaultTypeInternal;
+LIBPROTOC_EXPORT extern MessageAccessInfoDefaultTypeInternal _MessageAccessInfo_default_instance_;
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
+
+namespace google {
+namespace protobuf {
+namespace compiler {
+
+namespace protobuf_google_2fprotobuf_2fcompiler_2fprofile_2eproto {
+// Internal implementation detail -- do not call these.
+struct LIBPROTOC_EXPORT TableStruct {
+ static const ::google::protobuf::internal::ParseTableField entries[];
+ static const ::google::protobuf::internal::AuxillaryParseTableField aux[];
+ static const ::google::protobuf::internal::ParseTable schema[];
+ static const ::google::protobuf::uint32 offsets[];
+ static void InitDefaultsImpl();
+ static void Shutdown();
+};
+void LIBPROTOC_EXPORT AddDescriptors();
+void LIBPROTOC_EXPORT InitDefaults();
+} // namespace protobuf_google_2fprotobuf_2fcompiler_2fprofile_2eproto
+
+// ===================================================================
+
+class LIBPROTOC_EXPORT FieldAccessInfo : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.FieldAccessInfo) */ {
+ public:
+ FieldAccessInfo();
+ virtual ~FieldAccessInfo();
+
+ FieldAccessInfo(const FieldAccessInfo& from);
+
+ inline FieldAccessInfo& operator=(const FieldAccessInfo& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const FieldAccessInfo& default_instance();
+
+ static inline const FieldAccessInfo* internal_default_instance() {
+ return reinterpret_cast<const FieldAccessInfo*>(
+ &_FieldAccessInfo_default_instance_);
+ }
+ static PROTOBUF_CONSTEXPR int const kIndexInFileMessages =
+ 0;
+
+ void Swap(FieldAccessInfo* other);
+
+ // implements Message ----------------------------------------------
+
+ inline FieldAccessInfo* New() const PROTOBUF_FINAL { return New(NULL); }
+
+ FieldAccessInfo* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+ void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+ void CopyFrom(const FieldAccessInfo& from);
+ void MergeFrom(const FieldAccessInfo& from);
+ void Clear() PROTOBUF_FINAL;
+ bool IsInitialized() const PROTOBUF_FINAL;
+
+ size_t ByteSizeLong() const PROTOBUF_FINAL;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
+ int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const PROTOBUF_FINAL;
+ void InternalSwap(FieldAccessInfo* other);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return NULL;
+ }
+ inline void* MaybeArenaPtr() const {
+ return NULL;
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
+
+ // nested types ----------------------------------------------------
+
+ // accessors -------------------------------------------------------
+
+ // optional string name = 1;
+ bool has_name() const;
+ void clear_name();
+ static const int kNameFieldNumber = 1;
+ const ::std::string& name() const;
+ void set_name(const ::std::string& value);
+ #if LANG_CXX11
+ void set_name(::std::string&& value);
+ #endif
+ void set_name(const char* value);
+ void set_name(const char* value, size_t size);
+ ::std::string* mutable_name();
+ ::std::string* release_name();
+ void set_allocated_name(::std::string* name);
+
+ // optional uint64 getters_count = 2;
+ bool has_getters_count() const;
+ void clear_getters_count();
+ static const int kGettersCountFieldNumber = 2;
+ ::google::protobuf::uint64 getters_count() const;
+ void set_getters_count(::google::protobuf::uint64 value);
+
+ // optional uint64 setters_count = 3;
+ bool has_setters_count() const;
+ void clear_setters_count();
+ static const int kSettersCountFieldNumber = 3;
+ ::google::protobuf::uint64 setters_count() const;
+ void set_setters_count(::google::protobuf::uint64 value);
+
+ // optional uint64 configs_count = 4;
+ bool has_configs_count() const;
+ void clear_configs_count();
+ static const int kConfigsCountFieldNumber = 4;
+ ::google::protobuf::uint64 configs_count() const;
+ void set_configs_count(::google::protobuf::uint64 value);
+
+ // @@protoc_insertion_point(class_scope:google.protobuf.compiler.FieldAccessInfo)
+ private:
+ void set_has_name();
+ void clear_has_name();
+ void set_has_getters_count();
+ void clear_has_getters_count();
+ void set_has_setters_count();
+ void clear_has_setters_count();
+ void set_has_configs_count();
+ void clear_has_configs_count();
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ ::google::protobuf::internal::ArenaStringPtr name_;
+ ::google::protobuf::uint64 getters_count_;
+ ::google::protobuf::uint64 setters_count_;
+ ::google::protobuf::uint64 configs_count_;
+ friend struct protobuf_google_2fprotobuf_2fcompiler_2fprofile_2eproto::TableStruct;
+};
+// -------------------------------------------------------------------
+
+class LIBPROTOC_EXPORT MessageAccessInfo : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.MessageAccessInfo) */ {
+ public:
+ MessageAccessInfo();
+ virtual ~MessageAccessInfo();
+
+ MessageAccessInfo(const MessageAccessInfo& from);
+
+ inline MessageAccessInfo& operator=(const MessageAccessInfo& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const MessageAccessInfo& default_instance();
+
+ static inline const MessageAccessInfo* internal_default_instance() {
+ return reinterpret_cast<const MessageAccessInfo*>(
+ &_MessageAccessInfo_default_instance_);
+ }
+ static PROTOBUF_CONSTEXPR int const kIndexInFileMessages =
+ 1;
+
+ void Swap(MessageAccessInfo* other);
+
+ // implements Message ----------------------------------------------
+
+ inline MessageAccessInfo* New() const PROTOBUF_FINAL { return New(NULL); }
+
+ MessageAccessInfo* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+ void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+ void CopyFrom(const MessageAccessInfo& from);
+ void MergeFrom(const MessageAccessInfo& from);
+ void Clear() PROTOBUF_FINAL;
+ bool IsInitialized() const PROTOBUF_FINAL;
+
+ size_t ByteSizeLong() const PROTOBUF_FINAL;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
+ int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const PROTOBUF_FINAL;
+ void InternalSwap(MessageAccessInfo* other);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return NULL;
+ }
+ inline void* MaybeArenaPtr() const {
+ return NULL;
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
+
+ // nested types ----------------------------------------------------
+
+ // accessors -------------------------------------------------------
+
+ // repeated .google.protobuf.compiler.FieldAccessInfo field = 3;
+ int field_size() const;
+ void clear_field();
+ static const int kFieldFieldNumber = 3;
+ const ::google::protobuf::compiler::FieldAccessInfo& field(int index) const;
+ ::google::protobuf::compiler::FieldAccessInfo* mutable_field(int index);
+ ::google::protobuf::compiler::FieldAccessInfo* add_field();
+ ::google::protobuf::RepeatedPtrField< ::google::protobuf::compiler::FieldAccessInfo >*
+ mutable_field();
+ const ::google::protobuf::RepeatedPtrField< ::google::protobuf::compiler::FieldAccessInfo >&
+ field() const;
+
+ // optional string name = 1;
+ bool has_name() const;
+ void clear_name();
+ static const int kNameFieldNumber = 1;
+ const ::std::string& name() const;
+ void set_name(const ::std::string& value);
+ #if LANG_CXX11
+ void set_name(::std::string&& value);
+ #endif
+ void set_name(const char* value);
+ void set_name(const char* value, size_t size);
+ ::std::string* mutable_name();
+ ::std::string* release_name();
+ void set_allocated_name(::std::string* name);
+
+ // optional uint64 count = 2;
+ bool has_count() const;
+ void clear_count();
+ static const int kCountFieldNumber = 2;
+ ::google::protobuf::uint64 count() const;
+ void set_count(::google::protobuf::uint64 value);
+
+ // @@protoc_insertion_point(class_scope:google.protobuf.compiler.MessageAccessInfo)
+ private:
+ void set_has_name();
+ void clear_has_name();
+ void set_has_count();
+ void clear_has_count();
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ ::google::protobuf::RepeatedPtrField< ::google::protobuf::compiler::FieldAccessInfo > field_;
+ ::google::protobuf::internal::ArenaStringPtr name_;
+ ::google::protobuf::uint64 count_;
+ friend struct protobuf_google_2fprotobuf_2fcompiler_2fprofile_2eproto::TableStruct;
+};
+// -------------------------------------------------------------------
+
+class LIBPROTOC_EXPORT AccessInfo : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.AccessInfo) */ {
+ public:
+ AccessInfo();
+ virtual ~AccessInfo();
+
+ AccessInfo(const AccessInfo& from);
+
+ inline AccessInfo& operator=(const AccessInfo& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const AccessInfo& default_instance();
+
+ static inline const AccessInfo* internal_default_instance() {
+ return reinterpret_cast<const AccessInfo*>(
+ &_AccessInfo_default_instance_);
+ }
+ static PROTOBUF_CONSTEXPR int const kIndexInFileMessages =
+ 2;
+
+ void Swap(AccessInfo* other);
+
+ // implements Message ----------------------------------------------
+
+ inline AccessInfo* New() const PROTOBUF_FINAL { return New(NULL); }
+
+ AccessInfo* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+ void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+ void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+ void CopyFrom(const AccessInfo& from);
+ void MergeFrom(const AccessInfo& from);
+ void Clear() PROTOBUF_FINAL;
+ bool IsInitialized() const PROTOBUF_FINAL;
+
+ size_t ByteSizeLong() const PROTOBUF_FINAL;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
+ int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const PROTOBUF_FINAL;
+ void InternalSwap(AccessInfo* other);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return NULL;
+ }
+ inline void* MaybeArenaPtr() const {
+ return NULL;
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
+
+ // nested types ----------------------------------------------------
+
+ // accessors -------------------------------------------------------
+
+ // repeated .google.protobuf.compiler.MessageAccessInfo message = 1;
+ int message_size() const;
+ void clear_message();
+ static const int kMessageFieldNumber = 1;
+ const ::google::protobuf::compiler::MessageAccessInfo& message(int index) const;
+ ::google::protobuf::compiler::MessageAccessInfo* mutable_message(int index);
+ ::google::protobuf::compiler::MessageAccessInfo* add_message();
+ ::google::protobuf::RepeatedPtrField< ::google::protobuf::compiler::MessageAccessInfo >*
+ mutable_message();
+ const ::google::protobuf::RepeatedPtrField< ::google::protobuf::compiler::MessageAccessInfo >&
+ message() const;
+
+ // @@protoc_insertion_point(class_scope:google.protobuf.compiler.AccessInfo)
+ private:
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ ::google::protobuf::RepeatedPtrField< ::google::protobuf::compiler::MessageAccessInfo > message_;
+ friend struct protobuf_google_2fprotobuf_2fcompiler_2fprofile_2eproto::TableStruct;
+};
+// ===================================================================
+
+
+// ===================================================================
+
+#if !PROTOBUF_INLINE_NOT_IN_HEADERS
+// FieldAccessInfo
+
+// optional string name = 1;
+inline bool FieldAccessInfo::has_name() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void FieldAccessInfo::set_has_name() {
+ _has_bits_[0] |= 0x00000001u;
+}
+inline void FieldAccessInfo::clear_has_name() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+inline void FieldAccessInfo::clear_name() {
+ name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_name();
+}
+inline const ::std::string& FieldAccessInfo::name() const {
+ // @@protoc_insertion_point(field_get:google.protobuf.compiler.FieldAccessInfo.name)
+ return name_.GetNoArena();
+}
+inline void FieldAccessInfo::set_name(const ::std::string& value) {
+ set_has_name();
+ name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:google.protobuf.compiler.FieldAccessInfo.name)
+}
+#if LANG_CXX11
+inline void FieldAccessInfo::set_name(::std::string&& value) {
+ set_has_name();
+ name_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.FieldAccessInfo.name)
+}
+#endif
+inline void FieldAccessInfo::set_name(const char* value) {
+ GOOGLE_DCHECK(value != NULL);
+ set_has_name();
+ name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.FieldAccessInfo.name)
+}
+inline void FieldAccessInfo::set_name(const char* value, size_t size) {
+ set_has_name();
+ name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.FieldAccessInfo.name)
+}
+inline ::std::string* FieldAccessInfo::mutable_name() {
+ set_has_name();
+ // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.FieldAccessInfo.name)
+ return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline ::std::string* FieldAccessInfo::release_name() {
+ // @@protoc_insertion_point(field_release:google.protobuf.compiler.FieldAccessInfo.name)
+ clear_has_name();
+ return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void FieldAccessInfo::set_allocated_name(::std::string* name) {
+ if (name != NULL) {
+ set_has_name();
+ } else {
+ clear_has_name();
+ }
+ name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);
+ // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.FieldAccessInfo.name)
+}
+
+// optional uint64 getters_count = 2;
+inline bool FieldAccessInfo::has_getters_count() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+inline void FieldAccessInfo::set_has_getters_count() {
+ _has_bits_[0] |= 0x00000002u;
+}
+inline void FieldAccessInfo::clear_has_getters_count() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+inline void FieldAccessInfo::clear_getters_count() {
+ getters_count_ = GOOGLE_ULONGLONG(0);
+ clear_has_getters_count();
+}
+inline ::google::protobuf::uint64 FieldAccessInfo::getters_count() const {
+ // @@protoc_insertion_point(field_get:google.protobuf.compiler.FieldAccessInfo.getters_count)
+ return getters_count_;
+}
+inline void FieldAccessInfo::set_getters_count(::google::protobuf::uint64 value) {
+ set_has_getters_count();
+ getters_count_ = value;
+ // @@protoc_insertion_point(field_set:google.protobuf.compiler.FieldAccessInfo.getters_count)
+}
+
+// optional uint64 setters_count = 3;
+inline bool FieldAccessInfo::has_setters_count() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+inline void FieldAccessInfo::set_has_setters_count() {
+ _has_bits_[0] |= 0x00000004u;
+}
+inline void FieldAccessInfo::clear_has_setters_count() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+inline void FieldAccessInfo::clear_setters_count() {
+ setters_count_ = GOOGLE_ULONGLONG(0);
+ clear_has_setters_count();
+}
+inline ::google::protobuf::uint64 FieldAccessInfo::setters_count() const {
+ // @@protoc_insertion_point(field_get:google.protobuf.compiler.FieldAccessInfo.setters_count)
+ return setters_count_;
+}
+inline void FieldAccessInfo::set_setters_count(::google::protobuf::uint64 value) {
+ set_has_setters_count();
+ setters_count_ = value;
+ // @@protoc_insertion_point(field_set:google.protobuf.compiler.FieldAccessInfo.setters_count)
+}
+
+// optional uint64 configs_count = 4;
+inline bool FieldAccessInfo::has_configs_count() const {
+ return (_has_bits_[0] & 0x00000008u) != 0;
+}
+inline void FieldAccessInfo::set_has_configs_count() {
+ _has_bits_[0] |= 0x00000008u;
+}
+inline void FieldAccessInfo::clear_has_configs_count() {
+ _has_bits_[0] &= ~0x00000008u;
+}
+inline void FieldAccessInfo::clear_configs_count() {
+ configs_count_ = GOOGLE_ULONGLONG(0);
+ clear_has_configs_count();
+}
+inline ::google::protobuf::uint64 FieldAccessInfo::configs_count() const {
+ // @@protoc_insertion_point(field_get:google.protobuf.compiler.FieldAccessInfo.configs_count)
+ return configs_count_;
+}
+inline void FieldAccessInfo::set_configs_count(::google::protobuf::uint64 value) {
+ set_has_configs_count();
+ configs_count_ = value;
+ // @@protoc_insertion_point(field_set:google.protobuf.compiler.FieldAccessInfo.configs_count)
+}
+
+// -------------------------------------------------------------------
+
+// MessageAccessInfo
+
+// optional string name = 1;
+inline bool MessageAccessInfo::has_name() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void MessageAccessInfo::set_has_name() {
+ _has_bits_[0] |= 0x00000001u;
+}
+inline void MessageAccessInfo::clear_has_name() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+inline void MessageAccessInfo::clear_name() {
+ name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_name();
+}
+inline const ::std::string& MessageAccessInfo::name() const {
+ // @@protoc_insertion_point(field_get:google.protobuf.compiler.MessageAccessInfo.name)
+ return name_.GetNoArena();
+}
+inline void MessageAccessInfo::set_name(const ::std::string& value) {
+ set_has_name();
+ name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:google.protobuf.compiler.MessageAccessInfo.name)
+}
+#if LANG_CXX11
+inline void MessageAccessInfo::set_name(::std::string&& value) {
+ set_has_name();
+ name_.SetNoArena(
+ &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+ // @@protoc_insertion_point(field_set_rvalue:google.protobuf.compiler.MessageAccessInfo.name)
+}
+#endif
+inline void MessageAccessInfo::set_name(const char* value) {
+ GOOGLE_DCHECK(value != NULL);
+ set_has_name();
+ name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.MessageAccessInfo.name)
+}
+inline void MessageAccessInfo::set_name(const char* value, size_t size) {
+ set_has_name();
+ name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.MessageAccessInfo.name)
+}
+inline ::std::string* MessageAccessInfo::mutable_name() {
+ set_has_name();
+ // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.MessageAccessInfo.name)
+ return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline ::std::string* MessageAccessInfo::release_name() {
+ // @@protoc_insertion_point(field_release:google.protobuf.compiler.MessageAccessInfo.name)
+ clear_has_name();
+ return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void MessageAccessInfo::set_allocated_name(::std::string* name) {
+ if (name != NULL) {
+ set_has_name();
+ } else {
+ clear_has_name();
+ }
+ name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);
+ // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.MessageAccessInfo.name)
+}
+
+// optional uint64 count = 2;
+inline bool MessageAccessInfo::has_count() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+inline void MessageAccessInfo::set_has_count() {
+ _has_bits_[0] |= 0x00000002u;
+}
+inline void MessageAccessInfo::clear_has_count() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+inline void MessageAccessInfo::clear_count() {
+ count_ = GOOGLE_ULONGLONG(0);
+ clear_has_count();
+}
+inline ::google::protobuf::uint64 MessageAccessInfo::count() const {
+ // @@protoc_insertion_point(field_get:google.protobuf.compiler.MessageAccessInfo.count)
+ return count_;
+}
+inline void MessageAccessInfo::set_count(::google::protobuf::uint64 value) {
+ set_has_count();
+ count_ = value;
+ // @@protoc_insertion_point(field_set:google.protobuf.compiler.MessageAccessInfo.count)
+}
+
+// repeated .google.protobuf.compiler.FieldAccessInfo field = 3;
+inline int MessageAccessInfo::field_size() const {
+ return field_.size();
+}
+inline void MessageAccessInfo::clear_field() {
+ field_.Clear();
+}
+inline const ::google::protobuf::compiler::FieldAccessInfo& MessageAccessInfo::field(int index) const {
+ // @@protoc_insertion_point(field_get:google.protobuf.compiler.MessageAccessInfo.field)
+ return field_.Get(index);
+}
+inline ::google::protobuf::compiler::FieldAccessInfo* MessageAccessInfo::mutable_field(int index) {
+ // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.MessageAccessInfo.field)
+ return field_.Mutable(index);
+}
+inline ::google::protobuf::compiler::FieldAccessInfo* MessageAccessInfo::add_field() {
+ // @@protoc_insertion_point(field_add:google.protobuf.compiler.MessageAccessInfo.field)
+ return field_.Add();
+}
+inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::compiler::FieldAccessInfo >*
+MessageAccessInfo::mutable_field() {
+ // @@protoc_insertion_point(field_mutable_list:google.protobuf.compiler.MessageAccessInfo.field)
+ return &field_;
+}
+inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::compiler::FieldAccessInfo >&
+MessageAccessInfo::field() const {
+ // @@protoc_insertion_point(field_list:google.protobuf.compiler.MessageAccessInfo.field)
+ return field_;
+}
+
+// -------------------------------------------------------------------
+
+// AccessInfo
+
+// repeated .google.protobuf.compiler.MessageAccessInfo message = 1;
+inline int AccessInfo::message_size() const {
+ return message_.size();
+}
+inline void AccessInfo::clear_message() {
+ message_.Clear();
+}
+inline const ::google::protobuf::compiler::MessageAccessInfo& AccessInfo::message(int index) const {
+ // @@protoc_insertion_point(field_get:google.protobuf.compiler.AccessInfo.message)
+ return message_.Get(index);
+}
+inline ::google::protobuf::compiler::MessageAccessInfo* AccessInfo::mutable_message(int index) {
+ // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.AccessInfo.message)
+ return message_.Mutable(index);
+}
+inline ::google::protobuf::compiler::MessageAccessInfo* AccessInfo::add_message() {
+ // @@protoc_insertion_point(field_add:google.protobuf.compiler.AccessInfo.message)
+ return message_.Add();
+}
+inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::compiler::MessageAccessInfo >*
+AccessInfo::mutable_message() {
+ // @@protoc_insertion_point(field_mutable_list:google.protobuf.compiler.AccessInfo.message)
+ return &message_;
+}
+inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::compiler::MessageAccessInfo >&
+AccessInfo::message() const {
+ // @@protoc_insertion_point(field_list:google.protobuf.compiler.AccessInfo.message)
+ return message_;
+}
+
+#endif // !PROTOBUF_INLINE_NOT_IN_HEADERS
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+
+// @@protoc_insertion_point(namespace_scope)
+
+
+} // namespace compiler
+} // namespace protobuf
+} // namespace google
+
+// @@protoc_insertion_point(global_scope)
+
+#endif // PROTOBUF_google_2fprotobuf_2fcompiler_2fprofile_2eproto__INCLUDED
diff --git a/src/google/protobuf/compiler/profile.proto b/src/google/protobuf/compiler/profile.proto
new file mode 100644
index 00000000..09ebe091
--- /dev/null
+++ b/src/google/protobuf/compiler/profile.proto
@@ -0,0 +1,68 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// 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
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (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: seongkim@google.com (Seong Beom Kim)
+//
+// protoc (Protocol Compiler) can generate more efficient code
+// if it knows how a workload accesses fields of a message;
+// e.g. some much more frequently than others.
+//
+// Protos defined here describe the access information per message
+// and per field. Note that one can use any methods to collect
+// the access patterns like CPU profiling, instrumented build, etc.
+
+syntax = "proto2";
+
+package google.protobuf.compiler;
+
+// To convey the access pattern of a field, it classifies
+// the type of the accessor methods into getters, setters and
+// configs. Getters and setters read and write the field
+// respectively and other operations like checking if the field
+// exists are considered as configs.
+message FieldAccessInfo {
+ optional string name = 1;
+ optional uint64 getters_count = 2;
+ optional uint64 setters_count = 3;
+ optional uint64 configs_count = 4;
+}
+
+// "count" correlates with how many samples an access info has
+// for a message. High "count" means more confident optimization
+// based on the info.
+message MessageAccessInfo {
+ optional string name = 1;
+ optional uint64 count = 2;
+ repeated FieldAccessInfo field = 3;
+}
+
+message AccessInfo {
+ repeated MessageAccessInfo message = 1;
+}
diff --git a/src/google/protobuf/compiler/test_plugin.cc b/src/google/protobuf/compiler/test_plugin.cc
index 4830fd70..c676ce8c 100644
--- a/src/google/protobuf/compiler/test_plugin.cc
+++ b/src/google/protobuf/compiler/test_plugin.cc
@@ -37,7 +37,6 @@
#include <stdlib.h>
#include <google/protobuf/compiler/plugin.h>
#include <google/protobuf/compiler/mock_code_generator.h>
-#include <google/protobuf/stubs/strutil.h>
int main(int argc, char* argv[]) {
#ifdef _MSC_VER
diff --git a/src/google/protobuf/compiler/zip_writer.cc b/src/google/protobuf/compiler/zip_writer.cc
index 07d52b18..458cced2 100644
--- a/src/google/protobuf/compiler/zip_writer.cc
+++ b/src/google/protobuf/compiler/zip_writer.cc
@@ -28,6 +28,36 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// 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
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (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: ambrose@google.com (Ambrose Feinstein),
// kenton@google.com (Kenton Varda)
//
diff --git a/src/google/protobuf/compiler/zip_writer.h b/src/google/protobuf/compiler/zip_writer.h
index 737f4d42..03db4d57 100644
--- a/src/google/protobuf/compiler/zip_writer.h
+++ b/src/google/protobuf/compiler/zip_writer.h
@@ -28,6 +28,36 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// 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
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (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)
#include <vector>