diff options
Diffstat (limited to 'src/google/protobuf/compiler')
26 files changed, 479 insertions, 465 deletions
diff --git a/src/google/protobuf/compiler/command_line_interface.cc b/src/google/protobuf/compiler/command_line_interface.cc index bef0fe5a..725ac823 100644 --- a/src/google/protobuf/compiler/command_line_interface.cc +++ b/src/google/protobuf/compiler/command_line_interface.cc @@ -116,6 +116,9 @@ static const char* kPathSeparator = ";"; static const char* kPathSeparator = ":"; #endif +static const char* kDefaultDirectDependenciesViolationMsg = + "File is imported but not declared in --direct_dependencies: %s"; + // Returns true if the text looks like a Windows-style absolute path, starting // with a drive letter. Example: "C:\foo". TODO(kenton): Share this with // copy in importer.cc? @@ -276,12 +279,13 @@ class CommandLineInterface::ErrorPrinter : public MultiFileErrorCollector, public io::ErrorCollector { public: ErrorPrinter(ErrorFormat format, DiskSourceTree *tree = NULL) - : format_(format), tree_(tree) {} + : format_(format), tree_(tree), found_errors_(false) {} ~ErrorPrinter() {} // implements MultiFileErrorCollector ------------------------------ void AddError(const string& filename, int line, int column, const string& message) { + found_errors_ = true; AddErrorOrWarning(filename, line, column, message, "error", std::cerr); } @@ -299,10 +303,12 @@ class CommandLineInterface::ErrorPrinter : public MultiFileErrorCollector, AddErrorOrWarning("input", line, column, message, "warning", std::clog); } + bool FoundErrors() const { return found_errors_; } + private: - void AddErrorOrWarning( - const string& filename, int line, int column, - const string& message, const string& type, ostream& out) { + void AddErrorOrWarning(const string& filename, int line, int column, + const string& message, const string& type, + std::ostream& out) { // Print full path when running under MSVS string dfile; if (format_ == CommandLineInterface::ERROR_FORMAT_MSVS && @@ -337,6 +343,7 @@ class CommandLineInterface::ErrorPrinter : public MultiFileErrorCollector, const ErrorFormat format_; DiskSourceTree *tree_; + bool found_errors_; }; // ------------------------------------------------------------------- @@ -708,14 +715,17 @@ CommandLineInterface::MemoryOutputStream::~MemoryOutputStream() { // =================================================================== CommandLineInterface::CommandLineInterface() - : mode_(MODE_COMPILE), - print_mode_(PRINT_NONE), - error_format_(ERROR_FORMAT_GCC), - direct_dependencies_explicitly_set_(false), - imports_in_descriptor_set_(false), - source_info_in_descriptor_set_(false), - disallow_services_(false), - inputs_are_proto_path_relative_(false) {} + : mode_(MODE_COMPILE), + print_mode_(PRINT_NONE), + error_format_(ERROR_FORMAT_GCC), + direct_dependencies_explicitly_set_(false), + direct_dependencies_violation_msg_( + kDefaultDirectDependenciesViolationMsg), + imports_in_descriptor_set_(false), + source_info_in_descriptor_set_(false), + disallow_services_(false), + inputs_are_proto_path_relative_(false) { +} CommandLineInterface::~CommandLineInterface() {} void CommandLineInterface::RegisterGenerator(const string& flag_name, @@ -800,10 +810,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() - << ": File is imported but not declared in " - << "--direct_dependencies: " - << parsed_file->dependency(i)->name() << std::endl; + cerr << parsed_file->name() << ": " + << StringReplace(direct_dependencies_violation_msg_, "%s", + parsed_file->dependency(i)->name(), + true /* replace_all */) + << std::endl; } } if (indirect_imports) { @@ -895,6 +906,10 @@ int CommandLineInterface::Run(int argc, const char* const argv[]) { } } + if (error_collector.FoundErrors()) { + return 1; + } + if (mode_ == MODE_PRINT) { switch (print_mode_) { case PRINT_FREE_FIELDS: @@ -924,6 +939,7 @@ void CommandLineInterface::Clear() { proto_path_.clear(); input_files_.clear(); direct_dependencies_.clear(); + direct_dependencies_violation_msg_ = kDefaultDirectDependenciesViolationMsg; output_directives_.clear(); codec_type_.clear(); descriptor_set_name_.clear(); @@ -1209,6 +1225,9 @@ CommandLineInterface::InterpretArgument(const string& name, GOOGLE_DCHECK(direct_dependencies_.empty()); direct_dependencies_.insert(direct.begin(), direct.end()); + } else if (name == "--direct_dependencies_violation_msg") { + direct_dependencies_violation_msg_ = value; + } else if (name == "-o" || name == "--descriptor_set_out") { if (!descriptor_set_name_.empty()) { std::cerr << name << " may only be passed once." << std::endl; diff --git a/src/google/protobuf/compiler/command_line_interface.h b/src/google/protobuf/compiler/command_line_interface.h index 28471ee7..8f8c2682 100644 --- a/src/google/protobuf/compiler/command_line_interface.h +++ b/src/google/protobuf/compiler/command_line_interface.h @@ -365,6 +365,10 @@ class LIBPROTOC_EXPORT CommandLineInterface { std::set<string> direct_dependencies_; bool direct_dependencies_explicitly_set_; + // If there's a violation of depend-on-what-you-import, this string will be + // presented to the user. "%s" will be replaced with the violating import. + string direct_dependencies_violation_msg_; + // output_directives_ lists all the files we are supposed to output and what // generator to use for each. struct OutputDirective { diff --git a/src/google/protobuf/compiler/command_line_interface_unittest.cc b/src/google/protobuf/compiler/command_line_interface_unittest.cc index b2ec8426..e43d287f 100644 --- a/src/google/protobuf/compiler/command_line_interface_unittest.cc +++ b/src/google/protobuf/compiler/command_line_interface_unittest.cc @@ -101,6 +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); // ----------------------------------------------------------------- // Methods to set up the test (called before Run()). @@ -292,8 +293,10 @@ void CommandLineInterfaceTest::TearDown() { } void CommandLineInterfaceTest::Run(const string& command) { - std::vector<string> args = Split(command, " ", true); + RunWithArgs(Split(command, " ", true)); +} +void CommandLineInterfaceTest::RunWithArgs(vector<string> args) { if (!disallow_plugins_) { cli_.AllowPlugins("prefix-"); #ifndef GOOGLE_THIRD_PARTY_PROTOBUF @@ -996,6 +999,27 @@ TEST_F(CommandLineInterfaceTest, DirectDependencies_ProvidedMultipleTimes) { "':'.\n"); } +TEST_F(CommandLineInterfaceTest, DirectDependencies_CustomErrorMessage) { + CreateTempFile("foo.proto", + "syntax = \"proto2\";\n" + "import \"bar.proto\";\n" + "message Foo { optional Bar bar = 1; }"); + CreateTempFile("bar.proto", + "syntax = \"proto2\";\n" + "message Bar { optional string text = 1; }"); + + vector<string> commands; + commands.push_back("protocol_compiler"); + commands.push_back("--test_out=$tmpdir"); + commands.push_back("--proto_path=$tmpdir"); + commands.push_back("--direct_dependencies="); + commands.push_back("--direct_dependencies_violation_msg=Bla \"%s\" Bla"); + commands.push_back("foo.proto"); + RunWithArgs(commands); + + ExpectErrorText("foo.proto: Bla \"bar.proto\" Bla\n"); +} + TEST_F(CommandLineInterfaceTest, CwdRelativeInputs) { // Test that we can accept working-directory-relative input files. @@ -1283,6 +1307,19 @@ TEST_F(CommandLineInterfaceTest, ParseErrorsMultipleFiles) { "foo.proto: Import \"baz.proto\" was not found or had errors.\n"); } +TEST_F(CommandLineInterfaceTest, RecursiveImportFails) { + // Create a proto file that imports itself. + CreateTempFile("foo.proto", + "syntax = \"proto2\";\n" + "import \"foo.proto\";\n"); + + Run("protocol_compiler --test_out=$tmpdir " + "--proto_path=$tmpdir foo.proto"); + + ExpectErrorSubstring( + "foo.proto: File recursively imports itself: foo.proto -> foo.proto\n"); +} + TEST_F(CommandLineInterfaceTest, InputNotFoundError) { // Test what happens if the input file is not found. diff --git a/src/google/protobuf/compiler/cpp/cpp_enum.cc b/src/google/protobuf/compiler/cpp/cpp_enum.cc index 9493d5f8..6a8a83d1 100644 --- a/src/google/protobuf/compiler/cpp/cpp_enum.cc +++ b/src/google/protobuf/compiler/cpp/cpp_enum.cc @@ -251,13 +251,15 @@ void EnumGenerator::GenerateMethods(io::Printer* printer) { vars["classname"] = classname_; vars["index_in_metadata"] = SimpleItoa(index_in_metadata_); vars["constexpr"] = options_.proto_h ? "constexpr " : ""; + vars["file_namespace"] = FileLevelNamespace(descriptor_->file()->name()); if (HasDescriptorMethods(descriptor_->file(), options_)) { printer->Print( vars, "const ::google::protobuf::EnumDescriptor* $classname$_descriptor() {\n" - " protobuf_AssignDescriptorsOnce();\n" - " return file_level_enum_descriptors[$index_in_metadata$];\n" + " $file_namespace$::protobuf_AssignDescriptorsOnce();\n" + " return " + "$file_namespace$::file_level_enum_descriptors[$index_in_metadata$];\n" "}\n"); } diff --git a/src/google/protobuf/compiler/cpp/cpp_enum_field.cc b/src/google/protobuf/compiler/cpp/cpp_enum_field.cc index b6658079..44a86fc8 100644 --- a/src/google/protobuf/compiler/cpp/cpp_enum_field.cc +++ b/src/google/protobuf/compiler/cpp/cpp_enum_field.cc @@ -230,7 +230,7 @@ void EnumOneofFieldGenerator:: GenerateConstructorCode(io::Printer* printer) const { printer->Print( variables_, - " $classname$_default_oneof_instance_.$name$_ = $default$;\n"); + "_$classname$_default_instance_.$name$_ = $default$;\n"); } // =================================================================== diff --git a/src/google/protobuf/compiler/cpp/cpp_file.cc b/src/google/protobuf/compiler/cpp/cpp_file.cc index 9cfd6ec6..0e5e2f18 100644 --- a/src/google/protobuf/compiler/cpp/cpp_file.cc +++ b/src/google/protobuf/compiler/cpp/cpp_file.cc @@ -284,8 +284,13 @@ void FileGenerator::GenerateSource(io::Printer* printer) { if (IsMapEntryMessage(message_generators_[i]->descriptor_)) continue; printer->Print( "class $classname$DefaultTypeInternal : " - "public ::google::protobuf::internal::ExplicitlyConstructed<$classname$> {};\n" - "$classname$DefaultTypeInternal _$classname$_default_instance_;\n", + "public ::google::protobuf::internal::ExplicitlyConstructed<$classname$> {\n", + "classname", message_generators_[i]->classname_); + printer->Indent(); + message_generators_[i]->GenerateExtraDefaultFields(printer); + printer->Outdent(); + printer->Print( + "} _$classname$_default_instance_;\n", "classname", message_generators_[i]->classname_); } @@ -301,6 +306,12 @@ void FileGenerator::GenerateSource(io::Printer* printer) { } } + printer->Print( + "\n" + "namespace $file_namespace$ {\n" + "\n", + "file_namespace", FileLevelNamespace(file_->name())); + if (HasDescriptorMethods(file_, options_)) { printer->Print( "\n" @@ -324,10 +335,6 @@ void FileGenerator::GenerateSource(io::Printer* printer) { "size", SimpleItoa(file_->service_count())); } - for (int i = 0; i < message_generators_.size(); i++) { - message_generators_[i]->GenerateDescriptorDeclarations(printer); - } - printer->Print( "\n" "} // namespace\n" @@ -338,6 +345,12 @@ void FileGenerator::GenerateSource(io::Printer* printer) { // library, all this does is initialize default instances.) GenerateBuildDescriptors(printer); + printer->Print( + "\n" + "} // namespace $file_namespace$\n" + "\n", + "file_namespace", FileLevelNamespace(file_->name())); + // Generate enums. for (int i = 0; i < enum_generators_.size(); i++) { enum_generators_[i]->GenerateMethods(printer); @@ -473,28 +486,16 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) { if (HasDescriptorMethods(file_, options_)) { if (!message_generators_.empty()) { - printer->Print( - "\n" - "const ::google::protobuf::uint32* $offsetfunname$() GOOGLE_ATTRIBUTE_COLD;\n" - "const ::google::protobuf::uint32* $offsetfunname$() {\n", - "offsetfunname", GlobalOffsetTableName(file_->name())); - printer->Indent(); - - printer->Print("static const ::google::protobuf::uint32 offsets[] = {\n"); + printer->Print("const ::google::protobuf::uint32 TableStruct::offsets[] = {\n"); printer->Indent(); std::vector<std::pair<size_t, size_t> > pairs; for (int i = 0; i < message_generators_.size(); i++) { pairs.push_back(message_generators_[i]->GenerateOffsets(printer)); } printer->Outdent(); - printer->Outdent(); - printer->Print( - " };\n" - " return offsets;\n" - "}\n" - "\n"); - printer->Print( + "};\n" + "\n" "static const ::google::protobuf::internal::MigrationSchema schemas[] = {\n"); printer->Indent(); { @@ -508,25 +509,17 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) { printer->Outdent(); printer->Print( "};\n" - "\n" - "static const ::google::protobuf::internal::DefaultInstanceData " - "file_default_instances[] = {\n"); + "\nstatic " + "::google::protobuf::Message const * const file_default_instances[] = {\n"); printer->Indent(); for (int i = 0; i < message_generators_.size(); i++) { const Descriptor* descriptor = message_generators_[i]->descriptor_; if (IsMapEntryMessage(descriptor)) continue; - string oneof_default = "NULL"; - if (message_generators_[i]->descriptor_->oneof_decl_count()) { - oneof_default = - "&" + ClassName(descriptor, false) + "_default_oneof_instance_"; - } printer->Print( - "{reinterpret_cast<const " - "::google::protobuf::Message*>(&_$classname$_default_instance_), " - "$oneof_default$},\n", - "classname", ClassName(descriptor, false), "oneof_default", - oneof_default); + "reinterpret_cast<const " + "::google::protobuf::Message*>(&_$classname$_default_instance_),\n", + "classname", ClassName(descriptor, false)); } printer->Outdent(); printer->Print( @@ -535,12 +528,11 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) { } else { // we still need these symbols to exist printer->Print( - "inline ::google::protobuf::uint32* $offsetfunname$() { return NULL; }\n" + // MSVC doesn't like empty arrays, so we add a dummy. + "const ::google::protobuf::uint32 TableStruct::offsets[] = { ~0u };\n" "static const ::google::protobuf::internal::MigrationSchema* schemas = NULL;\n" - "static const ::google::protobuf::internal::DefaultInstanceData* " - "file_default_instances = NULL;\n", - "offsetfunname", - GlobalOffsetTableName(file_->name())); + "static const ::google::protobuf::Message* const* " + "file_default_instances = NULL;\n"); } // --------------------------------------------------------------- @@ -557,11 +549,11 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) { // is requested *during* static init then AddDescriptors() may not have // been called yet, so we call it manually. Note that it's fine if // AddDescriptors() is called multiple times. - " $adddescriptorsname$();\n" + " AddDescriptors();\n" " ::google::protobuf::MessageFactory* factory = $factory$;\n" " AssignDescriptors(\n" " \"$filename$\", schemas, file_default_instances, " - "$offsetfunname$(), factory,\n" + "TableStruct::offsets, factory,\n" " $metadata$, $enum_descriptors$, $service_descriptors$);\n" "}\n" "\n" @@ -570,9 +562,7 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) { " ::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors);\n" "}\n" "\n", - "adddescriptorsname", GlobalAddDescriptorsName(file_->name()), - "offsetfunname", GlobalOffsetTableName(file_->name()), "filename", - file_->name(), "metadata", + "filename", file_->name(), "metadata", !message_generators_.empty() ? "file_level_metadata" : "NULL", "enum_descriptors", !enum_generators_.empty() ? "file_level_enum_descriptors" : "NULL", @@ -616,8 +606,7 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) { // ShutdownFile(): Deletes descriptors, default instances, etc. on shutdown. printer->Print( "\n" - "void $shutdownfilename$() {\n", - "shutdownfilename", GlobalShutdownFileName(file_->name())); + "void TableStruct::Shutdown() {\n"); printer->Indent(); for (int i = 0; i < message_generators_.size(); i++) { @@ -630,13 +619,12 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) { // ----------------------------------------------------------------- - // Now generate the InitDefaults() function. + // Now generate the InitDefaultsImpl() function. printer->Print( - "void $initdefaultsname$_impl() {\n" + "void TableStruct::InitDefaultsImpl() {\n" " GOOGLE_PROTOBUF_VERIFY_VERSION;\n\n" - "", - // Vars. - "initdefaultsname", GlobalInitDefaultsName(file_->name())); + // Force initialization of primitive values we depend on. + " ::google::protobuf::internal::InitProtobufDefaults();\n"); printer->Indent(); @@ -645,17 +633,13 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) { for (int i = 0; i < file_->dependency_count(); i++) { const FileDescriptor* dependency = file_->dependency(i); // Print the namespace prefix for the dependency. - string add_desc_name = QualifiedFileLevelSymbol( - dependency->package(), GlobalInitDefaultsName(dependency->name())); + string file_namespace = QualifiedFileLevelSymbol( + dependency->package(), FileLevelNamespace(dependency->name())); // Call its AddDescriptors function. - printer->Print( - "$name$();\n", - "name", add_desc_name); + printer->Print("$file_namespace$::InitDefaults();\n", "file_namespace", + file_namespace); } - // Force initialization of primitive values we depend on. - printer->Print("::google::protobuf::internal::InitProtobufDefaults();\n"); - // Allocate and initialize default instances. This can't be done lazily // since default instances are returned by simple accessors and are used with // extensions. Speaking of which, we also register extensions at this time. @@ -672,21 +656,17 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) { printer->Print( "}\n" "\n" - "void $initdefaultsname$() {\n" + "void InitDefaults() {\n" " static GOOGLE_PROTOBUF_DECLARE_ONCE(once);\n" - " ::google::protobuf::GoogleOnceInit(&once, &$initdefaultsname$_impl);\n" - "}\n", - "initdefaultsname", GlobalInitDefaultsName(file_->name())); + " ::google::protobuf::GoogleOnceInit(&once, &TableStruct::InitDefaultsImpl);\n" + "}\n"); // ----------------------------------------------------------------- // Now generate the AddDescriptors() function. printer->Print( - "void $adddescriptorsname$_impl() {\n" - " $initdefaultsname$();\n", - // Vars. - "adddescriptorsname", GlobalAddDescriptorsName(file_->name()), - "initdefaultsname", GlobalInitDefaultsName(file_->name())); + "void AddDescriptorsImpl() {\n" + " InitDefaults();\n"); printer->Indent(); if (HasDescriptorMethods(file_, options_)) { @@ -702,12 +682,7 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) { printer->Print("static const char descriptor[] = {\n"); printer->Indent(); -#ifdef _MSC_VER - bool breakdown_large_file = true; -#else - bool breakdown_large_file = false; -#endif - if (breakdown_large_file && file_data.size() > 66538) { + if (file_data.size() > 66535) { // Workaround for MSVC: "Error C1091: compiler limit: string exceeds 65535 // bytes in length". Declare a static array of characters rather than use // a string literal. Only write 25 bytes per line. @@ -748,42 +723,36 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) { for (int i = 0; i < file_->dependency_count(); i++) { const FileDescriptor* dependency = file_->dependency(i); // Print the namespace prefix for the dependency. - string add_desc_name = QualifiedFileLevelSymbol( - dependency->package(), GlobalAddDescriptorsName(dependency->name())); + string file_namespace = QualifiedFileLevelSymbol( + dependency->package(), FileLevelNamespace(dependency->name())); // Call its AddDescriptors function. - printer->Print("$adddescriptorsname$();\n", "adddescriptorsname", - add_desc_name); + printer->Print("$file_namespace$::AddDescriptors();\n", "file_namespace", + file_namespace); } printer->Print( - "::google::protobuf::internal::OnShutdown(&$shutdownfilename$);\n", - "shutdownfilename", GlobalShutdownFileName(file_->name())); + "::google::protobuf::internal::OnShutdown(&TableStruct::Shutdown);\n"); printer->Outdent(); printer->Print( "}\n" "\n" - "GOOGLE_PROTOBUF_DECLARE_ONCE($adddescriptorsname$_once_);\n" - "void $adddescriptorsname$() {\n" - " ::google::protobuf::GoogleOnceInit(&$adddescriptorsname$_once_,\n" - " &$adddescriptorsname$_impl);\n" - "}\n", - "adddescriptorsname", GlobalAddDescriptorsName(file_->name())); + "void AddDescriptors() {\n" + " static GOOGLE_PROTOBUF_DECLARE_ONCE(once);\n" + " ::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl);\n" + "}\n"); if (!StaticInitializersForced(file_, options_)) { - printer->Print("#ifndef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER\n"); + printer->Print("#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER\n"); } printer->Print( // With static initializers. "// Force AddDescriptors() to be called at static initialization time.\n" - "struct StaticDescriptorInitializer_$filename$ {\n" - " StaticDescriptorInitializer_$filename$() {\n" - " $adddescriptorsname$();\n" + "struct StaticDescriptorInitializer {\n" + " StaticDescriptorInitializer() {\n" + " AddDescriptors();\n" " }\n" - "} static_descriptor_initializer_$filename$_;\n", - // Vars. - "adddescriptorsname", GlobalAddDescriptorsName(file_->name()), "filename", - FilenameIdentifier(file_->name())); + "} static_descriptor_initializer;\n"); if (!StaticInitializersForced(file_, options_)) { printer->Print("#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER\n"); } @@ -884,10 +853,11 @@ void FileGenerator::GenerateLibraryIncludes(io::Printer* printer) { // OK, it's now safe to #include other files. printer->Print( - "#include <google/protobuf/arena.h>\n" - "#include <google/protobuf/arenastring.h>\n" - "#include <google/protobuf/generated_message_util.h>\n" - "#include <google/protobuf/metadata.h>\n"); + "#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/metadata.h>\n"); if (!message_generators_.empty()) { if (HasDescriptorMethods(file_, options_)) { @@ -982,12 +952,21 @@ void FileGenerator::GenerateGlobalStateFunctionDeclarations( // functions, so that we can declare them to be friends of each class. printer->Print( "\n" + "namespace $file_namespace$ {\n" "// Internal implementation detail -- do not call these.\n" - "void $dllexport_decl$$adddescriptorsname$();\n" - "void $dllexport_decl$$initdefaultsname$();\n", - "initdefaultsname", GlobalInitDefaultsName(file_->name()), - "adddescriptorsname", GlobalAddDescriptorsName(file_->name()), - "dllexport_decl", + "struct $dllexport_decl$TableStruct {\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. + // This is the internal implementation of InitDefaults. It should only + // be called by InitDefaults which makes sure it will be called only once. + " static void InitDefaultsImpl();\n" + " static void Shutdown();\n" + "};\n" + "void $dllexport_decl$AddDescriptors();\n" + "void $dllexport_decl$InitDefaults();\n" + "} // namespace $file_namespace$\n", + "file_namespace", FileLevelNamespace(file_->name()), "dllexport_decl", options_.dllexport_decl.empty() ? "" : options_.dllexport_decl + " "); } diff --git a/src/google/protobuf/compiler/cpp/cpp_helpers.cc b/src/google/protobuf/compiler/cpp/cpp_helpers.cc index 5a37b9d7..3c4dddc5 100644 --- a/src/google/protobuf/compiler/cpp/cpp_helpers.cc +++ b/src/google/protobuf/compiler/cpp/cpp_helpers.cc @@ -440,23 +440,8 @@ string FilenameIdentifier(const string& filename) { return result; } -// Return the name of the AddDescriptors() function for a given file. -string GlobalAddDescriptorsName(const string& filename) { - return "protobuf_AddDesc_" + FilenameIdentifier(filename); -} - -string GlobalInitDefaultsName(const string& filename) { - return "protobuf_InitDefaults_" + FilenameIdentifier(filename); -} - -// Return the name of the AssignDescriptors() function for a given file. -string GlobalOffsetTableName(const string& filename) { - return "protobuf_Offsets_" + FilenameIdentifier(filename); -} - -// Return the name of the ShutdownFile() function for a given file. -string GlobalShutdownFileName(const string& filename) { - return "protobuf_ShutdownFile_" + FilenameIdentifier(filename); +string FileLevelNamespace(const string& filename) { + return "protobuf_" + FilenameIdentifier(filename); } // Return the qualified C++ name for a file level symbol. diff --git a/src/google/protobuf/compiler/cpp/cpp_helpers.h b/src/google/protobuf/compiler/cpp/cpp_helpers.h index c988bda8..0f297ec8 100644 --- a/src/google/protobuf/compiler/cpp/cpp_helpers.h +++ b/src/google/protobuf/compiler/cpp/cpp_helpers.h @@ -144,21 +144,13 @@ string DefaultValue(const FieldDescriptor* field); // Convert a file name into a valid identifier. string FilenameIdentifier(const string& filename); -// Return the name of the AddDescriptors() function for a given file. -string GlobalAddDescriptorsName(const string& filename); - -// Return the name of the InitDefaults() function for a given file. -string GlobalInitDefaultsName(const string& filename); - -// Return the name of the offset table function for a given file. -string GlobalOffsetTableName(const string& filename); +// For each .proto file generates a unique namespace. In this namespace global +// definitions are put to prevent collisions. +string FileLevelNamespace(const string& filename); // Return the qualified C++ name for a file level symbol. string QualifiedFileLevelSymbol(const string& package, const string& name); -// Return the name of the ShutdownFile() function for a given file. -string GlobalShutdownFileName(const string& filename); - // Escape C++ trigraphs by escaping question marks to \? string EscapeTrigraphs(const string& to_escape); diff --git a/src/google/protobuf/compiler/cpp/cpp_map_field.cc b/src/google/protobuf/compiler/cpp/cpp_map_field.cc index 5c4b56f7..b4eaf485 100644 --- a/src/google/protobuf/compiler/cpp/cpp_map_field.cc +++ b/src/google/protobuf/compiler/cpp/cpp_map_field.cc @@ -49,6 +49,8 @@ void SetMessageVariables(const FieldDescriptor* descriptor, const Options& options) { SetCommonFieldVariables(descriptor, variables, options); (*variables)["type"] = ClassName(descriptor->message_type(), false); + (*variables)["file_namespace"] = + FileLevelNamespace(descriptor->file()->name()); (*variables)["stream_writer"] = (*variables)["declared_type"] + (HasFastArraySerialization(descriptor->message_type()->file(), options) @@ -174,7 +176,7 @@ GenerateConstructorCode(io::Printer* printer) const { if (HasDescriptorMethods(descriptor_->file(), options_)) { printer->Print(variables_, "$name$_.SetAssignDescriptorCallback(\n" - " protobuf_AssignDescriptorsOnce);\n" + " $file_namespace$::protobuf_AssignDescriptorsOnce);\n" "$name$_.SetEntryDescriptor(\n" " &$type$_descriptor);\n"); } diff --git a/src/google/protobuf/compiler/cpp/cpp_message.cc b/src/google/protobuf/compiler/cpp/cpp_message.cc index 2d3d5640..32f05f25 100644 --- a/src/google/protobuf/compiler/cpp/cpp_message.cc +++ b/src/google/protobuf/compiler/cpp/cpp_message.cc @@ -505,6 +505,7 @@ MessageGenerator::MessageGenerator(const 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()]), enum_generators_( @@ -523,7 +524,7 @@ MessageGenerator::MessageGenerator(const Descriptor* descriptor, OptimizePadding(&optimized_order_, options_); if (HasFieldPresence(descriptor_->file())) { - int has_bit_index = 0; + // We use -1 as a sentinel. has_bit_indices_.resize(descriptor_->field_count(), -1); for (int i = 0; i < optimized_order_.size(); i++) { const FieldDescriptor* field = optimized_order_[i]; @@ -532,19 +533,7 @@ MessageGenerator::MessageGenerator(const Descriptor* descriptor, continue; } - has_bit_indices_[field->index()] = has_bit_index; - has_bit_index++; - } - - // Assign fields that do not use has bits to be at the end. This can be - // removed once we shrink the has bits we assign. - // - // TODO(ckennelly): Shrink the has bits for these fields. - for (int i = 0; i < descriptor_->field_count(); i++) { - const FieldDescriptor* field = descriptor_->field(i); - if (has_bit_indices_[field->index()] < 0) { - has_bit_indices_[field->index()] = has_bit_index++; - } + has_bit_indices_[field->index()] = max_has_bit_index_++; } } @@ -581,9 +570,8 @@ MessageGenerator::MessageGenerator(const Descriptor* descriptor, MessageGenerator::~MessageGenerator() {} size_t MessageGenerator::HasBitsSize() const { - // TODO(jieluo) - Optimize _has_bits_ for repeated and oneof fields. - size_t sizeof_has_bits = (descriptor_->field_count() + 31) / 32 * 4; - if (descriptor_->field_count() == 0) { + size_t sizeof_has_bits = (max_has_bit_index_ + 31) / 32 * 4; + if (sizeof_has_bits == 0) { // Zero-size arrays aren't technically allowed, and MSVC in particular // doesn't like them. We still need to declare these arrays to make // other code compile. Since this is an uncommon case, we'll just declare @@ -642,8 +630,28 @@ GenerateDependentFieldAccessorDeclarations(io::Printer* printer) { void MessageGenerator:: GenerateFieldAccessorDeclarations(io::Printer* printer) { + // optimized_fields_ does not contain fields where + // field->containing_oneof() != NULL + // so we need to iterate over those as well. + // + // We place the non-oneof fields in optimized_order_, as that controls the + // order of the _has_bits_ entries and we want GDB's pretty printers to be + // able to infer these indices from the k[FIELDNAME]FieldNumber order. + std::vector<const FieldDescriptor*> ordered_fields; + ordered_fields.reserve(descriptor_->field_count()); + + ordered_fields.insert( + 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) { + continue; + } + ordered_fields.push_back(field); + } + + for (int i = 0; i < ordered_fields.size(); i++) { + const FieldDescriptor* field = ordered_fields[i]; PrintFieldComment(printer, field); @@ -1191,12 +1199,14 @@ 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(false, output);\n" - "}\n"); + "::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"); } } @@ -1447,25 +1457,15 @@ GenerateClassDefinition(io::Printer* printer) { "::google::protobuf::internal::AnyMetadata _any_metadata_;\n"); } - // Declare AddDescriptors(), BuildDescriptors(), and ShutdownFile() as - // friends so that they can access private static variables like - // default_instance_ and reflection_. - printer->Print("friend void $dllexport_decl$ $initdefaultsname$_impl();\n", - // Vars. - "dllexport_decl", options_.dllexport_decl, "initdefaultsname", - GlobalInitDefaultsName(descriptor_->file()->name())); - printer->Print("friend void $dllexport_decl$ $adddescriptorsname$_impl();\n", - // Vars. - "dllexport_decl", options_.dllexport_decl, - "adddescriptorsname", - GlobalAddDescriptorsName(descriptor_->file()->name())); - + // 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( - "friend const ::google::protobuf::uint32* $offsetfunname$();\n" - "friend void $shutdownfilename$();\n" - "\n", - "offsetfunname", GlobalOffsetTableName(descriptor_->file()->name()), - "shutdownfilename", GlobalShutdownFileName(descriptor_->file()->name())); + "friend struct $dllexport_decl$ $file_namespace$::TableStruct;\n", + // Vars. + "dllexport_decl", options_.dllexport_decl, "file_namespace", + FileLevelNamespace(descriptor_->file()->name())); printer->Outdent(); printer->Print("};"); @@ -1510,15 +1510,13 @@ GenerateInlineMethods(io::Printer* printer, bool is_inline) { } void MessageGenerator:: -GenerateDescriptorDeclarations(io::Printer* printer) { +GenerateExtraDefaultFields(io::Printer* printer) { // Generate oneof default instance for reflection usage. if (descriptor_->oneof_decl_count() > 0) { - printer->Print("struct $name$OneofInstance {\n", - "name", classname_); + 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++) { const FieldDescriptor* field = descriptor_->oneof_decl(i)->field(j); - printer->Print(" "); if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE || (field->cpp_type() == FieldDescriptor::CPPTYPE_STRING && EffectiveStringCType(field) != FieldOptions::STRING)) { @@ -1527,8 +1525,6 @@ GenerateDescriptorDeclarations(io::Printer* printer) { field_generators_.get(field).GeneratePrivateMembers(printer); } } - - printer->Print("} $name$_default_oneof_instance_;\n", "name", classname_); } } @@ -1555,6 +1551,7 @@ GenerateTypeRegistrations(io::Printer* printer) { 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 && @@ -1570,7 +1567,8 @@ GenerateTypeRegistrations(io::Printer* printer) { printer->Print( vars, "const ::google::protobuf::Descriptor* $classname$_descriptor = " - "file_level_metadata[$index_in_metadata$].descriptor;\n" + "$file_namespace$::file_level_metadata[$index_in_metadata$].descriptor;" + "\n" "::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n" " $classname$_descriptor,\n" " ::google::protobuf::internal::MapEntry<\n" @@ -1620,7 +1618,7 @@ GenerateDefaultInstanceInitializer(io::Printer* printer) { HasDescriptorMethods(descriptor_->file(), options_))) { string name; if (field->containing_oneof()) { - name = classname_ + "_default_oneof_instance_."; + name = "_" + classname_ + "_default_instance_."; } else { name = "_" + classname_ + "_default_instance_.get_mutable()->"; } @@ -1740,11 +1738,12 @@ GenerateClassMethods(io::Printer* printer) { if (HasDescriptorMethods(descriptor_->file(), options_)) { printer->Print( "::google::protobuf::Metadata $classname$::GetMetadata() const {\n" - " protobuf_AssignDescriptorsOnce();\n" - " return file_level_metadata[$index$];\n" + " $file_namespace$::protobuf_AssignDescriptorsOnce();\n" + " return $file_namespace$::file_level_metadata[$index$];\n" "}\n" "\n", - "classname", classname_, "index", SimpleItoa(index_in_metadata_)); + "classname", classname_, "index", SimpleItoa(index_in_metadata_), + "file_namespace", FileLevelNamespace(descriptor_->file()->name())); } else { printer->Print( "::std::string $classname$::GetTypeName() const {\n" @@ -1798,7 +1797,7 @@ std::pair<size_t, size_t> MessageGenerator::GenerateOffsets( if (field->containing_oneof()) { printer->Print( "PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET(" - "(&$classname$_default_oneof_instance_), $name$_),\n", + "(&_$classname$_default_instance_), $name$_),\n", "classname", classname_, "name", FieldName(field)); } else { printer->Print( @@ -1820,7 +1819,9 @@ std::pair<size_t, size_t> MessageGenerator::GenerateOffsets( if (HasFieldPresence(descriptor_->file())) { entries += has_bit_indices_.size(); for (int i = 0; i < has_bit_indices_.size(); i++) { - printer->Print("$index$,\n", "index", SimpleItoa(has_bit_indices_[i])); + const string index = has_bit_indices_[i] >= 0 ? + SimpleItoa(has_bit_indices_[i]) : "~0u"; + printer->Print("$index$,\n", "index", index); } } @@ -1849,9 +1850,10 @@ GenerateSharedConstructorCode(io::Printer* printer) { IsMapEntryMessage(descriptor_->nested_type(i))) { printer->Print( "const ::google::protobuf::Descriptor*& $type$_descriptor = " - "file_level_metadata[$index$].descriptor;\n", + "$file_namespace$::file_level_metadata[$index$].descriptor;\n", "type", ClassName(descriptor_->nested_type(i), false), "index", - SimpleItoa(nested_generators_[i]->index_in_metadata_)); + SimpleItoa(nested_generators_[i]->index_in_metadata_), + "file_namespace", FileLevelNamespace(descriptor_->file()->name())); } } @@ -2086,14 +2088,14 @@ GenerateStructors(io::Printer* printer) { "$classname$::$classname$()\n" " : $superclass$()$initializer$ {\n" " if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {\n" - " $initdefaultsname$();\n" + " $file_namespace$::InitDefaults();\n" " }\n" " SharedCtor();\n" " // @@protoc_insertion_point(constructor:$full_name$)\n" "}\n", "classname", classname_, "superclass", superclass, "full_name", descriptor_->full_name(), "initializer", initializer_null, - "initdefaultsname", GlobalInitDefaultsName(descriptor_->file()->name())); + "file_namespace", FileLevelNamespace(descriptor_->file()->name())); if (SupportsArenas(descriptor_)) { printer->Print( @@ -2102,7 +2104,7 @@ GenerateStructors(io::Printer* printer) { // When arenas are used it's safe to assume we have finished // static init time (protos with arenas are unsafe during static init) "#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER\n" - " $initdefaultsname$();\n" + " $file_namespace$::InitDefaults();\n" "#endif // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER\n" " SharedCtor();\n" " RegisterArenaDtor(arena);\n" @@ -2110,8 +2112,7 @@ GenerateStructors(io::Printer* printer) { "}\n", "initializer", initializer_with_arena, "classname", classname_, "superclass", superclass, "full_name", descriptor_->full_name(), - "initdefaultsname", - GlobalInitDefaultsName(descriptor_->file()->name())); + "file_namespace", FileLevelNamespace(descriptor_->file()->name())); } // Generate the copy constructor. @@ -2182,9 +2183,10 @@ GenerateStructors(io::Printer* printer) { IsMapEntryMessage(descriptor_->nested_type(i))) { printer->Print( "const ::google::protobuf::Descriptor*& $type$_descriptor = " - "file_level_metadata[$index$].descriptor;\n", + "$file_namespace$::file_level_metadata[$index$].descriptor;\n", "type", ClassName(descriptor_->nested_type(i), false), "index", - SimpleItoa(nested_generators_[i]->index_in_metadata_)); + SimpleItoa(nested_generators_[i]->index_in_metadata_), + "file_namespace", FileLevelNamespace(descriptor_->file()->name())); } } @@ -2265,20 +2267,21 @@ GenerateStructors(io::Printer* printer) { !descriptor_->options().no_standard_descriptor_accessor()) { printer->Print( "const ::google::protobuf::Descriptor* $classname$::descriptor() {\n" - " protobuf_AssignDescriptorsOnce();\n" - " return file_level_metadata[$index$].descriptor;\n" + " $file_namespace$::protobuf_AssignDescriptorsOnce();\n" + " return $file_namespace$::file_level_metadata[$index$].descriptor;\n" "}\n" "\n", - "index", SimpleItoa(index_in_metadata_), "classname", classname_); + "index", SimpleItoa(index_in_metadata_), "classname", classname_, + "file_namespace", FileLevelNamespace(descriptor_->file()->name())); } printer->Print( "const $classname$& $classname$::default_instance() {\n" - " $initdefaultsname$();\n" + " $file_namespace$::InitDefaults();\n" " return *internal_default_instance();\n" "}\n\n", - "classname", classname_, "initdefaultsname", - GlobalInitDefaultsName(descriptor_->file()->name())); + "classname", classname_, "file_namespace", + FileLevelNamespace(descriptor_->file()->name())); if (SupportsArenas(descriptor_)) { printer->Print( @@ -2630,7 +2633,7 @@ GenerateSwap(io::Printer* printer) { } if (HasFieldPresence(descriptor_->file())) { - for (int i = 0; i < (descriptor_->field_count() + 31) / 32; ++i) { + for (int i = 0; i < HasBitsSize() / 4; ++i) { printer->Print("std::swap(_has_bits_[$i$], other->_has_bits_[$i$]);\n", "i", SimpleItoa(i)); } @@ -3260,7 +3263,7 @@ void MessageGenerator::GenerateSerializeOneExtensionRange( if (to_array) { printer->Print(vars, "target = _extensions_.InternalSerializeWithCachedSizesToArray(\n" - " $start$, $end$, false, target);\n\n"); + " $start$, $end$, deterministic, target);\n\n"); } else { printer->Print(vars, "_extensions_.SerializeWithCachedSizes(\n" @@ -3335,7 +3338,7 @@ GenerateSerializeWithCachedSizesToArray(io::Printer* printer) { "classname", classname_); printer->Indent(); - printer->Print("(void)deterministic; // Unused\n"); + printer->Print("(void)deterministic; // Unused\n"); printer->Print( "// @@protoc_insertion_point(serialize_to_array_start:$full_name$)\n", "full_name", descriptor_->full_name()); diff --git a/src/google/protobuf/compiler/cpp/cpp_message.h b/src/google/protobuf/compiler/cpp/cpp_message.h index c5efff12..1a804a16 100644 --- a/src/google/protobuf/compiler/cpp/cpp_message.h +++ b/src/google/protobuf/compiler/cpp/cpp_message.h @@ -91,9 +91,8 @@ class MessageGenerator { // Source file stuff. - // Generate code which declares all the global descriptor pointers which - // will be initialized by the methods below. - void GenerateDescriptorDeclarations(io::Printer* printer); + // Generate extra fields + void GenerateExtraDefaultFields(io::Printer* printer); // Generate code that calls MessageFactory::InternalRegisterGeneratedMessage() // for all types. @@ -201,6 +200,7 @@ class MessageGenerator { // optimized_order_ excludes oneof fields. std::vector<const FieldDescriptor *> optimized_order_; std::vector<int> has_bit_indices_; + int max_has_bit_index_; google::protobuf::scoped_array<google::protobuf::scoped_ptr<MessageGenerator> > nested_generators_; google::protobuf::scoped_array<google::protobuf::scoped_ptr<EnumGenerator> > enum_generators_; google::protobuf::scoped_array<google::protobuf::scoped_ptr<ExtensionGenerator> > extension_generators_; diff --git a/src/google/protobuf/compiler/cpp/cpp_message_field.cc b/src/google/protobuf/compiler/cpp/cpp_message_field.cc index 91449657..c3d1745c 100644 --- a/src/google/protobuf/compiler/cpp/cpp_message_field.cc +++ b/src/google/protobuf/compiler/cpp/cpp_message_field.cc @@ -487,9 +487,6 @@ GenerateClearingCode(io::Printer* printer) const { void MessageFieldGenerator:: GenerateMessageClearingCode(io::Printer* printer) const { - std::map<string, string> variables(variables_); - variables["type"] = FieldMessageTypeName(descriptor_); - if (!HasFieldPresence(descriptor_->file())) { // If we don't have has-bits, message presence is indicated only by ptr != // NULL. Thus on clear, we need to delete the object. @@ -1035,7 +1032,6 @@ GenerateInlineAccessorDefinitions(io::Printer* printer, "}\n"); } - if (!dependent_field_) { printer->Print(variables, "$inline$" diff --git a/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc b/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc index 240a6e0a..a68891a3 100644 --- a/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc +++ b/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc @@ -245,7 +245,7 @@ void PrimitiveOneofFieldGenerator:: GenerateConstructorCode(io::Printer* printer) const { printer->Print( variables_, - " $classname$_default_oneof_instance_.$name$_ = $default$;\n"); + "_$classname$_default_instance_.$name$_ = $default$;\n"); } void PrimitiveOneofFieldGenerator:: @@ -373,6 +373,7 @@ GenerateMergeFromCodedStreamWithPacking(io::Printer* printer) const { void RepeatedPrimitiveFieldGenerator:: GenerateSerializeWithCachedSizes(io::Printer* printer) const { + bool array_written = false; if (descriptor_->is_packed()) { // Write the tag and the size. printer->Print(variables_, @@ -381,21 +382,30 @@ GenerateSerializeWithCachedSizes(io::Printer* printer) const { "$number$, " "::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED, " "output);\n" - " output->WriteVarint32(_$name$_cached_byte_size_);\n" - "}\n"); + " output->WriteVarint32(_$name$_cached_byte_size_);\n"); + + if (FixedSize(descriptor_->type()) > 0) { + printer->Print(variables_, + " ::google::protobuf::internal::WireFormatLite::Write$declared_type$Array(\n" + " this->$name$().data(), this->$name$_size(), output);\n"); + array_written = true; // Wrote array all at once + } + printer->Print(variables_, "}\n"); } - printer->Print(variables_, - "for (int i = 0; i < this->$name$_size(); i++) {\n"); - if (descriptor_->is_packed()) { + if (!array_written) { printer->Print(variables_, - " ::google::protobuf::internal::WireFormatLite::Write$declared_type$NoTag(\n" - " this->$name$(i), output);\n"); - } else { - printer->Print(variables_, - " ::google::protobuf::internal::WireFormatLite::Write$declared_type$(\n" - " $number$, this->$name$(i), output);\n"); + "for (int i = 0; i < this->$name$_size(); i++) {\n"); + if (descriptor_->is_packed()) { + printer->Print(variables_, + " ::google::protobuf::internal::WireFormatLite::Write$declared_type$NoTag(\n" + " this->$name$(i), output);\n"); + } else { + printer->Print(variables_, + " ::google::protobuf::internal::WireFormatLite::Write$declared_type$(\n" + " $number$, this->$name$(i), output);\n"); + } + printer->Print("}\n"); } - printer->Print("}\n"); } void RepeatedPrimitiveFieldGenerator:: @@ -428,21 +438,17 @@ GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const { void RepeatedPrimitiveFieldGenerator:: GenerateByteSize(io::Printer* printer) const { - printer->Print(variables_, - "{\n" - " size_t data_size = 0;\n" - " unsigned int count = this->$name$_size();\n"); + printer->Print(variables_, "{\n"); printer->Indent(); int fixed_size = FixedSize(descriptor_->type()); if (fixed_size == -1) { printer->Print(variables_, - "for (unsigned int i = 0; i < count; i++) {\n" - " data_size += ::google::protobuf::internal::WireFormatLite::\n" - " $declared_type$Size(this->$name$(i));\n" - "}\n"); + "size_t data_size = ::google::protobuf::internal::WireFormatLite::\n" + " $declared_type$Size(this->$name$_);\n"); } else { printer->Print(variables_, - "data_size = $fixed_size$UL * count;\n"); + "unsigned int count = this->$name$_size();\n" + "size_t data_size = $fixed_size$UL * count;\n"); } if (descriptor_->is_packed()) { diff --git a/src/google/protobuf/compiler/cpp/cpp_service.cc b/src/google/protobuf/compiler/cpp/cpp_service.cc index d6b1ddc5..95357d9f 100644 --- a/src/google/protobuf/compiler/cpp/cpp_service.cc +++ b/src/google/protobuf/compiler/cpp/cpp_service.cc @@ -46,6 +46,7 @@ ServiceGenerator::ServiceGenerator(const ServiceDescriptor* descriptor, const Options& options) : descriptor_(descriptor) { vars_["classname"] = descriptor_->name(); + vars_["file_namespace"] = FileLevelNamespace(descriptor_->file()->name()); vars_["full_name"] = descriptor_->full_name(); if (options.dllexport_decl.empty()) { vars_["dllexport"] = ""; @@ -178,8 +179,8 @@ void ServiceGenerator::GenerateImplementation(io::Printer* printer) { "$classname$::~$classname$() {}\n" "\n" "const ::google::protobuf::ServiceDescriptor* $classname$::descriptor() {\n" - " protobuf_AssignDescriptorsOnce();\n" - " return file_level_service_descriptors[$index$];\n" + " $file_namespace$::protobuf_AssignDescriptorsOnce();\n" + " return $file_namespace$::file_level_service_descriptors[$index$];\n" "}\n" "\n" "const ::google::protobuf::ServiceDescriptor* $classname$::GetDescriptor() {\n" @@ -241,7 +242,7 @@ void ServiceGenerator::GenerateCallMethod(io::Printer* printer) { " ::google::protobuf::Message* response,\n" " ::google::protobuf::Closure* done) {\n" " GOOGLE_DCHECK_EQ(method->service(), " - "file_level_service_descriptors[$index$]);\n" + "$file_namespace$::file_level_service_descriptors[$index$]);\n" " switch(method->index()) {\n"); for (int i = 0; i < descriptor_->method_count(); i++) { diff --git a/src/google/protobuf/compiler/cpp/cpp_string_field.cc b/src/google/protobuf/compiler/cpp/cpp_string_field.cc index 2874de7d..359e5e26 100644 --- a/src/google/protobuf/compiler/cpp/cpp_string_field.cc +++ b/src/google/protobuf/compiler/cpp/cpp_string_field.cc @@ -762,7 +762,7 @@ void StringOneofFieldGenerator:: GenerateConstructorCode(io::Printer* printer) const { printer->Print( variables_, - "$classname$_default_oneof_instance_.$name$_.UnsafeSetDefault(\n" + "_$classname$_default_instance_.$name$_.UnsafeSetDefault(\n" " $default_variable$);\n"); } @@ -838,9 +838,7 @@ GenerateAccessorDeclarations(io::Printer* printer) const { "$deprecated_attr$void add_$name$(const ::std::string& value);\n" "$deprecated_attr$void add_$name$(const char* value);\n" "$deprecated_attr$void add_$name$(const $pointer_type$* value, size_t size)" - ";\n"); - - printer->Print(variables_, + ";\n" "$deprecated_attr$const ::google::protobuf::RepeatedPtrField< ::std::string>& $name$() " "const;\n" "$deprecated_attr$::google::protobuf::RepeatedPtrField< ::std::string>* mutable_$name$()" @@ -898,8 +896,7 @@ GenerateInlineAccessorDefinitions(io::Printer* printer, "$classname$::add_$name$(const $pointer_type$* value, size_t size) {\n" " $name$_.Add()->assign(reinterpret_cast<const char*>(value), size);\n" " // @@protoc_insertion_point(field_add_pointer:$full_name$)\n" - "}\n"); - printer->Print(variables, + "}\n" "$inline$const ::google::protobuf::RepeatedPtrField< ::std::string>&\n" "$classname$::$name$() const {\n" " // @@protoc_insertion_point(field_list:$full_name$)\n" 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 f1dc47fc..50eed5da 100644 --- a/src/google/protobuf/compiler/java/java_enum_field_lite.cc +++ b/src/google/protobuf/compiler/java/java_enum_field_lite.cc @@ -76,6 +76,7 @@ void SetEnumVariables(const FieldDescriptor* descriptor, // by the proto compiler (*variables)["deprecation"] = descriptor->options().deprecated() ? "@java.lang.Deprecated " : ""; + (*variables)["required"] = descriptor->is_required() ? "true" : "false"; if (SupportFieldPresence(descriptor->file())) { // For singular messages and builders, one bit is used for the hasField bit. 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 fd78f75a..0957676c 100644 --- a/src/google/protobuf/compiler/java/java_message_field_lite.cc +++ b/src/google/protobuf/compiler/java/java_message_field_lite.cc @@ -70,6 +70,7 @@ void SetMessageVariables(const FieldDescriptor* descriptor, // by the proto compiler (*variables)["deprecation"] = descriptor->options().deprecated() ? "@java.lang.Deprecated " : ""; + (*variables)["required"] = descriptor->is_required() ? "true" : "false"; if (SupportFieldPresence(descriptor->file())) { // For singular messages and builders, one bit is used for the hasField bit. diff --git a/src/google/protobuf/compiler/java/java_message_lite.cc b/src/google/protobuf/compiler/java/java_message_lite.cc index 8cc0f01d..048d5892 100644 --- a/src/google/protobuf/compiler/java/java_message_lite.cc +++ b/src/google/protobuf/compiler/java/java_message_lite.cc @@ -928,10 +928,10 @@ void ImmutableMessageLiteGenerator::GenerateDynamicMethodMergeFromStream( "com.google.protobuf.CodedInputStream input =\n" " (com.google.protobuf.CodedInputStream) arg0;\n" "com.google.protobuf.ExtensionRegistryLite extensionRegistry =\n" - " (com.google.protobuf.ExtensionRegistryLite) arg1;\n" + " (com.google.protobuf.ExtensionRegistryLite) arg1;\n"); + printer->Print( "try {\n"); printer->Indent(); - printer->Print( "boolean done = false;\n" "while (!done) {\n"); 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 ac39f4cf..b04bf1c2 100644 --- a/src/google/protobuf/compiler/java/java_primitive_field_lite.cc +++ b/src/google/protobuf/compiler/java/java_primitive_field_lite.cc @@ -74,6 +74,7 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor, SimpleItoa(static_cast<int32>(WireFormat::MakeTag(descriptor))); (*variables)["tag_size"] = SimpleItoa( WireFormat::TagSize(descriptor->number(), GetType(descriptor))); + (*variables)["required"] = descriptor->is_required() ? "true" : "false"; string capitalized_type = UnderscoresToCamelCase(PrimitiveTypeName(javaType), true /* cap_next_letter */); diff --git a/src/google/protobuf/compiler/java/java_shared_code_generator.cc b/src/google/protobuf/compiler/java/java_shared_code_generator.cc index 5fe68245..7bd5ad7a 100644 --- a/src/google/protobuf/compiler/java/java_shared_code_generator.cc +++ b/src/google/protobuf/compiler/java/java_shared_code_generator.cc @@ -181,13 +181,11 @@ void SharedCodeGenerator::GenerateDescriptors(io::Printer* printer) { // Find out all dependencies. std::vector<std::pair<string, string> > dependencies; for (int i = 0; i < file_->dependency_count(); i++) { - if (ShouldIncludeDependency(file_->dependency(i))) { - string filename = file_->dependency(i)->name(); - string classname = FileJavaPackage(file_->dependency(i)) + "." + - name_resolver_->GetDescriptorClassName( - file_->dependency(i)); - dependencies.push_back(std::make_pair(filename, classname)); - } + string filename = file_->dependency(i)->name(); + string classname = FileJavaPackage(file_->dependency(i)) + "." + + name_resolver_->GetDescriptorClassName( + file_->dependency(i)); + dependencies.push_back(std::make_pair(filename, classname)); } // ----------------------------------------------------------------- @@ -209,11 +207,6 @@ void SharedCodeGenerator::GenerateDescriptors(io::Printer* printer) { " }, assigner);\n"); } -bool SharedCodeGenerator::ShouldIncludeDependency( - const FileDescriptor* descriptor) { - return true; -} - } // namespace java } // namespace compiler } // namespace protobuf diff --git a/src/google/protobuf/compiler/java/java_shared_code_generator.h b/src/google/protobuf/compiler/java/java_shared_code_generator.h index c8ead47a..40502270 100644 --- a/src/google/protobuf/compiler/java/java_shared_code_generator.h +++ b/src/google/protobuf/compiler/java/java_shared_code_generator.h @@ -77,11 +77,6 @@ class SharedCodeGenerator { void GenerateDescriptors(io::Printer* printer); private: - // Returns whether the dependency should be included in the output file. - // Always returns true for opensource, but used internally at Google to help - // improve compatibility with version 1 of protocol buffers. - bool ShouldIncludeDependency(const FileDescriptor* descriptor); - google::protobuf::scoped_ptr<ClassNameResolver> name_resolver_; const FileDescriptor* file_; const Options options_; 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 4d2dcad8..138e59b6 100644 --- a/src/google/protobuf/compiler/java/java_string_field_lite.cc +++ b/src/google/protobuf/compiler/java/java_string_field_lite.cc @@ -85,6 +85,7 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor, // by the proto compiler (*variables)["deprecation"] = descriptor->options().deprecated() ? "@java.lang.Deprecated " : ""; + (*variables)["required"] = descriptor->is_required() ? "true" : "false"; if (SupportFieldPresence(descriptor->file())) { // For singular messages and builders, one bit is used for the hasField bit. diff --git a/src/google/protobuf/compiler/parser.cc b/src/google/protobuf/compiler/parser.cc index 09c7a2b6..7a03d42b 100644 --- a/src/google/protobuf/compiler/parser.cc +++ b/src/google/protobuf/compiler/parser.cc @@ -249,11 +249,11 @@ bool Parser::ConsumeNumber(double* output, const char* error) { input_->Next(); return true; } else if (LookingAt("inf")) { - *output = numeric_limits<double>::infinity(); + *output = std::numeric_limits<double>::infinity(); input_->Next(); return true; } else if (LookingAt("nan")) { - *output = numeric_limits<double>::quiet_NaN(); + *output = std::numeric_limits<double>::quiet_NaN(); input_->Next(); return true; } else { @@ -282,7 +282,7 @@ bool Parser::TryConsumeEndOfDeclaration( const char* text, const LocationRecorder* location) { if (LookingAt(text)) { string leading, trailing; - vector<string> detached; + std::vector<string> detached; input_->NextWithComments(&trailing, &detached, &leading); // Save the leading comments for next time, and recall the leading comments @@ -404,7 +404,7 @@ void Parser::LocationRecorder::RecordLegacyLocation(const Message* descriptor, void Parser::LocationRecorder::AttachComments( string* leading, string* trailing, - vector<string>* detached_comments) const { + std::vector<string>* detached_comments) const { GOOGLE_CHECK(!location_->has_leading_comments()); GOOGLE_CHECK(!location_->has_trailing_comments()); @@ -487,7 +487,7 @@ bool Parser::ValidateEnum(const EnumDescriptorProto* proto) { return false; } - set<int> used_values; + std::set<int> used_values; bool has_duplicates = false; for (int i = 0; i < proto->value_size(); ++i) { const EnumValueDescriptorProto enum_value = proto->value(i); @@ -2089,7 +2089,7 @@ bool SourceLocationTable::Find( const Message* descriptor, DescriptorPool::ErrorCollector::ErrorLocation location, int* line, int* column) const { - const pair<int, int>* result = + const std::pair<int, int>* result = FindOrNull(location_map_, std::make_pair(descriptor, location)); if (result == NULL) { *line = -1; diff --git a/src/google/protobuf/compiler/php/php_generator.cc b/src/google/protobuf/compiler/php/php_generator.cc index 36f00acd..ec9a2365 100644 --- a/src/google/protobuf/compiler/php/php_generator.cc +++ b/src/google/protobuf/compiler/php/php_generator.cc @@ -757,12 +757,15 @@ void GenerateEnumFile(const FileDescriptor* file, const EnumDescriptor* en, std::string fullname = FilenameToClassname(filename); int lastindex = fullname.find_last_of("\\"); - GenerateEnumDocComment(&printer, en); - if (lastindex != string::npos) { + if (!file->package().empty()) { printer.Print( "namespace ^name^;\n\n", "name", fullname.substr(0, lastindex)); + } + GenerateEnumDocComment(&printer, en); + + if (lastindex != string::npos) { printer.Print( "class ^name^\n" "{\n", diff --git a/src/google/protobuf/compiler/plugin.pb.cc b/src/google/protobuf/compiler/plugin.pb.cc index 6edb5e76..ac27c412 100644 --- a/src/google/protobuf/compiler/plugin.pb.cc +++ b/src/google/protobuf/compiler/plugin.pb.cc @@ -20,14 +20,17 @@ namespace google { namespace protobuf { namespace compiler { -class VersionDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Version> {}; -VersionDefaultTypeInternal _Version_default_instance_; -class CodeGeneratorRequestDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<CodeGeneratorRequest> {}; -CodeGeneratorRequestDefaultTypeInternal _CodeGeneratorRequest_default_instance_; -class CodeGeneratorResponse_FileDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<CodeGeneratorResponse_File> {}; -CodeGeneratorResponse_FileDefaultTypeInternal _CodeGeneratorResponse_File_default_instance_; -class CodeGeneratorResponseDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<CodeGeneratorResponse> {}; -CodeGeneratorResponseDefaultTypeInternal _CodeGeneratorResponse_default_instance_; +class VersionDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<Version> { +} _Version_default_instance_; +class CodeGeneratorRequestDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<CodeGeneratorRequest> { +} _CodeGeneratorRequest_default_instance_; +class CodeGeneratorResponse_FileDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<CodeGeneratorResponse_File> { +} _CodeGeneratorResponse_File_default_instance_; +class CodeGeneratorResponseDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed<CodeGeneratorResponse> { +} _CodeGeneratorResponse_default_instance_; + +namespace protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto { + namespace { @@ -35,55 +38,50 @@ namespace { } // namespace - -const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fcompiler_2fplugin_2eproto() GOOGLE_ATTRIBUTE_COLD; -const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fcompiler_2fplugin_2eproto() { - static const ::google::protobuf::uint32 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_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Version, major_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Version, minor_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Version, patch_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Version, suffix_), - 1, - 2, - 3, - 0, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, _has_bits_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - 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_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, compiler_version_), - 2, - 0, - 3, - 1, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse_File, _has_bits_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse_File, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - 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_), - 0, - 1, - 2, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse, _has_bits_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse, error_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse, file_), - 0, - 1, - }; - return offsets; -} +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_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Version, major_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Version, minor_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Version, patch_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Version, suffix_), + 1, + 2, + 3, + 0, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + 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_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, compiler_version_), + ~0u, + 0, + ~0u, + 1, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse_File, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse_File, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + 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_), + 0, + 1, + 2, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse, _has_bits_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse, error_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse, file_), + 0, + ~0u, +}; static const ::google::protobuf::internal::MigrationSchema schemas[] = { { 0, 8, sizeof(Version)}, @@ -92,20 +90,20 @@ static const ::google::protobuf::internal::MigrationSchema schemas[] = { { 34, 40, sizeof(CodeGeneratorResponse)}, }; -static const ::google::protobuf::internal::DefaultInstanceData file_default_instances[] = { - {reinterpret_cast<const ::google::protobuf::Message*>(&_Version_default_instance_), NULL}, - {reinterpret_cast<const ::google::protobuf::Message*>(&_CodeGeneratorRequest_default_instance_), NULL}, - {reinterpret_cast<const ::google::protobuf::Message*>(&_CodeGeneratorResponse_File_default_instance_), NULL}, - {reinterpret_cast<const ::google::protobuf::Message*>(&_CodeGeneratorResponse_default_instance_), NULL}, +static ::google::protobuf::Message const * const file_default_instances[] = { + reinterpret_cast<const ::google::protobuf::Message*>(&_Version_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&_CodeGeneratorRequest_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&_CodeGeneratorResponse_File_default_instance_), + reinterpret_cast<const ::google::protobuf::Message*>(&_CodeGeneratorResponse_default_instance_), }; namespace { void protobuf_AssignDescriptors() { - protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); + AddDescriptors(); ::google::protobuf::MessageFactory* factory = NULL; AssignDescriptors( - "google/protobuf/compiler/plugin.proto", schemas, file_default_instances, protobuf_Offsets_google_2fprotobuf_2fcompiler_2fplugin_2eproto(), factory, + "google/protobuf/compiler/plugin.proto", schemas, file_default_instances, TableStruct::offsets, factory, file_level_metadata, NULL, NULL); } @@ -122,7 +120,7 @@ void protobuf_RegisterTypes(const ::std::string&) { } // namespace -void protobuf_ShutdownFile_google_2fprotobuf_2fcompiler_2fplugin_2eproto() { +void TableStruct::Shutdown() { _Version_default_instance_.Shutdown(); delete file_level_metadata[0].reflection; _CodeGeneratorRequest_default_instance_.Shutdown(); @@ -133,11 +131,11 @@ void protobuf_ShutdownFile_google_2fprotobuf_2fcompiler_2fplugin_2eproto() { delete file_level_metadata[3].reflection; } -void protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl() { +void TableStruct::InitDefaultsImpl() { GOOGLE_PROTOBUF_VERIFY_VERSION; - ::google::protobuf::protobuf_InitDefaults_google_2fprotobuf_2fdescriptor_2eproto(); ::google::protobuf::internal::InitProtobufDefaults(); + ::google::protobuf::protobuf_google_2fprotobuf_2fdescriptor_2eproto::InitDefaults(); _Version_default_instance_.DefaultConstruct(); _CodeGeneratorRequest_default_instance_.DefaultConstruct(); _CodeGeneratorResponse_File_default_instance_.DefaultConstruct(); @@ -146,12 +144,12 @@ void protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl() ::google::protobuf::compiler::Version::internal_default_instance()); } -void protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto() { +void InitDefaults() { static GOOGLE_PROTOBUF_DECLARE_ONCE(once); - ::google::protobuf::GoogleOnceInit(&once, &protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl); + ::google::protobuf::GoogleOnceInit(&once, &TableStruct::InitDefaultsImpl); } -void protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl() { - protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); +void AddDescriptorsImpl() { + InitDefaults(); static const char descriptor[] = { "\n%google/protobuf/compiler/plugin.proto\022" "\030google.protobuf.compiler\032 google/protob" @@ -173,21 +171,23 @@ void protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl() { descriptor, 590); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/protobuf/compiler/plugin.proto", &protobuf_RegisterTypes); - ::google::protobuf::protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto(); - ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fcompiler_2fplugin_2eproto); + ::google::protobuf::protobuf_google_2fprotobuf_2fdescriptor_2eproto::AddDescriptors(); + ::google::protobuf::internal::OnShutdown(&TableStruct::Shutdown); } -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once_); -void protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto() { - ::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once_, - &protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl); +void AddDescriptors() { + static GOOGLE_PROTOBUF_DECLARE_ONCE(once); + ::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl); } // Force AddDescriptors() to be called at static initialization time. -struct StaticDescriptorInitializer_google_2fprotobuf_2fcompiler_2fplugin_2eproto { - StaticDescriptorInitializer_google_2fprotobuf_2fcompiler_2fplugin_2eproto() { - protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); +struct StaticDescriptorInitializer { + StaticDescriptorInitializer() { + AddDescriptors(); } -} static_descriptor_initializer_google_2fprotobuf_2fcompiler_2fplugin_2eproto_; +} static_descriptor_initializer; + +} // namespace protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto + // =================================================================== @@ -201,7 +201,7 @@ const int Version::kSuffixFieldNumber; Version::Version() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { - protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); + protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::InitDefaults(); } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.compiler.Version) @@ -244,12 +244,12 @@ void Version::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* Version::descriptor() { - protobuf_AssignDescriptorsOnce(); - return file_level_metadata[0].descriptor; + protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::file_level_metadata[0].descriptor; } const Version& Version::default_instance() { - protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); + protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::InitDefaults(); return *internal_default_instance(); } @@ -398,7 +398,7 @@ void Version::SerializeWithCachedSizes( ::google::protobuf::uint8* Version::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { - (void)deterministic; // Unused + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.compiler.Version) // optional int32 major = 1; if (has_major()) { @@ -549,8 +549,8 @@ void Version::InternalSwap(Version* other) { } ::google::protobuf::Metadata Version::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); - return file_level_metadata[0]; + protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::file_level_metadata[0]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS @@ -704,7 +704,7 @@ const int CodeGeneratorRequest::kCompilerVersionFieldNumber; CodeGeneratorRequest::CodeGeneratorRequest() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { - protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); + protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::InitDefaults(); } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.compiler.CodeGeneratorRequest) @@ -753,12 +753,12 @@ void CodeGeneratorRequest::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* CodeGeneratorRequest::descriptor() { - protobuf_AssignDescriptorsOnce(); - return file_level_metadata[1].descriptor; + protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::file_level_metadata[1].descriptor; } const CodeGeneratorRequest& CodeGeneratorRequest::default_instance() { - protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); + protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::InitDefaults(); return *internal_default_instance(); } @@ -919,7 +919,7 @@ void CodeGeneratorRequest::SerializeWithCachedSizes( ::google::protobuf::uint8* CodeGeneratorRequest::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { - (void)deterministic; // Unused + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.compiler.CodeGeneratorRequest) // repeated string file_to_generate = 1; for (int i = 0; i < this->file_to_generate_size(); i++) { @@ -1081,8 +1081,8 @@ void CodeGeneratorRequest::InternalSwap(CodeGeneratorRequest* other) { } ::google::protobuf::Metadata CodeGeneratorRequest::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); - return file_level_metadata[1]; + protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::file_level_metadata[1]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS @@ -1293,7 +1293,7 @@ const int CodeGeneratorResponse_File::kContentFieldNumber; CodeGeneratorResponse_File::CodeGeneratorResponse_File() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { - protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); + protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::InitDefaults(); } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.compiler.CodeGeneratorResponse.File) @@ -1343,12 +1343,12 @@ void CodeGeneratorResponse_File::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* CodeGeneratorResponse_File::descriptor() { - protobuf_AssignDescriptorsOnce(); - return file_level_metadata[2].descriptor; + protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::file_level_metadata[2].descriptor; } const CodeGeneratorResponse_File& CodeGeneratorResponse_File::default_instance() { - protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); + protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::InitDefaults(); return *internal_default_instance(); } @@ -1499,7 +1499,7 @@ void CodeGeneratorResponse_File::SerializeWithCachedSizes( ::google::protobuf::uint8* CodeGeneratorResponse_File::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { - (void)deterministic; // Unused + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.compiler.CodeGeneratorResponse.File) // optional string name = 1; if (has_name()) { @@ -1648,8 +1648,8 @@ void CodeGeneratorResponse_File::InternalSwap(CodeGeneratorResponse_File* other) } ::google::protobuf::Metadata CodeGeneratorResponse_File::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); - return file_level_metadata[2]; + protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::file_level_metadata[2]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS @@ -1853,7 +1853,7 @@ const int CodeGeneratorResponse::kFileFieldNumber; CodeGeneratorResponse::CodeGeneratorResponse() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { - protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); + protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::InitDefaults(); } SharedCtor(); // @@protoc_insertion_point(constructor:google.protobuf.compiler.CodeGeneratorResponse) @@ -1892,12 +1892,12 @@ void CodeGeneratorResponse::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* CodeGeneratorResponse::descriptor() { - protobuf_AssignDescriptorsOnce(); - return file_level_metadata[3].descriptor; + protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::file_level_metadata[3].descriptor; } const CodeGeneratorResponse& CodeGeneratorResponse::default_instance() { - protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); + protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::InitDefaults(); return *internal_default_instance(); } @@ -2008,7 +2008,7 @@ void CodeGeneratorResponse::SerializeWithCachedSizes( ::google::protobuf::uint8* CodeGeneratorResponse::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { - (void)deterministic; // Unused + (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.compiler.CodeGeneratorResponse) // optional string error = 1; if (has_error()) { @@ -2127,8 +2127,8 @@ void CodeGeneratorResponse::InternalSwap(CodeGeneratorResponse* other) { } ::google::protobuf::Metadata CodeGeneratorResponse::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); - return file_level_metadata[3]; + protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::protobuf_AssignDescriptorsOnce(); + return protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::file_level_metadata[3]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS diff --git a/src/google/protobuf/compiler/plugin.pb.h b/src/google/protobuf/compiler/plugin.pb.h index 0c29b959..8465f0bd 100644 --- a/src/google/protobuf/compiler/plugin.pb.h +++ b/src/google/protobuf/compiler/plugin.pb.h @@ -8,17 +8,18 @@ #include <google/protobuf/stubs/common.h> -#if GOOGLE_PROTOBUF_VERSION < 3001000 +#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 3001000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION +#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_util.h> @@ -127,9 +128,16 @@ namespace google { namespace protobuf { namespace compiler { +namespace protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto { // Internal implementation detail -- do not call these. -void LIBPROTOC_EXPORT protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); -void LIBPROTOC_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); +struct LIBPROTOC_EXPORT TableStruct { + 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_2fplugin_2eproto // =================================================================== @@ -184,7 +192,8 @@ class LIBPROTOC_EXPORT Version : public ::google::protobuf::Message /* @@protoc_ bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const PROTOBUF_FINAL { - return InternalSerializeWithCachedSizesToArray(false, output); + return InternalSerializeWithCachedSizesToArray( + ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output); } int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: @@ -207,6 +216,21 @@ class LIBPROTOC_EXPORT Version : public ::google::protobuf::Message /* @@protoc_ // accessors ------------------------------------------------------- + // optional string suffix = 4; + bool has_suffix() const; + void clear_suffix(); + static const int kSuffixFieldNumber = 4; + const ::std::string& suffix() const; + void set_suffix(const ::std::string& value); + #if LANG_CXX11 + void set_suffix(::std::string&& value); + #endif + void set_suffix(const char* value); + void set_suffix(const char* value, size_t size); + ::std::string* mutable_suffix(); + ::std::string* release_suffix(); + void set_allocated_suffix(::std::string* suffix); + // optional int32 major = 1; bool has_major() const; void clear_major(); @@ -228,21 +252,6 @@ class LIBPROTOC_EXPORT Version : public ::google::protobuf::Message /* @@protoc_ ::google::protobuf::int32 patch() const; void set_patch(::google::protobuf::int32 value); - // optional string suffix = 4; - bool has_suffix() const; - void clear_suffix(); - static const int kSuffixFieldNumber = 4; - const ::std::string& suffix() const; - void set_suffix(const ::std::string& value); - #if LANG_CXX11 - void set_suffix(::std::string&& value); - #endif - void set_suffix(const char* value); - void set_suffix(const char* value, size_t size); - ::std::string* mutable_suffix(); - ::std::string* release_suffix(); - void set_allocated_suffix(::std::string* suffix); - // @@protoc_insertion_point(class_scope:google.protobuf.compiler.Version) private: void set_has_major(); @@ -261,11 +270,7 @@ class LIBPROTOC_EXPORT Version : public ::google::protobuf::Message /* @@protoc_ ::google::protobuf::int32 major_; ::google::protobuf::int32 minor_; ::google::protobuf::int32 patch_; - friend void LIBPROTOC_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl(); - friend void LIBPROTOC_EXPORT protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl(); - friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); - friend void protobuf_ShutdownFile_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); - + friend struct LIBPROTOC_EXPORT protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::TableStruct; }; // ------------------------------------------------------------------- @@ -320,7 +325,8 @@ class LIBPROTOC_EXPORT CodeGeneratorRequest : public ::google::protobuf::Message bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const PROTOBUF_FINAL { - return InternalSerializeWithCachedSizesToArray(false, output); + return InternalSerializeWithCachedSizesToArray( + ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output); } int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: @@ -359,6 +365,18 @@ class LIBPROTOC_EXPORT CodeGeneratorRequest : public ::google::protobuf::Message const ::google::protobuf::RepeatedPtrField< ::std::string>& file_to_generate() const; ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_file_to_generate(); + // repeated .google.protobuf.FileDescriptorProto proto_file = 15; + int proto_file_size() const; + void clear_proto_file(); + static const int kProtoFileFieldNumber = 15; + const ::google::protobuf::FileDescriptorProto& proto_file(int index) const; + ::google::protobuf::FileDescriptorProto* mutable_proto_file(int index); + ::google::protobuf::FileDescriptorProto* add_proto_file(); + ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto >* + mutable_proto_file(); + const ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto >& + proto_file() const; + // optional string parameter = 2; bool has_parameter() const; void clear_parameter(); @@ -374,18 +392,6 @@ class LIBPROTOC_EXPORT CodeGeneratorRequest : public ::google::protobuf::Message ::std::string* release_parameter(); void set_allocated_parameter(::std::string* parameter); - // repeated .google.protobuf.FileDescriptorProto proto_file = 15; - int proto_file_size() const; - void clear_proto_file(); - static const int kProtoFileFieldNumber = 15; - const ::google::protobuf::FileDescriptorProto& proto_file(int index) const; - ::google::protobuf::FileDescriptorProto* mutable_proto_file(int index); - ::google::protobuf::FileDescriptorProto* add_proto_file(); - ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto >* - mutable_proto_file(); - const ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto >& - proto_file() const; - // optional .google.protobuf.compiler.Version compiler_version = 3; bool has_compiler_version() const; void clear_compiler_version(); @@ -409,11 +415,7 @@ class LIBPROTOC_EXPORT CodeGeneratorRequest : public ::google::protobuf::Message ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto > proto_file_; ::google::protobuf::internal::ArenaStringPtr parameter_; ::google::protobuf::compiler::Version* compiler_version_; - friend void LIBPROTOC_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl(); - friend void LIBPROTOC_EXPORT protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl(); - friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); - friend void protobuf_ShutdownFile_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); - + friend struct LIBPROTOC_EXPORT protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::TableStruct; }; // ------------------------------------------------------------------- @@ -468,7 +470,8 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse_File : public ::google::protobuf::M bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const PROTOBUF_FINAL { - return InternalSerializeWithCachedSizesToArray(false, output); + return InternalSerializeWithCachedSizesToArray( + ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output); } int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: @@ -551,11 +554,7 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse_File : public ::google::protobuf::M ::google::protobuf::internal::ArenaStringPtr name_; ::google::protobuf::internal::ArenaStringPtr insertion_point_; ::google::protobuf::internal::ArenaStringPtr content_; - friend void LIBPROTOC_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl(); - friend void LIBPROTOC_EXPORT protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl(); - friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); - friend void protobuf_ShutdownFile_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); - + friend struct LIBPROTOC_EXPORT protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::TableStruct; }; // ------------------------------------------------------------------- @@ -610,7 +609,8 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse : public ::google::protobuf::Messag bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const PROTOBUF_FINAL { - return InternalSerializeWithCachedSizesToArray(false, output); + return InternalSerializeWithCachedSizesToArray( + ::google::protobuf::io::CodedOutputStream::IsDefaultSerializationDeterministic(), output); } int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: @@ -635,6 +635,18 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse : public ::google::protobuf::Messag // accessors ------------------------------------------------------- + // repeated .google.protobuf.compiler.CodeGeneratorResponse.File file = 15; + int file_size() const; + void clear_file(); + static const int kFileFieldNumber = 15; + const ::google::protobuf::compiler::CodeGeneratorResponse_File& file(int index) const; + ::google::protobuf::compiler::CodeGeneratorResponse_File* mutable_file(int index); + ::google::protobuf::compiler::CodeGeneratorResponse_File* add_file(); + ::google::protobuf::RepeatedPtrField< ::google::protobuf::compiler::CodeGeneratorResponse_File >* + mutable_file(); + const ::google::protobuf::RepeatedPtrField< ::google::protobuf::compiler::CodeGeneratorResponse_File >& + file() const; + // optional string error = 1; bool has_error() const; void clear_error(); @@ -650,18 +662,6 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse : public ::google::protobuf::Messag ::std::string* release_error(); void set_allocated_error(::std::string* error); - // repeated .google.protobuf.compiler.CodeGeneratorResponse.File file = 15; - int file_size() const; - void clear_file(); - static const int kFileFieldNumber = 15; - const ::google::protobuf::compiler::CodeGeneratorResponse_File& file(int index) const; - ::google::protobuf::compiler::CodeGeneratorResponse_File* mutable_file(int index); - ::google::protobuf::compiler::CodeGeneratorResponse_File* add_file(); - ::google::protobuf::RepeatedPtrField< ::google::protobuf::compiler::CodeGeneratorResponse_File >* - mutable_file(); - const ::google::protobuf::RepeatedPtrField< ::google::protobuf::compiler::CodeGeneratorResponse_File >& - file() const; - // @@protoc_insertion_point(class_scope:google.protobuf.compiler.CodeGeneratorResponse) private: void set_has_error(); @@ -672,11 +672,7 @@ class LIBPROTOC_EXPORT CodeGeneratorResponse : public ::google::protobuf::Messag mutable int _cached_size_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::compiler::CodeGeneratorResponse_File > file_; ::google::protobuf::internal::ArenaStringPtr error_; - friend void LIBPROTOC_EXPORT protobuf_InitDefaults_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl(); - friend void LIBPROTOC_EXPORT protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto_impl(); - friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); - friend void protobuf_ShutdownFile_google_2fprotobuf_2fcompiler_2fplugin_2eproto(); - + friend struct LIBPROTOC_EXPORT protobuf_google_2fprotobuf_2fcompiler_2fplugin_2eproto::TableStruct; }; // =================================================================== |