diff options
author | orivej <orivej@yandex-team.ru> | 2022-02-10 16:45:01 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:01 +0300 |
commit | 2d37894b1b037cf24231090eda8589bbb44fb6fc (patch) | |
tree | be835aa92c6248212e705f25388ebafcf84bc7a1 /contrib/libs/protoc/src/google/protobuf/compiler | |
parent | 718c552901d703c502ccbefdfc3c9028d608b947 (diff) | |
download | ydb-2d37894b1b037cf24231090eda8589bbb44fb6fc.tar.gz |
Restoring authorship annotation for <orivej@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/libs/protoc/src/google/protobuf/compiler')
70 files changed, 2796 insertions, 2796 deletions
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/code_generator.cc b/contrib/libs/protoc/src/google/protobuf/compiler/code_generator.cc index f537fd45db..9ad4d14ef1 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/code_generator.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/code_generator.cc @@ -45,33 +45,33 @@ namespace protobuf { namespace compiler { CodeGenerator::~CodeGenerator() {} - + bool CodeGenerator::GenerateAll(const std::vector<const FileDescriptor*>& files, const TProtoStringType& parameter, GeneratorContext* generator_context, TProtoStringType* error) const { // Default implementation is just to call the per file method, and prefix any - // error string with the file to provide context. - bool succeeded = true; - for (int i = 0; i < files.size(); i++) { - const FileDescriptor* file = files[i]; - succeeded = Generate(file, parameter, generator_context, error); - if (!succeeded && error && error->empty()) { + // error string with the file to provide context. + bool succeeded = true; + for (int i = 0; i < files.size(); i++) { + const FileDescriptor* file = files[i]; + succeeded = Generate(file, parameter, generator_context, error); + if (!succeeded && error && error->empty()) { *error = "Code generator returned false but provided no error " "description."; - } - if (error && !error->empty()) { - *error = file->name() + ": " + *error; - break; - } - if (!succeeded) { - break; - } - } - return succeeded; -} - + } + if (error && !error->empty()) { + *error = file->name() + ": " + *error; + break; + } + if (!succeeded) { + break; + } + } + return succeeded; +} + GeneratorContext::~GeneratorContext() {} io::ZeroCopyOutputStream* GeneratorContext::OpenForAppend( @@ -96,13 +96,13 @@ void GeneratorContext::ListParsedFiles( GOOGLE_LOG(FATAL) << "This GeneratorContext does not support ListParsedFiles"; } -void GeneratorContext::GetCompilerVersion(Version* version) const { - version->set_major(GOOGLE_PROTOBUF_VERSION / 1000000); - version->set_minor(GOOGLE_PROTOBUF_VERSION / 1000 % 1000); - version->set_patch(GOOGLE_PROTOBUF_VERSION % 1000); - version->set_suffix(GOOGLE_PROTOBUF_VERSION_SUFFIX); -} - +void GeneratorContext::GetCompilerVersion(Version* version) const { + version->set_major(GOOGLE_PROTOBUF_VERSION / 1000000); + version->set_minor(GOOGLE_PROTOBUF_VERSION / 1000 % 1000); + version->set_patch(GOOGLE_PROTOBUF_VERSION % 1000); + version->set_suffix(GOOGLE_PROTOBUF_VERSION_SUFFIX); +} + // Parses a set of comma-delimited name/value pairs. void ParseGeneratorParameter( const TProtoStringType& text, diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/code_generator.h b/contrib/libs/protoc/src/google/protobuf/compiler/code_generator.h index 03cdab6cb1..03f93c49f9 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/code_generator.h +++ b/contrib/libs/protoc/src/google/protobuf/compiler/code_generator.h @@ -55,9 +55,9 @@ class FileDescriptor; class GeneratedCodeInfo; namespace compiler { -class AccessInfoMap; +class AccessInfoMap; -class Version; +class Version; // Defined in this file. class CodeGenerator; @@ -74,11 +74,11 @@ class PROTOC_EXPORT CodeGenerator { // Generates code for the given proto file, generating one or more files in // the given output directory. // - // A parameter to be passed to the generator can be specified on the command - // line. This is intended to be used to pass generator specific parameters. - // It is empty if no parameter was given. ParseGeneratorParameter (below), - // can be used to accept multiple parameters within the single parameter - // command line flag. + // A parameter to be passed to the generator can be specified on the command + // line. This is intended to be used to pass generator specific parameters. + // It is empty if no parameter was given. ParseGeneratorParameter (below), + // can be used to accept multiple parameters within the single parameter + // command line flag. // // Returns true if successful. Otherwise, sets *error to a description of // the problem (e.g. "invalid parameter") and returns false. @@ -87,20 +87,20 @@ class PROTOC_EXPORT CodeGenerator { GeneratorContext* generator_context, TProtoStringType* error) const = 0; - // Generates code for all given proto files. + // Generates code for all given proto files. // - // WARNING: The canonical code generator design produces one or two output - // files per input .proto file, and we do not wish to encourage alternate - // designs. + // WARNING: The canonical code generator design produces one or two output + // files per input .proto file, and we do not wish to encourage alternate + // designs. // // A parameter is given as passed on the command line, as in |Generate()| // above. // // Returns true if successful. Otherwise, sets *error to a description of // the problem (e.g. "invalid parameter") and returns false. - virtual bool GenerateAll(const std::vector<const FileDescriptor*>& files, + virtual bool GenerateAll(const std::vector<const FileDescriptor*>& files, const TProtoStringType& parameter, - GeneratorContext* generator_context, + GeneratorContext* generator_context, TProtoStringType* error) const; // Sync with plugin.proto. @@ -113,11 +113,11 @@ class PROTOC_EXPORT CodeGenerator { // plugin.proto. virtual uint64_t GetSupportedFeatures() const { return 0; } - // This is no longer used, but this class is part of the opensource protobuf - // library, so it has to remain to keep vtables the same for the current - // version of the library. When protobufs does a api breaking change, the - // method can be removed. - virtual bool HasGenerateAll() const { return true; } + // This is no longer used, but this class is part of the opensource protobuf + // library, so it has to remain to keep vtables the same for the current + // version of the library. When protobufs does a api breaking change, the + // method can be removed. + virtual bool HasGenerateAll() const { return true; } private: GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CodeGenerator); @@ -129,8 +129,8 @@ class PROTOC_EXPORT CodeGenerator { // runs. class PROTOC_EXPORT GeneratorContext { public: - inline GeneratorContext() { - } + inline GeneratorContext() { + } virtual ~GeneratorContext(); // Opens the given file, truncating it if it exists, and returns a @@ -171,11 +171,11 @@ class PROTOC_EXPORT GeneratorContext { // differently when compiled as a set rather than individually. virtual void ListParsedFiles(std::vector<const FileDescriptor*>* output); - // Retrieves the version number of the protocol compiler associated with - // this GeneratorContext. - virtual void GetCompilerVersion(Version* version) const; - - + // Retrieves the version number of the protocol compiler associated with + // this GeneratorContext. + virtual void GetCompilerVersion(Version* version) const; + + private: GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(GeneratorContext); }; diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/command_line_interface.cc b/contrib/libs/protoc/src/google/protobuf/compiler/command_line_interface.cc index 8e0e0f9885..7663ea0085 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/command_line_interface.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/command_line_interface.cc @@ -33,19 +33,19 @@ // Sanjay Ghemawat, Jeff Dean, and others. #include <google/protobuf/compiler/command_line_interface.h> - + #include <cstdint> #include <google/protobuf/stubs/platform_macros.h> #include <stdio.h> #include <sys/types.h> -#ifdef major -#undef major -#endif -#ifdef minor -#undef minor -#endif +#ifdef major +#undef major +#endif +#ifdef minor +#undef minor +#endif #include <fcntl.h> #include <sys/stat.h> #ifndef _MSC_VER @@ -86,7 +86,7 @@ #include <google/protobuf/stubs/map_util.h> #include <google/protobuf/stubs/stl_util.h> - + #include <google/protobuf/port_def.inc> namespace google { @@ -103,8 +103,8 @@ namespace compiler { namespace { #if defined(_WIN32) -// DO NOT include <io.h>, instead create functions in io_win32.{h,cc} and import -// them like we do below. +// DO NOT include <io.h>, instead create functions in io_win32.{h,cc} and import +// them like we do below. using google::protobuf::io::win32::access; using google::protobuf::io::win32::close; using google::protobuf::io::win32::mkdir; @@ -113,9 +113,9 @@ using google::protobuf::io::win32::setmode; using google::protobuf::io::win32::write; #endif -static const char* kDefaultDirectDependenciesViolationMsg = - "File is imported but not declared in --direct_dependencies: %s"; - +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? @@ -130,9 +130,9 @@ static bool IsWindowsAbsolutePath(const TProtoStringType& text) { void SetFdToTextMode(int fd) { #ifdef _WIN32 - if (setmode(fd, _O_TEXT) == -1) { + if (setmode(fd, _O_TEXT) == -1) { // This should never happen, I think. - GOOGLE_LOG(WARNING) << "setmode(" << fd << ", _O_TEXT): " << strerror(errno); + GOOGLE_LOG(WARNING) << "setmode(" << fd << ", _O_TEXT): " << strerror(errno); } #endif // (Text and binary are the same on non-Windows platforms.) @@ -140,9 +140,9 @@ void SetFdToTextMode(int fd) { void SetFdToBinaryMode(int fd) { #ifdef _WIN32 - if (setmode(fd, _O_BINARY) == -1) { + if (setmode(fd, _O_BINARY) == -1) { // This should never happen, I think. - GOOGLE_LOG(WARNING) << "setmode(" << fd << ", _O_BINARY): " << strerror(errno); + GOOGLE_LOG(WARNING) << "setmode(" << fd << ", _O_BINARY): " << strerror(errno); } #endif // (Text and binary are the same on non-Windows platforms.) @@ -273,21 +273,21 @@ void AddDefaultProtoPaths( return; } } - + TProtoStringType PluginName(const TProtoStringType& plugin_prefix, const TProtoStringType& directive) { - // Assuming the directive starts with "--" and ends with "_out" or "_opt", - // strip the "--" and "_out/_opt" and add the plugin prefix. - return plugin_prefix + "gen-" + directive.substr(2, directive.size() - 6); -} - + // Assuming the directive starts with "--" and ends with "_out" or "_opt", + // strip the "--" and "_out/_opt" and add the plugin prefix. + return plugin_prefix + "gen-" + directive.substr(2, directive.size() - 6); +} + } // namespace // A MultiFileErrorCollector that prints errors to stderr. -class CommandLineInterface::ErrorPrinter - : public MultiFileErrorCollector, - public io::ErrorCollector, - public DescriptorPool::ErrorCollector { +class CommandLineInterface::ErrorPrinter + : public MultiFileErrorCollector, + public io::ErrorCollector, + public DescriptorPool::ErrorCollector { public: ErrorPrinter(ErrorFormat format, DiskSourceTree* tree = NULL) : format_(format), @@ -299,7 +299,7 @@ class CommandLineInterface::ErrorPrinter // implements MultiFileErrorCollector ------------------------------ void AddError(const TProtoStringType& filename, int line, int column, const TProtoStringType& message) { - found_errors_ = true; + found_errors_ = true; AddErrorOrWarning(filename, line, column, message, "error", std::cerr); } @@ -318,27 +318,27 @@ class CommandLineInterface::ErrorPrinter AddErrorOrWarning("input", line, column, message, "warning", std::clog); } - // implements DescriptorPool::ErrorCollector------------------------- + // implements DescriptorPool::ErrorCollector------------------------- void AddError(const TProtoStringType& filename, const TProtoStringType& element_name, const Message* descriptor, ErrorLocation location, const TProtoStringType& message) { - AddErrorOrWarning(filename, -1, -1, message, "error", std::cerr); - } - + AddErrorOrWarning(filename, -1, -1, message, "error", std::cerr); + } + void AddWarning(const TProtoStringType& filename, const TProtoStringType& element_name, const Message* descriptor, ErrorLocation location, const TProtoStringType& message) { - AddErrorOrWarning(filename, -1, -1, message, "warning", std::clog); - } - - bool FoundErrors() const { return found_errors_; } - + AddErrorOrWarning(filename, -1, -1, message, "warning", std::clog); + } + + bool FoundErrors() const { return found_errors_; } + bool FoundWarnings() const { return found_warnings_; } private: void AddErrorOrWarning(const TProtoStringType& filename, int line, int column, const TProtoStringType& message, const TProtoStringType& type, - std::ostream& out) { + std::ostream& out) { // Print full path when running under MSVS TProtoStringType dfile; if (format_ == CommandLineInterface::ERROR_FORMAT_MSVS && tree_ != NULL && @@ -372,7 +372,7 @@ class CommandLineInterface::ErrorPrinter const ErrorFormat format_; DiskSourceTree* tree_; - bool found_errors_; + bool found_errors_; bool found_warnings_; }; @@ -445,8 +445,8 @@ class CommandLineInterface::MemoryOutputStream private: // Checks to see if "filename_.pb.meta" exists in directory_; if so, fixes the - // offsets in that GeneratedCodeInfo record to reflect bytes inserted in - // filename_ at original offset insertion_offset with length insertion_length. + // offsets in that GeneratedCodeInfo record to reflect bytes inserted in + // filename_ at original offset insertion_offset with length insertion_length. // Also adds in the data from info_to_insert_ with updated offsets governed by // insertion_offset and indent_length. We assume that insertions will not // occur within any given annotated span of text. insertion_content must end @@ -454,7 +454,7 @@ class CommandLineInterface::MemoryOutputStream void UpdateMetadata(const TProtoStringType& insertion_content, size_t insertion_offset, size_t insertion_length, size_t indent_length); - + // Inserts info_to_insert_ into target_info, assuming that the relevant // insertion was made at insertion_offset in file_content with the given // indent_length. insertion_content must end with an endline. @@ -705,16 +705,16 @@ void CommandLineInterface::MemoryOutputStream::InsertShiftedInfo( } } -void CommandLineInterface::MemoryOutputStream::UpdateMetadata( +void CommandLineInterface::MemoryOutputStream::UpdateMetadata( const TProtoStringType& insertion_content, size_t insertion_offset, size_t insertion_length, size_t indent_length) { auto it = directory_->files_.find(filename_ + ".pb.meta"); if (it == directory_->files_.end() && info_to_insert_.annotation().empty()) { - // No metadata was recorded for this file. - return; - } - GeneratedCodeInfo metadata; - bool is_text_format = false; + // No metadata was recorded for this file. + return; + } + GeneratedCodeInfo metadata; + bool is_text_format = false; TProtoStringType* encoded_data = nullptr; if (it != directory_->files_.end()) { encoded_data = &it->second; @@ -734,12 +734,12 @@ void CommandLineInterface::MemoryOutputStream::UpdateMetadata( // metadata (because in the public plugin protocol, file content must be // UTF8-encoded strings). is_text_format = true; - } + } } else { // Create a new file to store the new metadata in info_to_insert_. encoded_data = &directory_->files_.insert({filename_ + ".pb.meta", ""}).first->second; - } + } GeneratedCodeInfo new_metadata; bool crossed_offset = false; size_t to_add = 0; @@ -753,25 +753,25 @@ void CommandLineInterface::MemoryOutputStream::UpdateMetadata( InsertShiftedInfo(insertion_content, insertion_offset, indent_length, new_metadata); to_add += insertion_length; - } + } GeneratedCodeInfo::Annotation* annotation = new_metadata.add_annotation(); *annotation = source_annotation; annotation->set_begin(annotation->begin() + to_add); annotation->set_end(annotation->end() + to_add); - } + } // If there were never any annotations at or after the insertion point, // make sure to still insert the new metadata from info_to_insert_. if (!crossed_offset) { InsertShiftedInfo(insertion_content, insertion_offset, indent_length, new_metadata); } - if (is_text_format) { + if (is_text_format) { TextFormat::PrintToString(new_metadata, encoded_data); - } else { + } else { new_metadata.SerializeToString(encoded_data); - } -} - + } +} + CommandLineInterface::MemoryOutputStream::~MemoryOutputStream() { // Make sure all data has been written. inner_.reset(); @@ -889,12 +889,12 @@ CommandLineInterface::MemoryOutputStream::~MemoryOutputStream() { // =================================================================== -#if defined(_WIN32) && !defined(__CYGWIN__) -const char* const CommandLineInterface::kPathSeparator = ";"; -#else -const char* const CommandLineInterface::kPathSeparator = ":"; -#endif - +#if defined(_WIN32) && !defined(__CYGWIN__) +const char* const CommandLineInterface::kPathSeparator = ";"; +#else +const char* const CommandLineInterface::kPathSeparator = ":"; +#endif + CommandLineInterface::CommandLineInterface() : direct_dependencies_violation_msg_( kDefaultDirectDependenciesViolationMsg) {} @@ -972,7 +972,7 @@ int CommandLineInterface::Run(int argc, const char* const argv[]) { break; } - std::vector<const FileDescriptor*> parsed_files; + std::vector<const FileDescriptor*> parsed_files; std::unique_ptr<DiskSourceTree> disk_source_tree; std::unique_ptr<ErrorPrinter> error_collector; std::unique_ptr<DescriptorPool> descriptor_pool; @@ -1022,29 +1022,29 @@ int CommandLineInterface::Run(int argc, const char* const argv[]) { descriptor_pool.reset(new DescriptorPool(descriptor_set_in_database.get(), error_collector.get())); } else { - disk_source_tree.reset(new DiskSourceTree()); + disk_source_tree.reset(new DiskSourceTree()); if (!InitializeDiskSourceTree(disk_source_tree.get(), descriptor_set_in_database.get())) { return 1; } - error_collector.reset( - new ErrorPrinter(error_format_, disk_source_tree.get())); + error_collector.reset( + new ErrorPrinter(error_format_, disk_source_tree.get())); source_tree_database.reset(new SourceTreeDescriptorDatabase( disk_source_tree.get(), descriptor_set_in_database.get())); source_tree_database->RecordErrorsTo(error_collector.get()); - descriptor_pool.reset(new DescriptorPool( + descriptor_pool.reset(new DescriptorPool( source_tree_database.get(), source_tree_database->GetValidationErrorCollector())); } - descriptor_pool->EnforceWeakDependencies(true); + descriptor_pool->EnforceWeakDependencies(true); if (!ParseInputFiles(descriptor_pool.get(), disk_source_tree.get(), &parsed_files)) { - return 1; - } + return 1; + } // We construct a separate GeneratorContext for each output location. Note @@ -1096,14 +1096,14 @@ int CommandLineInterface::Run(int argc, const char* const argv[]) { } if (!dependency_out_name_.empty()) { - GOOGLE_DCHECK(disk_source_tree.get()); + GOOGLE_DCHECK(disk_source_tree.get()); if (!GenerateDependencyManifestFile(parsed_files, output_directories, - disk_source_tree.get())) { + disk_source_tree.get())) { return 1; } } - if (!descriptor_set_out_name_.empty()) { + if (!descriptor_set_out_name_.empty()) { if (!WriteDescriptorSet(parsed_files)) { return 1; } @@ -1122,7 +1122,7 @@ int CommandLineInterface::Run(int argc, const char* const argv[]) { return 1; } } else { - if (!EncodeOrDecode(descriptor_pool.get())) { + if (!EncodeOrDecode(descriptor_pool.get())) { return 1; } } @@ -1130,9 +1130,9 @@ int CommandLineInterface::Run(int argc, const char* const argv[]) { if (error_collector->FoundErrors() || (fatal_warnings_ && error_collector->FoundWarnings())) { - return 1; - } - + return 1; + } + if (mode_ == MODE_PRINT) { switch (print_mode_) { case PRINT_FREE_FIELDS: @@ -1155,23 +1155,23 @@ int CommandLineInterface::Run(int argc, const char* const argv[]) { return 0; } -bool CommandLineInterface::InitializeDiskSourceTree( +bool CommandLineInterface::InitializeDiskSourceTree( DiskSourceTree* source_tree, DescriptorDatabase* fallback_database) { - AddDefaultProtoPaths(&proto_path_); - - // Set up the source tree. - for (int i = 0; i < proto_path_.size(); i++) { - source_tree->MapPath(proto_path_[i].first, proto_path_[i].second); - } - - // Map input files to virtual paths if possible. + AddDefaultProtoPaths(&proto_path_); + + // Set up the source tree. + for (int i = 0; i < proto_path_.size(); i++) { + source_tree->MapPath(proto_path_[i].first, proto_path_[i].second); + } + + // Map input files to virtual paths if possible. if (!MakeInputsBeProtoPathRelative(source_tree, fallback_database)) { - return false; - } + return false; + } + + return true; +} - return true; -} - namespace { std::unique_ptr<SimpleDescriptorDatabase> PopulateSingleSimpleDescriptorDatabase(const TProtoStringType& descriptor_set_name) { @@ -1206,14 +1206,14 @@ PopulateSingleSimpleDescriptorDatabase(const TProtoStringType& descriptor_set_na &previously_added_file_descriptor_proto)) { // already present - skip continue; - } + } if (!database->Add(file_descriptor_set.file(j))) { return nullptr; } } return database; } - + } // namespace @@ -1224,26 +1224,26 @@ bool CommandLineInterface::VerifyInputFilesInDescriptors( if (!database->FindFileByName(input_file, &file_descriptor)) { std::cerr << "Could not find file in descriptor database: " << input_file << ": " << strerror(ENOENT) << std::endl; - return false; - } - + return false; + } + // Enforce --disallow_services. if (disallow_services_ && file_descriptor.service_size() > 0) { std::cerr << file_descriptor.name() << ": This file contains services, but " "--disallow_services was used." - << std::endl; - return false; - } - - } - return true; -} - -bool CommandLineInterface::ParseInputFiles( + << std::endl; + return false; + } + + } + return true; +} + +bool CommandLineInterface::ParseInputFiles( DescriptorPool* descriptor_pool, DiskSourceTree* source_tree, - std::vector<const FileDescriptor*>* parsed_files) { - + std::vector<const FileDescriptor*>* parsed_files) { + if (!proto_path_.empty()) { // Track unused imports in all source files that were loaded from the // filesystem. We do not track unused imports for files loaded from @@ -1265,64 +1265,64 @@ bool CommandLineInterface::ParseInputFiles( } bool result = true; - // Parse each file. + // Parse each file. for (const auto& input_file : input_files_) { - // Import the file. - const FileDescriptor* parsed_file = + // Import the file. + const FileDescriptor* parsed_file = descriptor_pool->FindFileByName(input_file); - if (parsed_file == NULL) { + if (parsed_file == NULL) { result = false; break; - } - parsed_files->push_back(parsed_file); - - // Enforce --disallow_services. - if (disallow_services_ && parsed_file->service_count() > 0) { + } + parsed_files->push_back(parsed_file); + + // Enforce --disallow_services. + if (disallow_services_ && parsed_file->service_count() > 0) { std::cerr << parsed_file->name() << ": This file contains services, but " "--disallow_services was used." << std::endl; result = false; break; - } - - - // Enforce --direct_dependencies - if (direct_dependencies_explicitly_set_) { - bool indirect_imports = false; - for (int i = 0; i < parsed_file->dependency_count(); i++) { - if (direct_dependencies_.find(parsed_file->dependency(i)->name()) == - direct_dependencies_.end()) { - indirect_imports = true; - std::cerr << parsed_file->name() << ": " - << StringReplace(direct_dependencies_violation_msg_, "%s", - parsed_file->dependency(i)->name(), - true /* replace_all */) - << std::endl; - } - } - if (indirect_imports) { + } + + + // Enforce --direct_dependencies + if (direct_dependencies_explicitly_set_) { + bool indirect_imports = false; + for (int i = 0; i < parsed_file->dependency_count(); i++) { + if (direct_dependencies_.find(parsed_file->dependency(i)->name()) == + direct_dependencies_.end()) { + indirect_imports = true; + std::cerr << parsed_file->name() << ": " + << StringReplace(direct_dependencies_violation_msg_, "%s", + parsed_file->dependency(i)->name(), + true /* replace_all */) + << std::endl; + } + } + if (indirect_imports) { result = false; break; - } - } - } + } + } + } descriptor_pool->ClearUnusedImportTrackFiles(); return result; -} - +} + void CommandLineInterface::Clear() { // Clear all members that are set by Run(). Note that we must not clear // members which are set by other methods before Run() is called. executable_name_.clear(); proto_path_.clear(); input_files_.clear(); - direct_dependencies_.clear(); - direct_dependencies_violation_msg_ = kDefaultDirectDependenciesViolationMsg; + direct_dependencies_.clear(); + direct_dependencies_violation_msg_ = kDefaultDirectDependenciesViolationMsg; output_directives_.clear(); codec_type_.clear(); - descriptor_set_in_names_.clear(); - descriptor_set_out_name_.clear(); + descriptor_set_in_names_.clear(); + descriptor_set_out_name_.clear(); dependency_out_name_.clear(); @@ -1331,7 +1331,7 @@ void CommandLineInterface::Clear() { imports_in_descriptor_set_ = false; source_info_in_descriptor_set_ = false; disallow_services_ = false; - direct_dependencies_explicitly_set_ = false; + direct_dependencies_explicitly_set_ = false; deterministic_output_ = false; } @@ -1374,15 +1374,15 @@ bool CommandLineInterface::MakeProtoProtoPathRelative( return false; case DiskSourceTree::CANNOT_OPEN: { if (in_fallback_database) { - return true; - } + return true; + } TProtoStringType error_str = source_tree->GetLastErrorMessage().empty() ? strerror(errno) : source_tree->GetLastErrorMessage(); std::cerr << "Could not map to virtual file: " << *proto << ": " << error_str << std::endl; return false; - } + } case DiskSourceTree::NO_MAPPING: { // Try to interpret the path as a virtual path. TProtoStringType disk_file; @@ -1403,7 +1403,7 @@ bool CommandLineInterface::MakeProtoProtoPathRelative( "than you think)." << std::endl; return false; - } + } } } return true; @@ -1455,12 +1455,12 @@ CommandLineInterface::ParseArgumentStatus CommandLineInterface::ParseArguments( arguments.push_back(argv[i]); } - // if no arguments are given, show help + // if no arguments are given, show help if (arguments.empty()) { - PrintHelpText(); - return PARSE_ARGUMENT_DONE_AND_EXIT; // Exit without running compiler. - } - + PrintHelpText(); + return PARSE_ARGUMENT_DONE_AND_EXIT; // Exit without running compiler. + } + // Iterate through all arguments and parse them. for (int i = 0; i < arguments.size(); ++i) { TProtoStringType name, value; @@ -1484,38 +1484,38 @@ CommandLineInterface::ParseArgumentStatus CommandLineInterface::ParseArguments( if (status != PARSE_ARGUMENT_DONE_AND_CONTINUE) return status; } - // Make sure each plugin option has a matching plugin output. - bool foundUnknownPluginOption = false; + // Make sure each plugin option has a matching plugin output. + bool foundUnknownPluginOption = false; for (std::map<TProtoStringType, TProtoStringType>::const_iterator i = plugin_parameters_.begin(); - i != plugin_parameters_.end(); ++i) { - if (plugins_.find(i->first) != plugins_.end()) { - continue; - } - bool foundImplicitPlugin = false; + i != plugin_parameters_.end(); ++i) { + if (plugins_.find(i->first) != plugins_.end()) { + continue; + } + bool foundImplicitPlugin = false; for (std::vector<OutputDirective>::const_iterator j = output_directives_.begin(); - j != output_directives_.end(); ++j) { - if (j->generator == NULL) { + j != output_directives_.end(); ++j) { + if (j->generator == NULL) { TProtoStringType plugin_name = PluginName(plugin_prefix_, j->name); - if (plugin_name == i->first) { - foundImplicitPlugin = true; - break; - } - } - } - if (!foundImplicitPlugin) { - std::cerr << "Unknown flag: " - // strip prefix + "gen-" and add back "_opt" - << "--" + i->first.substr(plugin_prefix_.size() + 4) + "_opt" - << std::endl; - foundUnknownPluginOption = true; - } - } - if (foundUnknownPluginOption) { - return PARSE_ARGUMENT_FAIL; - } - + if (plugin_name == i->first) { + foundImplicitPlugin = true; + break; + } + } + } + if (!foundImplicitPlugin) { + std::cerr << "Unknown flag: " + // strip prefix + "gen-" and add back "_opt" + << "--" + i->first.substr(plugin_prefix_.size() + 4) + "_opt" + << std::endl; + foundUnknownPluginOption = true; + } + } + if (foundUnknownPluginOption) { + return PARSE_ARGUMENT_FAIL; + } + // The --proto_path & --descriptor_set_in flags both specify places to look // for proto files. If neither were given, use the current working directory. if (proto_path_.empty() && descriptor_set_in_names_.empty()) { @@ -1559,7 +1559,7 @@ CommandLineInterface::ParseArgumentStatus CommandLineInterface::ParseArguments( return PARSE_ARGUMENT_FAIL; } if (mode_ == MODE_COMPILE && output_directives_.empty() && - descriptor_set_out_name_.empty()) { + descriptor_set_out_name_.empty()) { std::cerr << "Missing output directives." << std::endl; return PARSE_ARGUMENT_FAIL; } @@ -1586,12 +1586,12 @@ CommandLineInterface::ParseArgumentStatus CommandLineInterface::ParseArguments( << std::endl; return PARSE_ARGUMENT_FAIL; } - if (imports_in_descriptor_set_ && descriptor_set_out_name_.empty()) { + if (imports_in_descriptor_set_ && descriptor_set_out_name_.empty()) { std::cerr << "--include_imports only makes sense when combined with " "--descriptor_set_out." << std::endl; } - if (source_info_in_descriptor_set_ && descriptor_set_out_name_.empty()) { + if (source_info_in_descriptor_set_ && descriptor_set_out_name_.empty()) { std::cerr << "--include_source_info only makes sense when combined with " "--descriptor_set_out." << std::endl; @@ -1709,7 +1709,7 @@ CommandLineInterface::InterpretArgument(const TProtoStringType& name, // intuitive. std::vector<TProtoStringType> parts = Split( value, CommandLineInterface::kPathSeparator, - true); + true); for (int i = 0; i < parts.size(); i++) { TProtoStringType virtual_path; @@ -1736,8 +1736,8 @@ CommandLineInterface::InterpretArgument(const TProtoStringType& name, if (access(disk_path.c_str(), F_OK) < 0) { // Try the original path; it may have just happened to have a '=' in it. if (access(parts[i].c_str(), F_OK) < 0) { - std::cerr << disk_path << ": warning: directory does not exist." - << std::endl; + std::cerr << disk_path << ": warning: directory does not exist." + << std::endl; } else { virtual_path = ""; disk_path = parts[i]; @@ -1751,50 +1751,50 @@ CommandLineInterface::InterpretArgument(const TProtoStringType& name, std::pair<TProtoStringType, TProtoStringType>(virtual_path, disk_path)); } - } else if (name == "--direct_dependencies") { - if (direct_dependencies_explicitly_set_) { + } else if (name == "--direct_dependencies") { + if (direct_dependencies_explicitly_set_) { std::cerr << name << " may only be passed once. To specify multiple " "direct dependencies, pass them all as a single " "parameter separated by ':'." - << std::endl; - return PARSE_ARGUMENT_FAIL; - } - - direct_dependencies_explicitly_set_ = true; + << std::endl; + return PARSE_ARGUMENT_FAIL; + } + + direct_dependencies_explicitly_set_ = true; std::vector<TProtoStringType> direct = Split(value, ":", true); - 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 == "--descriptor_set_in") { - if (!descriptor_set_in_names_.empty()) { + 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 == "--descriptor_set_in") { + if (!descriptor_set_in_names_.empty()) { std::cerr << name << " may only be passed once. To specify multiple " "descriptor sets, pass them all as a single " "parameter separated by '" << CommandLineInterface::kPathSeparator << "'." << std::endl; - return PARSE_ARGUMENT_FAIL; - } - if (value.empty()) { - std::cerr << name << " requires a non-empty value." << std::endl; - return PARSE_ARGUMENT_FAIL; - } - if (!dependency_out_name_.empty()) { - std::cerr << name << " cannot be used with --dependency_out." - << std::endl; - return PARSE_ARGUMENT_FAIL; - } - - descriptor_set_in_names_ = Split( + return PARSE_ARGUMENT_FAIL; + } + if (value.empty()) { + std::cerr << name << " requires a non-empty value." << std::endl; + return PARSE_ARGUMENT_FAIL; + } + if (!dependency_out_name_.empty()) { + std::cerr << name << " cannot be used with --dependency_out." + << std::endl; + return PARSE_ARGUMENT_FAIL; + } + + descriptor_set_in_names_ = Split( value, CommandLineInterface::kPathSeparator, true); - + } else if (name == "-o" || name == "--descriptor_set_out") { - if (!descriptor_set_out_name_.empty()) { + if (!descriptor_set_out_name_.empty()) { std::cerr << name << " may only be passed once." << std::endl; return PARSE_ARGUMENT_FAIL; } @@ -1809,7 +1809,7 @@ CommandLineInterface::InterpretArgument(const TProtoStringType& name, << std::endl; return PARSE_ARGUMENT_FAIL; } - descriptor_set_out_name_ = value; + descriptor_set_out_name_ = value; } else if (name == "--dependency_out") { if (!dependency_out_name_.empty()) { @@ -1820,11 +1820,11 @@ CommandLineInterface::InterpretArgument(const TProtoStringType& name, std::cerr << name << " requires a non-empty value." << std::endl; return PARSE_ARGUMENT_FAIL; } - if (!descriptor_set_in_names_.empty()) { - std::cerr << name << " cannot be used with --descriptor_set_in." - << std::endl; - return PARSE_ARGUMENT_FAIL; - } + if (!descriptor_set_in_names_.empty()) { + std::cerr << name << " cannot be used with --descriptor_set_in." + << std::endl; + return PARSE_ARGUMENT_FAIL; + } dependency_out_name_ = value; } else if (name == "--include_imports") { @@ -1866,7 +1866,7 @@ CommandLineInterface::InterpretArgument(const TProtoStringType& name, << std::endl; return PARSE_ARGUMENT_FAIL; } - if (!output_directives_.empty() || !descriptor_set_out_name_.empty()) { + if (!output_directives_.empty() || !descriptor_set_out_name_.empty()) { std::cerr << "Cannot use " << name << " and generate code or descriptors at the same time." << std::endl; @@ -1970,7 +1970,7 @@ CommandLineInterface::InterpretArgument(const TProtoStringType& name, << "other info at the same time." << std::endl; return PARSE_ARGUMENT_FAIL; } - if (!output_directives_.empty() || !descriptor_set_out_name_.empty()) { + if (!output_directives_.empty() || !descriptor_set_out_name_.empty()) { std::cerr << "Cannot use " << name << " and generate code or descriptors at the same time." << std::endl; @@ -1986,23 +1986,23 @@ CommandLineInterface::InterpretArgument(const TProtoStringType& name, (plugin_prefix_.empty() || !HasSuffixString(name, "_out"))) { // Check if it's a generator option flag. generator_info = FindOrNull(generators_by_option_name_, name); - if (generator_info != NULL) { + if (generator_info != NULL) { TProtoStringType* parameters = &generator_parameters_[generator_info->flag_name]; if (!parameters->empty()) { parameters->append(","); } parameters->append(value); - } else if (HasPrefixString(name, "--") && HasSuffixString(name, "_opt")) { + } else if (HasPrefixString(name, "--") && HasSuffixString(name, "_opt")) { TProtoStringType* parameters = - &plugin_parameters_[PluginName(plugin_prefix_, name)]; - if (!parameters->empty()) { - parameters->append(","); - } - parameters->append(value); - } else { - std::cerr << "Unknown flag: " << name << std::endl; - return PARSE_ARGUMENT_FAIL; + &plugin_parameters_[PluginName(plugin_prefix_, name)]; + if (!parameters->empty()) { + parameters->append(","); + } + parameters->append(value); + } else { + std::cerr << "Unknown flag: " << name << std::endl; + return PARSE_ARGUMENT_FAIL; } } else { // It's an output flag. Add it to the output directives. @@ -2184,12 +2184,12 @@ bool CommandLineInterface::GenerateOutput( TProtoStringType plugin_name = PluginName(plugin_prefix_, output_directive.name); TProtoStringType parameters = output_directive.parameter; - if (!plugin_parameters_[plugin_name].empty()) { - if (!parameters.empty()) { - parameters.append(","); - } - parameters.append(plugin_parameters_[plugin_name]); - } + if (!plugin_parameters_[plugin_name].empty()) { + if (!parameters.empty()) { + parameters.append(","); + } + parameters.append(plugin_parameters_[plugin_name]); + } if (!GeneratePluginOutput(parsed_files, plugin_name, parameters, generator_context, &error)) { std::cerr << output_directive.name << ": " << error << std::endl; @@ -2212,9 +2212,9 @@ bool CommandLineInterface::GenerateOutput( if (!output_directive.generator->GenerateAll(parsed_files, parameters, generator_context, &error)) { - // Generator returned an error. - std::cerr << output_directive.name << ": " << error << std::endl; - return false; + // Generator returned an error. + std::cerr << output_directive.name << ": " << error << std::endl; + return false; } } @@ -2303,7 +2303,7 @@ bool CommandLineInterface::GeneratePluginOutput( request.set_parameter(processed_parameter); } - + std::set<const FileDescriptor*> already_seen; for (int i = 0; i < parsed_files.size(); i++) { request.add_file_to_generate(parsed_files[i]->name()); @@ -2313,13 +2313,13 @@ bool CommandLineInterface::GeneratePluginOutput( &already_seen, request.mutable_proto_file()); } - google::protobuf::compiler::Version* version = - request.mutable_compiler_version(); + google::protobuf::compiler::Version* version = + request.mutable_compiler_version(); version->set_major(PROTOBUF_VERSION / 1000000); version->set_minor(PROTOBUF_VERSION / 1000 % 1000); version->set_patch(PROTOBUF_VERSION % 1000); version->set_suffix(PROTOBUF_VERSION_SUFFIX); - + // Invoke the plugin. Subprocess subprocess; @@ -2474,43 +2474,43 @@ 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; - 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()); + 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++) { - 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); - } + 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 + 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 { - fd = open(descriptor_set_out_name_.c_str(), + fd = open(descriptor_set_out_name_.c_str(), O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666); } while (fd < 0 && errno == EINTR); if (fd < 0) { - perror(descriptor_set_out_name_.c_str()); + perror(descriptor_set_out_name_.c_str()); return false; } @@ -2530,7 +2530,7 @@ bool CommandLineInterface::WriteDescriptorSet( } if (!out.Close()) { - std::cerr << descriptor_set_out_name_ << ": " << strerror(out.GetErrno()) + std::cerr << descriptor_set_out_name_ << ": " << strerror(out.GetErrno()) << std::endl; return false; } @@ -2599,9 +2599,9 @@ namespace { // tree) of the given descriptor for the caller to traverse. The declaration // order of the nested messages is also preserved. typedef std::pair<int, int> FieldRange; -void GatherOccupiedFieldRanges( - const Descriptor* descriptor, std::set<FieldRange>* ranges, - std::vector<const Descriptor*>* nested_messages) { +void GatherOccupiedFieldRanges( + const Descriptor* descriptor, std::set<FieldRange>* ranges, + std::vector<const Descriptor*>* nested_messages) { std::set<const Descriptor*> groups; for (int i = 0; i < descriptor->field_count(); ++i) { const FieldDescriptor* fd = descriptor->field(i); diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/command_line_interface.h b/contrib/libs/protoc/src/google/protobuf/compiler/command_line_interface.h index e0dfe2db31..337475c693 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/command_line_interface.h +++ b/contrib/libs/protoc/src/google/protobuf/compiler/command_line_interface.h @@ -66,9 +66,9 @@ class SimpleDescriptorDatabase; // descriptor_database.h namespace compiler { -class CodeGenerator; // code_generator.h -class GeneratorContext; // code_generator.h -class DiskSourceTree; // importer.h +class CodeGenerator; // code_generator.h +class GeneratorContext; // code_generator.h +class DiskSourceTree; // importer.h // This class implements the command-line interface to the protocol compiler. // It is designed to make it very easy to create a custom protocol compiler @@ -97,21 +97,21 @@ class DiskSourceTree; // importer.h // The compiler is invoked with syntax like: // protoc --cpp_out=outdir --foo_out=outdir --proto_path=src src/foo.proto // -// The .proto file to compile can be specified on the command line using either +// The .proto file to compile can be specified on the command line using either // its physical file path, or a virtual path relative to a directory specified -// in --proto_path. For example, for src/foo.proto, the following two protoc -// invocations work the same way: -// 1. protoc --proto_path=src src/foo.proto (physical file path) -// 2. protoc --proto_path=src foo.proto (virtual path relative to src) -// -// If a file path can be interpreted both as a physical file path and as a +// in --proto_path. For example, for src/foo.proto, the following two protoc +// invocations work the same way: +// 1. protoc --proto_path=src src/foo.proto (physical file path) +// 2. protoc --proto_path=src foo.proto (virtual path relative to src) +// +// If a file path can be interpreted both as a physical file path and as a // relative virtual path, the physical file path takes precedence. -// +// // For a full description of the command-line syntax, invoke it with --help. class PROTOC_EXPORT CommandLineInterface { public: - static const char* const kPathSeparator; - + static const char* const kPathSeparator; + CommandLineInterface(); ~CommandLineInterface(); @@ -161,14 +161,14 @@ class PROTOC_EXPORT CommandLineInterface { // plugin [--out=OUTDIR] [--parameter=PARAMETER] PROTO_FILES < DESCRIPTORS // --out indicates the output directory (as passed to the --foo_out // parameter); if omitted, the current directory should be used. --parameter - // gives the generator parameter, if any was provided (see below). The - // PROTO_FILES list the .proto files which were given on the compiler - // command-line; these are the files for which the plugin is expected to - // generate output code. Finally, DESCRIPTORS is an encoded FileDescriptorSet - // (as defined in descriptor.proto). This is piped to the plugin's stdin. - // The set will include descriptors for all the files listed in PROTO_FILES as - // well as all files that they import. The plugin MUST NOT attempt to read - // the PROTO_FILES directly -- it must use the FileDescriptorSet. + // gives the generator parameter, if any was provided (see below). The + // PROTO_FILES list the .proto files which were given on the compiler + // command-line; these are the files for which the plugin is expected to + // generate output code. Finally, DESCRIPTORS is an encoded FileDescriptorSet + // (as defined in descriptor.proto). This is piped to the plugin's stdin. + // The set will include descriptors for all the files listed in PROTO_FILES as + // well as all files that they import. The plugin MUST NOT attempt to read + // the PROTO_FILES directly -- it must use the FileDescriptorSet. // // The plugin should generate whatever files are necessary, as code generators // normally do. It should write the names of all files it generates to @@ -176,13 +176,13 @@ class PROTOC_EXPORT CommandLineInterface { // names or relative to the current directory. If any errors occur, error // messages should be written to stderr. If an error is fatal, the plugin // should exit with a non-zero exit code. - // - // Plugins can have generator parameters similar to normal built-in - // generators. Extra generator parameters can be passed in via a matching - // "_opt" parameter. For example: - // protoc --plug_out=enable_bar:outdir --plug_opt=enable_baz - // This will pass "enable_bar,enable_baz" as the parameter to the plugin. - // + // + // Plugins can have generator parameters similar to normal built-in + // generators. Extra generator parameters can be passed in via a matching + // "_opt" parameter. For example: + // protoc --plug_out=enable_bar:outdir --plug_opt=enable_baz + // This will pass "enable_bar,enable_baz" as the parameter to the plugin. + // void AllowPlugins(const TProtoStringType& exe_name_prefix); // Run the Protocol Compiler with the given command-line parameters. @@ -192,11 +192,11 @@ class PROTOC_EXPORT CommandLineInterface { // it calls strerror(). I'm not sure why you'd want to do this anyway. int Run(int argc, const char* const argv[]); - // DEPRECATED. Calling this method has no effect. Protocol compiler now - // always try to find the .proto file relative to the current directory - // first and if the file is not found, it will then treat the input path + // DEPRECATED. Calling this method has no effect. Protocol compiler now + // always try to find the .proto file relative to the current directory + // first and if the file is not found, it will then treat the input path // as a virtual path. - void SetInputsAreProtoPathRelative(bool /* enable */) {} + void SetInputsAreProtoPathRelative(bool /* enable */) {} // Provides some text which will be printed when the --version flag is // used. The version of libprotoc will also be printed on the next line @@ -269,25 +269,25 @@ class PROTOC_EXPORT CommandLineInterface { // Print the --help text to stderr. void PrintHelpText(); - // Loads proto_path_ into the provided source_tree. + // Loads proto_path_ into the provided source_tree. bool InitializeDiskSourceTree(DiskSourceTree* source_tree, DescriptorDatabase* fallback_database); - + // Verify that all the input files exist in the given database. bool VerifyInputFilesInDescriptors(DescriptorDatabase* fallback_database); - - // Parses input_files_ into parsed_files - bool ParseInputFiles(DescriptorPool* descriptor_pool, + + // Parses input_files_ into parsed_files + bool ParseInputFiles(DescriptorPool* descriptor_pool, DiskSourceTree* source_tree, - std::vector<const FileDescriptor*>* parsed_files); - + std::vector<const FileDescriptor*>* parsed_files); + // Generate the given output file from the given input. struct OutputDirective; // see below bool GenerateOutput(const std::vector<const FileDescriptor*>& parsed_files, const OutputDirective& output_directive, GeneratorContext* generator_context); - bool GeneratePluginOutput( - const std::vector<const FileDescriptor*>& parsed_files, + bool GeneratePluginOutput( + const std::vector<const FileDescriptor*>& parsed_files, const TProtoStringType& plugin_name, const TProtoStringType& parameter, GeneratorContext* generator_context, TProtoStringType* error); @@ -295,8 +295,8 @@ class PROTOC_EXPORT CommandLineInterface { bool EncodeOrDecode(const DescriptorPool* pool); // Implements the --descriptor_set_out option. - bool WriteDescriptorSet( - const std::vector<const FileDescriptor*>& parsed_files); + bool WriteDescriptorSet( + const std::vector<const FileDescriptor*>& parsed_files); // Implements the --dependency_out option bool GenerateDependencyManifestFile( @@ -358,7 +358,7 @@ class PROTOC_EXPORT CommandLineInterface { // protoc --foo_out=outputdir --foo_opt=enable_bar ... // Then there will be an entry ("--foo_out", "enable_bar") in this map. std::map<TProtoStringType, TProtoStringType> generator_parameters_; - // Similar to generator_parameters_, but stores the parameters for plugins. + // Similar to generator_parameters_, but stores the parameters for plugins. std::map<TProtoStringType, TProtoStringType> plugin_parameters_; // See AllowPlugins(). If this is empty, plugins aren't allowed. @@ -405,15 +405,15 @@ class PROTOC_EXPORT CommandLineInterface { proto_path_; // Search path for proto files. std::vector<TProtoStringType> input_files_; // Names of the input proto files. - // Names of proto files which are allowed to be imported. Used by build - // systems to enforce depend-on-what-you-import. + // Names of proto files which are allowed to be imported. Used by build + // systems to enforce depend-on-what-you-import. std::set<TProtoStringType> direct_dependencies_; bool direct_dependencies_explicitly_set_ = false; - - // 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. + + // 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. TProtoStringType direct_dependencies_violation_msg_; - + // output_directives_ lists all the files we are supposed to output and what // generator to use for each. struct OutputDirective { @@ -428,10 +428,10 @@ class PROTOC_EXPORT CommandLineInterface { // decoding. (Empty string indicates --decode_raw.) TProtoStringType codec_type_; - // If --descriptor_set_in was given, these are filenames containing - // parsed FileDescriptorSets to be used for loading protos. Otherwise, empty. + // If --descriptor_set_in was given, these are filenames containing + // parsed FileDescriptorSets to be used for loading protos. Otherwise, empty. std::vector<TProtoStringType> descriptor_set_in_names_; - + // If --descriptor_set_out was given, this is the filename to which the // FileDescriptorSet should be written. Otherwise, empty. TProtoStringType descriptor_set_out_name_; diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum.h index 8d3bd04c06..43f1e5f4a5 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum.h +++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum.h @@ -92,8 +92,8 @@ class EnumGenerator { const bool generate_array_size_; std::map<TProtoStringType, TProtoStringType> variables_; - - friend class FileGenerator; + + friend class FileGenerator; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumGenerator); }; diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum_field.cc index 9f21266a22..ce2a0e4591 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum_field.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum_field.cc @@ -136,8 +136,8 @@ void EnumFieldGenerator::GenerateCopyConstructorCode( io::Printer* printer) const { Formatter format(printer, variables_); format("$name$_ = from.$name$_;\n"); -} - +} + void EnumFieldGenerator::GenerateSerializeWithCachedSizesToArray( io::Printer* printer) const { Formatter format(printer, variables_); @@ -467,7 +467,7 @@ void RepeatedEnumFieldGenerator::GenerateByteSize(io::Printer* printer) const { "int>(this->_internal_$name$_size());"); format.Indent(); format( - "for (unsigned int i = 0; i < count; i++) {\n" + "for (unsigned int i = 0; i < count; i++) {\n" " data_size += ::$proto_ns$::internal::WireFormatLite::EnumSize(\n" " this->_internal_$name$(static_cast<int>(i)));\n" "}\n"); diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum_field.h index fbd64f645f..3fa64a8640 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum_field.h +++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum_field.h @@ -57,7 +57,7 @@ class EnumFieldGenerator : public FieldGenerator { void GenerateMergingCode(io::Printer* printer) const; void GenerateSwappingCode(io::Printer* printer) const; void GenerateConstructorCode(io::Printer* printer) const; - void GenerateCopyConstructorCode(io::Printer* printer) const; + void GenerateCopyConstructorCode(io::Printer* printer) const; void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const; void GenerateByteSize(io::Printer* printer) const; void GenerateConstinitInitializer(io::Printer* printer) const; @@ -96,7 +96,7 @@ class RepeatedEnumFieldGenerator : public FieldGenerator { void GenerateMergingCode(io::Printer* printer) const; void GenerateSwappingCode(io::Printer* printer) const; void GenerateConstructorCode(io::Printer* printer) const; - void GenerateCopyConstructorCode(io::Printer* printer) const {} + void GenerateCopyConstructorCode(io::Printer* printer) const {} void GenerateMergeFromCodedStream(io::Printer* printer) const; void GenerateMergeFromCodedStreamWithPacking(io::Printer* printer) const; void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const; diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_field.cc index 372f3cd76d..09261aaddc 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_field.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_field.cc @@ -289,12 +289,12 @@ void SetCommonFieldVariables(const FieldDescriptor* descriptor, AddAccessorAnnotations(descriptor, options, variables); - // These variables are placeholders to pick out the beginning and ends of - // identifiers for annotations (when doing so with existing variables would - // be ambiguous or impossible). They should never be set to anything but the - // empty string. - (*variables)["{"] = ""; - (*variables)["}"] = ""; + // These variables are placeholders to pick out the beginning and ends of + // identifiers for annotations (when doing so with existing variables would + // be ambiguous or impossible). They should never be set to anything but the + // empty string. + (*variables)["{"] = ""; + (*variables)["}"] = ""; } void FieldGenerator::SetHasBitIndex(int32_t has_bit_index) { diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_field.h index d16987d95b..b05f2d93fa 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_field.h +++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_field.h @@ -113,20 +113,20 @@ class FieldGenerator { io::Printer* /*printer*/) const {} // Generate lines of code (statements, not declarations) which clear the - // field. This is used to define the clear_$name$() method + // field. This is used to define the clear_$name$() method virtual void GenerateClearingCode(io::Printer* printer) const = 0; // Generate lines of code (statements, not declarations) which clear the // field as part of the Clear() method for the whole message. For message // types which have field presence bits, MessageGenerator::GenerateClear // will have already checked the presence bits. - // + // // Since most field types can re-use GenerateClearingCode, this method is // not pure virtual. - virtual void GenerateMessageClearingCode(io::Printer* printer) const { - GenerateClearingCode(printer); - } - + virtual void GenerateMessageClearingCode(io::Printer* printer) const { + GenerateClearingCode(printer); + } + // Generate lines of code (statements, not declarations) which merges the // contents of the field from the current message to the target message, // which is stored in the generated code variable "from". @@ -135,9 +135,9 @@ class FieldGenerator { // GenerateMergeFrom method. virtual void GenerateMergingCode(io::Printer* printer) const = 0; - // Generates a copy constructor - virtual void GenerateCopyConstructorCode(io::Printer* printer) const = 0; - + // Generates a copy constructor + virtual void GenerateCopyConstructorCode(io::Printer* printer) const = 0; + // Generate lines of code (statements, not declarations) which swaps // this field and the corresponding field of another message, which // is stored in the generated code variable "other". This is used to diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_file.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_file.cc index 1775adc710..6218cfa8b5 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_file.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_file.cc @@ -40,7 +40,7 @@ #include <set> #include <unordered_map> #include <unordered_set> -#include <vector> +#include <vector> #include <google/protobuf/compiler/cpp/cpp_enum.h> #include <google/protobuf/compiler/cpp/cpp_extension.h> @@ -61,15 +61,15 @@ namespace protobuf { namespace compiler { namespace cpp { -namespace { +namespace { // When we forward-declare things, we want to create a sorted order so our // output is deterministic and minimizes namespace changes. template <class T> TProtoStringType GetSortKey(const T& val) { return val.full_name(); -} - +} + template <> TProtoStringType GetSortKey<FileDescriptor>(const FileDescriptor& val) { return val.name(); @@ -78,17 +78,17 @@ TProtoStringType GetSortKey<FileDescriptor>(const FileDescriptor& val) { template <class T> bool CompareSortKeys(const T* a, const T* b) { return GetSortKey(*a) < GetSortKey(*b); -} - +} + template <class T> std::vector<const T*> Sorted(const std::unordered_set<const T*>& vals) { std::vector<const T*> sorted(vals.begin(), vals.end()); std::sort(sorted.begin(), sorted.end(), CompareSortKeys<T>); return sorted; -} - -} // namespace - +} + +} // namespace + FileGenerator::FileGenerator(const FileDescriptor* file, const Options& options) : file_(file), options_(options), scc_analyzer_(options) { // These variables are the same on a file level @@ -123,14 +123,14 @@ FileGenerator::FileGenerator(const FileDescriptor* file, const Options& options) service_generators_.emplace_back( new ServiceGenerator(file->service(i), variables_, options)); } - if (HasGenericServices(file_, options_)) { - for (int i = 0; i < service_generators_.size(); i++) { - service_generators_[i]->index_in_metadata_ = i; - } - } + if (HasGenericServices(file_, options_)) { + for (int i = 0; i < service_generators_.size(); i++) { + service_generators_[i]->index_in_metadata_ = i; + } + } for (int i = 0; i < file->extension_count(); i++) { extension_generators_.emplace_back( - new ExtensionGenerator(file->extension(i), options)); + new ExtensionGenerator(file->extension(i), options)); } for (int i = 0; i < file->weak_dependency_count(); ++i) { weak_deps_.insert(file->weak_dependency(i)); @@ -139,7 +139,7 @@ FileGenerator::FileGenerator(const FileDescriptor* file, const Options& options) FileGenerator::~FileGenerator() = default; -void FileGenerator::GenerateMacroUndefs(io::Printer* printer) { +void FileGenerator::GenerateMacroUndefs(io::Printer* printer) { Formatter format(printer, variables_); // 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 @@ -161,22 +161,22 @@ void FileGenerator::GenerateMacroUndefs(io::Printer* printer) { } } } - for (int i = 0; i < names_to_undef.size(); ++i) { + for (int i = 0; i < names_to_undef.size(); ++i) { format( "#ifdef $1$\n" "#undef $1$\n" - "#endif\n", + "#endif\n", names_to_undef[i]); - } -} - -void FileGenerator::GenerateHeader(io::Printer* printer) { + } +} + +void FileGenerator::GenerateHeader(io::Printer* printer) { Formatter format(printer, variables_); // port_def.inc must be included after all other includes. IncludeFile("net/proto2/public/port_def.inc", printer); format("#define $1$$ dllexport_decl$\n", FileDllExport(file_, options_)); - GenerateMacroUndefs(printer); + GenerateMacroUndefs(printer); // For Any support with lite protos, we need to friend AnyMetadata, so we // forward-declare it here. @@ -231,17 +231,17 @@ void FileGenerator::GenerateHeader(io::Printer* printer) { "// @@protoc_insertion_point(global_scope)\n" "\n"); IncludeFile("net/proto2/public/port_undef.inc", printer); -} +} -void FileGenerator::GenerateProtoHeader(io::Printer* printer, +void FileGenerator::GenerateProtoHeader(io::Printer* printer, const TProtoStringType& info_path) { Formatter format(printer, variables_); - if (!options_.proto_h) { - return; - } - + if (!options_.proto_h) { + return; + } + GenerateTopHeaderGuard(printer, false); - + if (!options_.opensource_runtime) { format( "#ifdef SWIG\n" @@ -249,25 +249,25 @@ void FileGenerator::GenerateProtoHeader(io::Printer* printer, "#endif // SWIG\n" "\n"); } - + if (IsBootstrapProto(options_, file_)) { format("// IWYU pragma: private, include \"$1$.proto.h\"\n\n", StripProto(file_->name())); } - GenerateLibraryIncludes(printer); - - for (int i = 0; i < file_->public_dependency_count(); i++) { - const FileDescriptor* dep = file_->public_dependency(i); + GenerateLibraryIncludes(printer); + + for (int i = 0; i < file_->public_dependency_count(); i++) { + const FileDescriptor* dep = file_->public_dependency(i); format("#include \"$1$.proto.h\"\n", StripProto(dep->name())); - } - + } + format("// @@protoc_insertion_point(includes)\n"); - GenerateMetadataPragma(printer, info_path); - - GenerateHeader(printer); - + GenerateMetadataPragma(printer, info_path); + + GenerateHeader(printer); + GenerateBottomHeaderGuard(printer, false); } @@ -286,7 +286,7 @@ void FileGenerator::GeneratePBHeader(io::Printer* printer, } else { GenerateLibraryIncludes(printer); } - + if (options_.transitive_pb_h) { GenerateDependencyIncludes(printer); } @@ -299,8 +299,8 @@ void FileGenerator::GeneratePBHeader(io::Printer* printer, GenerateMetadataPragma(printer, info_path); if (!options_.proto_h) { - GenerateHeader(printer); - } else { + GenerateHeader(printer); + } else { { NamespaceOpener ns(Namespace(file_, options_), format); format( @@ -392,7 +392,7 @@ void FileGenerator::GenerateSourceIncludes(io::Printer* printer) { IncludeFile("net/proto2/public/wire_format_lite.h", printer); // Unknown fields implementation in lite mode uses StringOutputStream - if (!UseUnknownFieldSet(file_, options_) && !message_generators_.empty()) { + if (!UseUnknownFieldSet(file_, options_) && !message_generators_.empty()) { IncludeFile("net/proto2/io/public/zero_copy_stream_impl_lite.h", printer); } @@ -468,9 +468,9 @@ void FileGenerator::GenerateSourceDefaultInstance(int idx, DefaultInstanceType(generator->descriptor_, options_), DefaultInstancePtr(generator->descriptor_, options_), DefaultInstanceName(generator->descriptor_, options_)); - } + } } - + // A list of things defined in one .pb.cc file that we need to reference from // another .pb.cc file. struct FileGenerator::CrossFileReferences { @@ -490,7 +490,7 @@ void FileGenerator::GetCrossFileReferencesForField(const FieldDescriptor* field, if (IsImplicitWeakField(field, options_, &scc_analyzer_) || IsWeak(field, options_)) { refs->weak_default_instances.insert(msg); - } + } } void FileGenerator::GetCrossFileReferencesForFile(const FileDescriptor* file, @@ -507,15 +507,15 @@ void FileGenerator::GetCrossFileReferencesForFile(const FileDescriptor* file, refs->weak_reflection_files.insert(dep); } else { refs->strong_reflection_files.insert(dep); - } - } + } + } } - + // Generates references to variables defined in other files. void FileGenerator::GenerateInternalForwardDeclarations( const CrossFileReferences& refs, io::Printer* printer) { Formatter format(printer, variables_); - + { NamespaceOpener ns(format); for (auto instance : Sorted(refs.weak_default_instances)) { @@ -574,10 +574,10 @@ void FileGenerator::GenerateSourceForMessage(int idx, io::Printer* printer) { } format( - "\n" + "\n" "// @@protoc_insertion_point(global_scope)\n"); } - + void FileGenerator::GenerateGlobalSource(io::Printer* printer) { Formatter format(printer, variables_); GenerateSourceIncludes(printer); @@ -595,7 +595,7 @@ void FileGenerator::GenerateGlobalSource(io::Printer* printer) { NamespaceOpener ns(Namespace(file_, options_), format); // Generate enums. - for (int i = 0; i < enum_generators_.size(); i++) { + for (int i = 0; i < enum_generators_.size(); i++) { enum_generators_[i]->GenerateMethods(i, printer); } @@ -606,7 +606,7 @@ void FileGenerator::GenerateGlobalSource(io::Printer* printer) { if (HasGenericServices(file_, options_)) { // Generate services. - for (int i = 0; i < service_generators_.size(); i++) { + for (int i = 0; i < service_generators_.size(); i++) { if (i == 0) format("\n"); format(kThickSeparator); format("\n"); @@ -650,7 +650,7 @@ void FileGenerator::GenerateSource(io::Printer* printer) { for (int i = 0; i < enum_generators_.size(); i++) { enum_generators_[i]->GenerateMethods(i, printer); } - + // Generate classes. for (int i = 0; i < message_generators_.size(); i++) { format("\n"); @@ -689,17 +689,17 @@ void FileGenerator::GenerateSource(io::Printer* printer) { format( "\n" "// @@protoc_insertion_point(global_scope)\n"); - + IncludeFile("net/proto2/public/port_undef.inc", printer); } - + void FileGenerator::GenerateReflectionInitializationCode(io::Printer* printer) { Formatter format(printer, variables_); - + if (!message_generators_.empty()) { format("static ::$proto_ns$::Metadata $file_level_metadata$[$1$];\n", message_generators_.size()); - } + } if (!enum_generators_.empty()) { format( "static " @@ -724,7 +724,7 @@ void FileGenerator::GenerateReflectionInitializationCode(io::Printer* printer) { "constexpr ::$proto_ns$::ServiceDescriptor const** " "$file_level_service_descriptors$ = nullptr;\n"); } - + if (!message_generators_.empty()) { format( "\n" @@ -779,10 +779,10 @@ void FileGenerator::GenerateReflectionInitializationCode(io::Printer* printer) { "static constexpr ::$proto_ns$::Message* const* " "file_default_instances = nullptr;\n" "\n"); - } - + } + // --------------------------------------------------------------- - + // Embed the descriptor. We simply serialize the entire // FileDescriptorProto/ and embed it as a string literal, which is parsed and // built into real descriptors at initialization time. @@ -820,9 +820,9 @@ void FileGenerator::GenerateReflectionInitializationCode(io::Printer* printer) { } } format(";\n"); - } + } format.Outdent(); - + CrossFileReferences refs; GetCrossFileReferencesForFile(file_, &refs); int num_deps = @@ -843,8 +843,8 @@ void FileGenerator::GenerateReflectionInitializationCode(io::Printer* printer) { } format("};\n"); - } - + } + // The DescriptorTable itself. // Should be "bool eager = NeedsEagerDescriptorAssignment(file_, options_);" // however this might cause a tsan failure in superroot b/148382879, @@ -858,7 +858,7 @@ void FileGenerator::GenerateReflectionInitializationCode(io::Printer* printer) { " schemas, file_default_instances, $tablename$::offsets,\n" " $7$, $file_level_enum_descriptors$, " "$file_level_service_descriptors$,\n" - "};\n" + "};\n" // This function exists to be marked as weak. // It can significantly speed up compilation by breaking up LLVM's SCC in // the .pb.cc translation units. Large translation units see a reduction @@ -880,7 +880,7 @@ void FileGenerator::GenerateReflectionInitializationCode(io::Printer* printer) { message_generators_.size(), message_generators_.empty() ? "nullptr" : variables_["file_level_metadata"]); - + // For descriptor.proto we want to avoid doing any dynamic initialization, // because in some situations that would otherwise pull in a lot of // unnecessary code that can't be stripped by --gc-sections. Descriptor @@ -892,9 +892,9 @@ void FileGenerator::GenerateReflectionInitializationCode(io::Printer* printer) { "static ::$proto_ns$::internal::AddDescriptorsRunner " "$1$(&$desc_table$);\n", UniqueName("dynamic_init_dummy", file_, options_)); - } + } } - + void FileGenerator::GenerateTables(io::Printer* printer) { Formatter format(printer, variables_); if (options_.table_driven_parsing) { @@ -965,44 +965,44 @@ void FileGenerator::GenerateTables(io::Printer* printer) { format( "};\n" "\n"); - } - - if (!message_generators_.empty() && options_.table_driven_serialization) { + } + + if (!message_generators_.empty() && options_.table_driven_serialization) { format( "const ::$proto_ns$::internal::FieldMetadata " "$tablename$::field_metadata[] " - "= {\n"); + "= {\n"); format.Indent(); - std::vector<int> field_metadata_offsets; - int idx = 0; - for (int i = 0; i < message_generators_.size(); i++) { - field_metadata_offsets.push_back(idx); - idx += message_generators_[i]->GenerateFieldMetadata(printer); - } - field_metadata_offsets.push_back(idx); + std::vector<int> field_metadata_offsets; + int idx = 0; + for (int i = 0; i < message_generators_.size(); i++) { + field_metadata_offsets.push_back(idx); + idx += message_generators_[i]->GenerateFieldMetadata(printer); + } + field_metadata_offsets.push_back(idx); format.Outdent(); format( - "};\n" + "};\n" "const ::$proto_ns$::internal::SerializationTable " "$tablename$::serialization_table[] = {\n"); format.Indent(); - // We rely on the order we layout the tables to match the order we - // calculate them with FlattenMessagesInFile, so we check here that - // these match exactly. - std::vector<const Descriptor*> calculated_order = - FlattenMessagesInFile(file_); - GOOGLE_CHECK_EQ(calculated_order.size(), message_generators_.size()); - for (int i = 0; i < message_generators_.size(); i++) { - GOOGLE_CHECK_EQ(calculated_order[i], message_generators_[i]->descriptor_); + // We rely on the order we layout the tables to match the order we + // calculate them with FlattenMessagesInFile, so we check here that + // these match exactly. + std::vector<const Descriptor*> calculated_order = + FlattenMessagesInFile(file_); + GOOGLE_CHECK_EQ(calculated_order.size(), message_generators_.size()); + for (int i = 0; i < message_generators_.size(); i++) { + GOOGLE_CHECK_EQ(calculated_order[i], message_generators_[i]->descriptor_); format("{$1$, $tablename$::field_metadata + $2$},\n", field_metadata_offsets[i + 1] - field_metadata_offsets[i], // 1 field_metadata_offsets[i]); // 2 - } + } format.Outdent(); format( - "};\n" - "\n"); - } + "};\n" + "\n"); + } } class FileGenerator::ForwardDeclarations { @@ -1018,7 +1018,7 @@ class FileGenerator::ForwardDeclarations { "enum ${1$$2$$}$ : int;\n" "bool $2$_IsValid(int value);\n", enum_desc, enumname); - } + } for (const auto& p : classes_) { const TProtoStringType& classname = p.first; const Descriptor* class_desc = p.second; @@ -1038,7 +1038,7 @@ class FileGenerator::ForwardDeclarations { "template<> $dllexport_decl $" "$1$* Arena::CreateMaybeMessage<$1$>(Arena*);\n", QualifiedClassName(pair.second, options)); - } + } } private: @@ -1058,9 +1058,9 @@ void FileGenerator::GenerateForwardDeclarations(io::Printer* printer) { Formatter format(printer, variables_); std::vector<const Descriptor*> classes; std::vector<const EnumDescriptor*> enums; - + FlattenMessagesInFile(file_, &classes); // All messages need forward decls. - + if (options_.proto_h) { // proto.h needs extra forward declarations. // All classes / enums referred to as field members std::vector<const FieldDescriptor*> fields; @@ -1083,7 +1083,7 @@ void FileGenerator::GenerateForwardDeclarations(io::Printer* printer) { const Descriptor* d = classes[i]; if (d && !public_set.count(d->file())) decls[Namespace(d, options_)].AddMessage(d); - } + } for (int i = 0; i < enums.size(); i++) { const EnumDescriptor* d = enums[i]; if (d && !public_set.count(d->file())) @@ -1177,12 +1177,12 @@ void FileGenerator::GenerateLibraryIncludes(io::Printer* printer) { } IncludeFile("net/proto2/public/generated_message_util.h", printer); IncludeFile("net/proto2/public/metadata_lite.h", printer); - - if (HasDescriptorMethods(file_, options_)) { + + if (HasDescriptorMethods(file_, options_)) { IncludeFile("net/proto2/public/generated_message_reflection.h", printer); - } - - if (!message_generators_.empty()) { + } + + if (!message_generators_.empty()) { if (HasDescriptorMethods(file_, options_)) { IncludeFile("net/proto2/public/message.h", printer); } else { @@ -1231,7 +1231,7 @@ void FileGenerator::GenerateLibraryIncludes(io::Printer* printer) { IncludeFile("net/proto2/public/service.h", printer); } - if (UseUnknownFieldSet(file_, options_) && !message_generators_.empty()) { + if (UseUnknownFieldSet(file_, options_) && !message_generators_.empty()) { IncludeFile("net/proto2/public/unknown_field_set.h", printer); } } @@ -1279,7 +1279,7 @@ void FileGenerator::GenerateGlobalStateFunctionDeclarations( // Also it annotates extra weak attributes. // TODO(gerbens) make sure this situation is handled better. format( - "\n" + "\n" "// Internal implementation detail -- do not use these members.\n" "struct $dllexport_decl $$tablename$ {\n" // These tables describe how to serialize and parse messages. Used @@ -1292,7 +1292,7 @@ void FileGenerator::GenerateGlobalStateFunctionDeclarations( " PROTOBUF_SECTION_VARIABLE(protodesc_cold);\n" " static const ::$proto_ns$::internal::FieldMetadata field_metadata[];\n" " static const ::$proto_ns$::internal::SerializationTable " - "serialization_table[];\n" + "serialization_table[];\n" " static const $uint32$ offsets[];\n" "};\n", std::max(size_t(1), message_generators_.size())); @@ -1306,7 +1306,7 @@ void FileGenerator::GenerateGlobalStateFunctionDeclarations( void FileGenerator::GenerateMessageDefinitions(io::Printer* printer) { Formatter format(printer, variables_); // Generate class definitions. - for (int i = 0; i < message_generators_.size(); i++) { + for (int i = 0; i < message_generators_.size(); i++) { if (i > 0) { format("\n"); format(kThinSeparator); @@ -1318,7 +1318,7 @@ void FileGenerator::GenerateMessageDefinitions(io::Printer* printer) { void FileGenerator::GenerateEnumDefinitions(io::Printer* printer) { // Generate enum definitions. - for (int i = 0; i < enum_generators_.size(); i++) { + for (int i = 0; i < enum_generators_.size(); i++) { enum_generators_[i]->GenerateDefinition(printer); } } @@ -1327,7 +1327,7 @@ void FileGenerator::GenerateServiceDefinitions(io::Printer* printer) { Formatter format(printer, variables_); if (HasGenericServices(file_, options_)) { // Generate service definitions. - for (int i = 0; i < service_generators_.size(); i++) { + for (int i = 0; i < service_generators_.size(); i++) { if (i > 0) { format("\n"); format(kThinSeparator); @@ -1343,8 +1343,8 @@ void FileGenerator::GenerateServiceDefinitions(io::Printer* printer) { } void FileGenerator::GenerateExtensionIdentifiers(io::Printer* printer) { - // Declare extension identifiers. These are in global scope and so only - // the global scope extensions. + // Declare extension identifiers. These are in global scope and so only + // the global scope extensions. for (auto& extension_generator : extension_generators_) { if (extension_generator->IsScoped()) continue; extension_generator->GenerateDeclaration(printer); @@ -1353,15 +1353,15 @@ void FileGenerator::GenerateExtensionIdentifiers(io::Printer* printer) { void FileGenerator::GenerateInlineFunctionDefinitions(io::Printer* printer) { Formatter format(printer, variables_); - // TODO(gerbens) remove pragmas when gcc is no longer used. Current version - // of gcc fires a bogus error when compiled with strict-aliasing. + // TODO(gerbens) remove pragmas when gcc is no longer used. Current version + // of gcc fires a bogus error when compiled with strict-aliasing. format( "#ifdef __GNUC__\n" " #pragma GCC diagnostic push\n" " #pragma GCC diagnostic ignored \"-Wstrict-aliasing\"\n" "#endif // __GNUC__\n"); // Generate class inline methods. - for (int i = 0; i < message_generators_.size(); i++) { + for (int i = 0; i < message_generators_.size(); i++) { if (i > 0) { format(kThinSeparator); format("\n"); @@ -1373,7 +1373,7 @@ void FileGenerator::GenerateInlineFunctionDefinitions(io::Printer* printer) { " #pragma GCC diagnostic pop\n" "#endif // __GNUC__\n"); - for (int i = 0; i < message_generators_.size(); i++) { + for (int i = 0; i < message_generators_.size(); i++) { if (i > 0) { format(kThinSeparator); format("\n"); diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_file.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_file.h index 79cda398c7..41e3907391 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_file.h +++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_file.h @@ -71,9 +71,9 @@ class FileGenerator { FileGenerator(const FileDescriptor* file, const Options& options); ~FileGenerator(); - // Shared code between the two header generators below. - void GenerateHeader(io::Printer* printer); - + // Shared code between the two header generators below. + void GenerateHeader(io::Printer* printer); + // info_path, if non-empty, should be the path (relative to printer's // output) to the metadata file describing this proto header. void GenerateProtoHeader(io::Printer* printer, const TProtoStringType& info_path); @@ -160,8 +160,8 @@ class FileGenerator { // undef the macro for these few platforms, or rename the field name for all // platforms. Since these names are part of protobuf public API, renaming is // generally a breaking change so we prefer the #undef approach. - void GenerateMacroUndefs(io::Printer* printer); - + void GenerateMacroUndefs(io::Printer* printer); + bool IsDepWeak(const FileDescriptor* dep) const { if (weak_deps_.count(dep) != 0) { GOOGLE_CHECK(!options_.opensource_runtime); @@ -176,11 +176,11 @@ class FileGenerator { const Options options_; MessageSCCAnalyzer scc_analyzer_; - + std::map<TProtoStringType, TProtoStringType> variables_; - // 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. + // 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<std::unique_ptr<MessageGenerator>> message_generators_; std::vector<std::unique_ptr<EnumGenerator>> enum_generators_; std::vector<std::unique_ptr<ServiceGenerator>> service_generators_; diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_generator.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_generator.cc index 63d10dd8bf..1e2d01d147 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_generator.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_generator.cc @@ -112,10 +112,10 @@ bool CppGenerator::Generate(const FileDescriptor* file, file_options.eagerly_verified_lazy = true; } else if (options[i].first == "force_eagerly_verified_lazy") { file_options.force_eagerly_verified_lazy = true; - } else if (options[i].first == "table_driven_parsing") { - file_options.table_driven_parsing = true; - } else if (options[i].first == "table_driven_serialization") { - file_options.table_driven_serialization = true; + } else if (options[i].first == "table_driven_parsing") { + file_options.table_driven_parsing = true; + } else if (options[i].first == "table_driven_serialization") { + file_options.table_driven_serialization = true; } else if (options[i].first == "experimental_tail_call_table_mode") { if (options[i].second == "never") { file_options.tctable_mode = Options::kTCTableNever; diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_helpers.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_helpers.cc index 3f975a8bbc..0f9660d237 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_helpers.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_helpers.cc @@ -407,7 +407,7 @@ TProtoStringType Namespace(const FileDescriptor* d, const Options& options) { TProtoStringType Namespace(const Descriptor* d, const Options& options) { return Namespace(d->file(), options); -} +} TProtoStringType Namespace(const FieldDescriptor* d, const Options& options) { return Namespace(d->file(), options); @@ -731,7 +731,7 @@ TProtoStringType DefaultValue(const Options& options, const FieldDescriptor* fie "\""; case FieldDescriptor::CPPTYPE_MESSAGE: return "*" + FieldMessageTypeName(field, options) + - "::internal_default_instance()"; + "::internal_default_instance()"; } // Can't actually get here; make compiler happy. (We could add a default // case above but then we wouldn't get the nice compiler warning when a @@ -1099,44 +1099,44 @@ void GenerateUtf8CheckCodeForCord(const FieldDescriptor* field, "VerifyUTF8CordNamedField", format); } -namespace { - -void Flatten(const Descriptor* descriptor, - std::vector<const Descriptor*>* flatten) { - for (int i = 0; i < descriptor->nested_type_count(); i++) - Flatten(descriptor->nested_type(i), flatten); - flatten->push_back(descriptor); -} - -} // namespace - +namespace { + +void Flatten(const Descriptor* descriptor, + std::vector<const Descriptor*>* flatten) { + for (int i = 0; i < descriptor->nested_type_count(); i++) + Flatten(descriptor->nested_type(i), flatten); + flatten->push_back(descriptor); +} + +} // namespace + void FlattenMessagesInFile(const FileDescriptor* file, std::vector<const Descriptor*>* result) { - for (int i = 0; i < file->message_type_count(); i++) { + for (int i = 0; i < file->message_type_count(); i++) { Flatten(file->message_type(i), result); - } -} - + } +} + bool HasWeakFields(const Descriptor* descriptor, const Options& options) { for (int i = 0; i < descriptor->field_count(); i++) { if (IsWeak(descriptor->field(i), options)) return true; } - return false; -} - + return false; +} + bool HasWeakFields(const FileDescriptor* file, const Options& options) { for (int i = 0; i < file->message_type_count(); ++i) { if (HasWeakFields(file->message_type(i), options)) return true; } - return false; -} - + return false; +} + bool UsingImplicitWeakFields(const FileDescriptor* file, const Options& options) { return options.lite_implicit_weak_fields && GetOptimizeFor(file, options) == FileOptions::LITE_RUNTIME; } - + bool IsImplicitWeakField(const FieldDescriptor* field, const Options& options, MessageSCCAnalyzer* scc_analyzer) { return UsingImplicitWeakFields(field->file(), options) && @@ -1150,67 +1150,67 @@ bool IsImplicitWeakField(const FieldDescriptor* field, const Options& options, // strongly-connected component. scc_analyzer->GetSCC(field->containing_type()) != scc_analyzer->GetSCC(field->message_type()); -} - +} + MessageAnalysis MessageSCCAnalyzer::GetSCCAnalysis(const SCC* scc) { - if (analysis_cache_.count(scc)) return analysis_cache_[scc]; + if (analysis_cache_.count(scc)) return analysis_cache_[scc]; MessageAnalysis result{}; if (UsingImplicitWeakFields(scc->GetFile(), options_)) { result.contains_weak = true; } - 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; - } + 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; + } if (field->options().weak()) { result.contains_weak = 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: { + 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 = analyzer_.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; - } + 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; + } result.contains_weak |= analysis.contains_weak; - } 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; -} - + } 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; +} + void ListAllFields(const Descriptor* d, std::vector<const FieldDescriptor*>* fields) { // Collect sub messages diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_helpers.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_helpers.h index 0e07da4ac2..1cc9329c86 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_helpers.h +++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_helpers.h @@ -157,10 +157,10 @@ TProtoStringType DefaultInstanceName(const Descriptor* descriptor, TProtoStringType DefaultInstancePtr(const Descriptor* descriptor, const Options& options); -// Fully qualified name of the default_instance of this message. +// Fully qualified name of the default_instance of this message. TProtoStringType QualifiedDefaultInstanceName(const Descriptor* descriptor, const Options& options); - + // Fully qualified name of the default instance pointer. TProtoStringType QualifiedDefaultInstancePtr(const Descriptor* descriptor, const Options& options); @@ -291,8 +291,8 @@ TProtoStringType SafeFunctionName(const Descriptor* descriptor, const FieldDescriptor* field, const TProtoStringType& prefix); -// Returns true if generated messages have public unknown fields accessors -inline bool PublicUnknownFieldsAccessors(const Descriptor* message) { +// Returns true if generated messages have public unknown fields accessors +inline bool PublicUnknownFieldsAccessors(const Descriptor* message) { return message->file()->syntax() != FileDescriptor::SYNTAX_PROTO3; } @@ -300,8 +300,8 @@ inline bool PublicUnknownFieldsAccessors(const Descriptor* message) { FileOptions_OptimizeMode GetOptimizeFor(const FileDescriptor* file, const Options& options); -// Determines whether unknown fields will be stored in an UnknownFieldSet or -// a string. +// Determines whether unknown fields will be stored in an UnknownFieldSet or +// a string. inline bool UseUnknownFieldSet(const FileDescriptor* file, const Options& options) { return GetOptimizeFor(file, options) != FileOptions::LITE_RUNTIME; @@ -523,7 +523,7 @@ inline bool NeedsEagerDescriptorAssignment(const FileDescriptor* file, } } -// This orders the messages in a .pb.cc as it's outputted by file.cc +// This orders the messages in a .pb.cc as it's outputted by file.cc void FlattenMessagesInFile(const FileDescriptor* file, std::vector<const Descriptor*>* result); inline std::vector<const Descriptor*> FlattenMessagesInFile( @@ -532,40 +532,40 @@ inline std::vector<const Descriptor*> FlattenMessagesInFile( FlattenMessagesInFile(file, &result); return result; } - + bool HasWeakFields(const Descriptor* desc, const Options& options); bool HasWeakFields(const FileDescriptor* desc, const Options& options); - -// Returns true if the "required" restriction check should be ignored for the -// given field. + +// Returns true if the "required" restriction check should be ignored for the +// given field. inline static bool ShouldIgnoreRequiredFieldCheck(const FieldDescriptor* field, const Options& options) { // Do not check "required" for lazily verified lazy fields. return IsLazilyVerifiedLazy(field, options); -} - -struct MessageAnalysis { - bool is_recursive; - bool contains_cord; - bool contains_extension; - bool contains_required; +} + +struct MessageAnalysis { + bool is_recursive; + bool contains_cord; + bool contains_extension; + bool contains_required; bool contains_weak; // Implicit weak as well. -}; - -// 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. +}; + +// 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 PROTOC_EXPORT MessageSCCAnalyzer { - public: + public: explicit MessageSCCAnalyzer(const Options& options) : options_(options) {} - - MessageAnalysis GetSCCAnalysis(const SCC* scc); - - bool HasRequiredFields(const Descriptor* descriptor) { - MessageAnalysis result = GetSCCAnalysis(GetSCC(descriptor)); - return result.contains_required || result.contains_extension; - } + + MessageAnalysis GetSCCAnalysis(const SCC* scc); + + bool HasRequiredFields(const Descriptor* descriptor) { + MessageAnalysis result = GetSCCAnalysis(GetSCC(descriptor)); + return result.contains_required || result.contains_extension; + } bool HasWeakField(const Descriptor* descriptor) { MessageAnalysis result = GetSCCAnalysis(GetSCC(descriptor)); return result.contains_weak; @@ -573,8 +573,8 @@ class PROTOC_EXPORT MessageSCCAnalyzer { const SCC* GetSCC(const Descriptor* descriptor) { return analyzer_.GetSCC(descriptor); } - - private: + + private: struct DepsGenerator { std::vector<const Descriptor*> operator()(const Descriptor* desc) const { std::vector<const Descriptor*> deps; @@ -585,12 +585,12 @@ class PROTOC_EXPORT MessageSCCAnalyzer { } return deps; } - }; + }; SCCAnalyzer<DepsGenerator> analyzer_; - Options options_; - std::map<const SCC*, MessageAnalysis> analysis_cache_; + Options options_; + std::map<const SCC*, MessageAnalysis> analysis_cache_; }; - + void ListAllFields(const Descriptor* d, std::vector<const FieldDescriptor*>* fields); void ListAllFields(const FileDescriptor* d, @@ -600,7 +600,7 @@ template <class T> void ForEachField(const Descriptor* d, T&& func) { for (int i = 0; i < d->nested_type_count(); i++) { ForEachField(d->nested_type(i), std::forward<T&&>(func)); - } + } for (int i = 0; i < d->extension_count(); i++) { func(d->extension(i)); } @@ -608,7 +608,7 @@ void ForEachField(const Descriptor* d, T&& func) { func(d->field(i)); } } - + template <class T> void ForEachField(const FileDescriptor* d, T&& func) { for (int i = 0; i < d->message_type_count(); i++) { @@ -735,8 +735,8 @@ class PROTOC_EXPORT Formatter { annotation.set_source_file(descriptor->file()->name()); return annotation.SerializeAsString(); } -}; - +}; + template <class T> void PrintFieldComment(const Formatter& format, const T* field) { // Print the field's (or oneof's) proto-syntax definition as a comment. diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_map_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_map_field.cc index 5e67a80f3f..f8e1c380cc 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_map_field.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_map_field.cc @@ -50,7 +50,7 @@ void SetMessageVariables(const FieldDescriptor* descriptor, std::map<TProtoStringType, TProtoStringType>* variables, const Options& options) { SetCommonFieldVariables(descriptor, variables, options); - (*variables)["type"] = ClassName(descriptor->message_type(), false); + (*variables)["type"] = ClassName(descriptor->message_type(), false); (*variables)["full_name"] = descriptor->full_name(); const FieldDescriptor* key = @@ -162,10 +162,10 @@ void MapFieldGenerator::GenerateSwappingCode(io::Printer* printer) const { void MapFieldGenerator::GenerateCopyConstructorCode( io::Printer* printer) const { - GenerateConstructorCode(printer); - GenerateMergingCode(printer); -} - + GenerateConstructorCode(printer); + GenerateMergingCode(printer); +} + static void GenerateSerializationLoop(const Formatter& format, bool string_key, bool string_value, bool is_deterministic) { @@ -236,12 +236,12 @@ void MapFieldGenerator::GenerateSerializeWithCachedSizesToArray( format.Indent(); format.Indent(); if (string_key) { - GenerateUtf8CheckCodeForString( + GenerateUtf8CheckCodeForString( key_field, options_, false, "p->first.data(), static_cast<int>(p->first.length()),\n", format); } if (string_value) { - GenerateUtf8CheckCodeForString( + GenerateUtf8CheckCodeForString( value_field, options_, false, "p->second.data(), static_cast<int>(p->second.length()),\n", format); } @@ -264,9 +264,9 @@ void MapFieldGenerator::GenerateSerializeWithCachedSizesToArray( " for (::$proto_ns$::Map< $key_cpp$, $val_cpp$ >::const_iterator\n" " it = this->_internal_$name$().begin();\n" " it != this->_internal_$name$().end(); ++it, ++n) {\n" - " items[static_cast<ptrdiff_t>(n)] = SortItem(&*it);\n" + " items[static_cast<ptrdiff_t>(n)] = SortItem(&*it);\n" " }\n" - " ::std::sort(&items[0], &items[static_cast<ptrdiff_t>(n)], Less());\n"); + " ::std::sort(&items[0], &items[static_cast<ptrdiff_t>(n)], Less());\n"); format.Indent(); GenerateSerializationLoop(format, string_key, string_value, true); format.Outdent(); @@ -282,7 +282,7 @@ void MapFieldGenerator::GenerateSerializeWithCachedSizesToArray( void MapFieldGenerator::GenerateByteSize(io::Printer* printer) const { Formatter format(printer, variables_); format( - "total_size += $tag_size$ *\n" + "total_size += $tag_size$ *\n" " " "::$proto_ns$::internal::FromIntSize(this->_internal_$name$_size());\n" "for (::$proto_ns$::Map< $key_cpp$, $val_cpp$ >::const_iterator\n" diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message.cc index 7e33770d58..cb890d5156 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message.cc @@ -33,7 +33,7 @@ // Sanjay Ghemawat, Jeff Dean, and others. #include <google/protobuf/compiler/cpp/cpp_message.h> - + #include <algorithm> #include <cstdint> #include <functional> @@ -42,7 +42,7 @@ #include <unordered_map> #include <utility> #include <vector> - + #include <google/protobuf/compiler/cpp/cpp_enum.h> #include <google/protobuf/compiler/cpp/cpp_extension.h> #include <google/protobuf/compiler/cpp/cpp_field.h> @@ -127,13 +127,13 @@ struct FieldOrderingByNumber { // Sort the fields of the given Descriptor by number into a new[]'d array // and return it. -std::vector<const FieldDescriptor*> SortFieldsByNumber( - const Descriptor* descriptor) { - std::vector<const FieldDescriptor*> fields(descriptor->field_count()); +std::vector<const FieldDescriptor*> SortFieldsByNumber( + const Descriptor* descriptor) { + std::vector<const FieldDescriptor*> fields(descriptor->field_count()); for (int i = 0; i < descriptor->field_count(); i++) { fields[i] = descriptor->field(i); } - std::sort(fields.begin(), fields.end(), FieldOrderingByNumber()); + std::sort(fields.begin(), fields.end(), FieldOrderingByNumber()); return fields; } @@ -158,29 +158,29 @@ bool IsPOD(const FieldDescriptor* field) { case FieldDescriptor::CPPTYPE_BOOL: return true; case FieldDescriptor::CPPTYPE_STRING: - return false; - default: - return false; - } -} - + return false; + default: + return false; + } +} + // Helper for the code that emits the SharedCtor() and InternalSwap() methods. // Anything that is a POD or a "normal" message (represented by a pointer) can // be manipulated as raw bytes. bool CanBeManipulatedAsRawBytes(const FieldDescriptor* field, const Options& options, MessageSCCAnalyzer* scc_analyzer) { - bool ret = CanInitializeByZeroing(field); - - // Non-repeated, non-lazy message fields are simply raw pointers, so we can + bool ret = CanInitializeByZeroing(field); + + // Non-repeated, non-lazy message fields are simply raw pointers, so we can // swap them or use memset to initialize these in SharedCtor. We cannot use // this in Clear, as we need to potentially delete the existing value. ret = ret || (!field->is_repeated() && !IsLazy(field, options, scc_analyzer) && field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE); - return ret; -} - + return ret; +} + // Finds runs of fields for which `predicate` is true. // RunMap maps from fields that start each run to the number of fields in that // run. This is optimized for the common case that there are very few runs in @@ -190,12 +190,12 @@ RunMap FindRuns(const std::vector<const FieldDescriptor*>& fields, const std::function<bool(const FieldDescriptor*)>& predicate) { RunMap runs; const FieldDescriptor* last_start = nullptr; - + for (auto field : fields) { if (predicate(field)) { if (last_start == nullptr) { last_start = field; - } + } runs[last_start]++; } else { @@ -289,7 +289,7 @@ bool HasPrivateHasMethod(const FieldDescriptor* field) { // TODO(ckennelly): Cull these exclusions if/when these protos do not have // their methods overridden by subclasses. - + bool ShouldMarkClassAsFinal(const Descriptor* descriptor, const Options& options) { return false; @@ -319,65 +319,65 @@ bool ShouldSerializeInOrder(const Descriptor* descriptor, bool TableDrivenParsingEnabled(const Descriptor* descriptor, const Options& options, MessageSCCAnalyzer* scc_analyzer) { - if (!options.table_driven_parsing) { - return false; - } - - // Consider table-driven parsing. We only do this if: - // - We have has_bits for fields. This avoids a check on every field we set - // when are present (the common case). + if (!options.table_driven_parsing) { + return false; + } + + // Consider table-driven parsing. We only do this if: + // - We have has_bits for fields. This avoids a check on every field we set + // when are present (the common case). bool has_hasbit = false; for (int i = 0; i < descriptor->field_count(); i++) { if (HasHasbit(descriptor->field(i))) { has_hasbit = true; break; } - } - + } + if (!has_hasbit) return false; - const double table_sparseness = 0.5; - int max_field_number = 0; + const double table_sparseness = 0.5; + int max_field_number = 0; for (auto field : FieldRange(descriptor)) { - if (max_field_number < field->number()) { - max_field_number = field->number(); - } - - // - There are no weak fields. + if (max_field_number < field->number()) { + max_field_number = field->number(); + } + + // - There are no weak fields. if (IsWeak(field, options)) { - return false; - } + return false; + } // - There are no lazy fields (they require the non-lite library). if (IsLazy(field, options, scc_analyzer)) { 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. - // We check for strictly greater than in the case where there are no fields - // (only extensions) so max_field_number == descriptor->field_count() == 0. - if (max_field_number * table_sparseness > descriptor->field_count()) { - return false; - } - - // - This is not a MapEntryMessage. - if (IsMapEntryMessage(descriptor)) { - return false; - } - - return true; -} - + } + + // - 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. + // We check for strictly greater than in the case where there are no fields + // (only extensions) so max_field_number == descriptor->field_count() == 0. + if (max_field_number * table_sparseness > descriptor->field_count()) { + return false; + } + + // - This is not a MapEntryMessage. + if (IsMapEntryMessage(descriptor)) { + return false; + } + + return true; +} + bool IsCrossFileMapField(const FieldDescriptor* field) { if (!field->is_map()) { return false; - } + } const Descriptor* d = field->message_type(); const FieldDescriptor* value = d->FindFieldByNumber(2); @@ -388,11 +388,11 @@ bool IsCrossFileMapField(const FieldDescriptor* field) { bool IsCrossFileMaybeMap(const FieldDescriptor* field) { if (IsCrossFileMapField(field)) { return true; - } + } return IsCrossFileMessage(field); -} - +} + bool IsRequired(const std::vector<const FieldDescriptor*>& v) { return v.front()->is_required(); } @@ -566,8 +566,8 @@ MessageGenerator::MessageGenerator( classname_(ClassName(descriptor, false)), options_(options), field_generators_(descriptor, options, scc_analyzer), - max_has_bit_index_(0), - num_weak_fields_(0), + max_has_bit_index_(0), + num_weak_fields_(0), scc_analyzer_(scc_analyzer), variables_(vars) { if (!message_layout_helper_) { @@ -615,20 +615,20 @@ MessageGenerator::MessageGenerator( SetUnknownFieldsVariable(descriptor_, options_, &variables_); - // Compute optimized field order to be used for layout and initialization - // purposes. + // Compute optimized field order to be used for layout and initialization + // purposes. for (auto field : FieldRange(descriptor_)) { if (IsFieldStripped(field, options_)) { continue; } if (IsWeak(field, options_)) { - num_weak_fields_++; + num_weak_fields_++; } else if (!field->real_containing_oneof()) { - optimized_order_.push_back(field); - } - } - + optimized_order_.push_back(field); + } + } + message_layout_helper_->OptimizeLayout(&optimized_order_, options_, scc_analyzer_); @@ -637,11 +637,11 @@ MessageGenerator::MessageGenerator( if (HasHasbit(field)) { if (has_bit_indices_.empty()) { has_bit_indices_.resize(descriptor_->field_count(), kNoHasbit); - } - has_bit_indices_[field->index()] = max_has_bit_index_++; - } - } - + } + has_bit_indices_[field->index()] = max_has_bit_index_++; + } + } + if (!has_bit_indices_.empty()) { field_generators_.SetHasBitIndices(has_bit_indices_); } @@ -652,7 +652,7 @@ MessageGenerator::MessageGenerator( ++num_required_fields_; } } - + table_driven_ = TableDrivenParsingEnabled(descriptor_, options_, scc_analyzer_); parse_function_generator_.reset(new ParseFunctionGenerator( @@ -662,7 +662,7 @@ MessageGenerator::MessageGenerator( MessageGenerator::~MessageGenerator() = default; -size_t MessageGenerator::HasBitsSize() const { +size_t MessageGenerator::HasBitsSize() const { return (max_has_bit_index_ + 31) / 32; } @@ -681,7 +681,7 @@ int MessageGenerator::HasWordIndex(const FieldDescriptor* field) const { return hasbit == kNoHasbit ? kNoHasbit : hasbit / 32; } -void MessageGenerator::AddGenerators( +void MessageGenerator::AddGenerators( std::vector<std::unique_ptr<EnumGenerator>>* enum_generators, std::vector<std::unique_ptr<ExtensionGenerator>>* extension_generators) { for (int i = 0; i < descriptor_->enum_type_count(); i++) { @@ -689,40 +689,40 @@ void MessageGenerator::AddGenerators( new EnumGenerator(descriptor_->enum_type(i), variables_, options_)); enum_generators_.push_back(enum_generators->back().get()); } - for (int i = 0; i < descriptor_->extension_count(); i++) { + for (int i = 0; i < descriptor_->extension_count(); i++) { extension_generators->emplace_back( new ExtensionGenerator(descriptor_->extension(i), options_)); extension_generators_.push_back(extension_generators->back().get()); - } + } } void MessageGenerator::GenerateFieldAccessorDeclarations(io::Printer* printer) { Formatter format(printer, variables_); - // optimized_fields_ does not contain fields where + // optimized_fields_ does not contain fields where // field->real_containing_oneof() - // 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()); - + // 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 (auto field : FieldRange(descriptor_)) { if (!field->real_containing_oneof() && !field->options().weak() && !IsFieldStripped(field, options_)) { - continue; - } - ordered_fields.push_back(field); - } + continue; + } + ordered_fields.push_back(field); + } if (!ordered_fields.empty()) { format("enum : int {\n"); for (auto field : ordered_fields) { Formatter::SaveState save(&format); - + std::map<TProtoStringType, TProtoStringType> vars; SetCommonFieldVariables(field, &vars, options_); format.AddMap(vars); @@ -809,18 +809,18 @@ void MessageGenerator::GenerateSingularFieldHasBits( "__builtin_trap(); }\n"); return; } - if (field->options().weak()) { + if (field->options().weak()) { format( "inline bool $classname$::has_$name$() const {\n" "$annotate_has$" - " return _weak_field_map_.Has($number$);\n" - "}\n"); - return; - } + " return _weak_field_map_.Has($number$);\n" + "}\n"); + return; + } if (HasHasbit(field)) { int has_bit_index = HasBitIndex(field); GOOGLE_CHECK_NE(has_bit_index, kNoHasbit); - + format.Set("has_array_index", has_bit_index / 32); format.Set("has_mask", strings::Hex(1u << (has_bit_index % 32), strings::ZERO_PAD_8)); @@ -1149,26 +1149,26 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { "~$classname$() override;\n" "explicit constexpr " "$classname$(::$proto_ns$::internal::ConstantInitialized);\n" - "\n" - "$classname$(const $classname$& from);\n" + "\n" + "$classname$(const $classname$& from);\n" "$classname$($classname$&& from) noexcept\n" " : $classname$() {\n" " *this = ::std::move(from);\n" "}\n" - "\n" - "inline $classname$& operator=(const $classname$& from) {\n" - " CopyFrom(from);\n" - " return *this;\n" - "}\n" - "inline $classname$& operator=($classname$&& from) noexcept {\n" + "\n" + "inline $classname$& operator=(const $classname$& from) {\n" + " CopyFrom(from);\n" + " return *this;\n" + "}\n" + "inline $classname$& operator=($classname$&& from) noexcept {\n" " if (this == &from) return *this;\n" " if (GetOwningArena() == from.GetOwningArena()) {\n" " InternalSwap(&from);\n" - " } else {\n" - " CopyFrom(from);\n" - " }\n" - " return *this;\n" - "}\n" + " } else {\n" + " CopyFrom(from);\n" + " }\n" + " return *this;\n" + "}\n" "\n"); if (options_.table_driven_serialization) { @@ -1177,17 +1177,17 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { "const void* InternalGetTable() const;\n" "public:\n" "\n"); - } - - if (PublicUnknownFieldsAccessors(descriptor_)) { + } + + if (PublicUnknownFieldsAccessors(descriptor_)) { format( - "inline const $unknown_fields_type$& unknown_fields() const {\n" - " return $unknown_fields$;\n" - "}\n" - "inline $unknown_fields_type$* mutable_unknown_fields() {\n" - " return $mutable_unknown_fields$;\n" - "}\n" - "\n"); + "inline const $unknown_fields_type$& unknown_fields() const {\n" + " return $unknown_fields$;\n" + "}\n" + "inline $unknown_fields_type$* mutable_unknown_fields() {\n" + " return $mutable_unknown_fields$;\n" + "}\n" + "\n"); } // Only generate this member if it's not disabled. @@ -1241,12 +1241,12 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { "\n"); } - // TODO(gerbens) make this private, while still granting other protos access. + // TODO(gerbens) make this private, while still granting other protos access. format( - "static inline const $classname$* internal_default_instance() {\n" - " return reinterpret_cast<const $classname$*>(\n" - " &_$classname$_default_instance_);\n" - "}\n" + "static inline const $classname$* internal_default_instance() {\n" + " return reinterpret_cast<const $classname$*>(\n" + " &_$classname$_default_instance_);\n" + "}\n" "static constexpr int kIndexInFileMessages =\n" " $1$;\n" "\n", @@ -1354,12 +1354,12 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { " return CreateMaybeMessage<$classname$>(arena);\n" "}\n"); - // For instances that derive from Message (rather than MessageLite), some - // methods are virtual and should be marked as final. + // For instances that derive from Message (rather than MessageLite), some + // methods are virtual and should be marked as final. format.Set("full_final", HasDescriptorMethods(descriptor_->file(), options_) ? "final" : ""); - + if (HasGeneratedMethods(descriptor_->file(), options_)) { if (HasDescriptorMethods(descriptor_->file(), options_)) { format( @@ -1388,11 +1388,11 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { format.Set("clear_final", ShouldMarkClearAsFinal(descriptor_, options_) ? "final" : ""); - + format( "PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear()$ clear_final$;\n" "bool IsInitialized() const final;\n" - "\n" + "\n" "size_t ByteSizeLong() const final;\n"); parse_function_generator_->GenerateMethodDecls(printer); @@ -1427,9 +1427,9 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { : "::StringPiece"); format( - // TODO(gerbens) Make this private! Currently people are deriving from - // protos to give access to this constructor, breaking the invariants - // we rely on. + // TODO(gerbens) Make this private! Currently people are deriving from + // protos to give access to this constructor, breaking the invariants + // we rely on. "protected:\n" "explicit $classname$(::$proto_ns$::Arena* arena,\n" " bool is_message_owned = false);\n" @@ -1527,8 +1527,8 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { !descriptor_->options().message_set_wire_format() && num_required_fields_ > 1) { format( - "// helper for ByteSizeLong()\n" - "size_t RequiredFieldsByteSizeFallback() const;\n\n"); + "// helper for ByteSizeLong()\n" + "size_t RequiredFieldsByteSizeFallback() const;\n\n"); } if (HasGeneratedMethods(descriptor_->file(), options_)) { @@ -1542,7 +1542,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { const TProtoStringType cached_size_decl = "mutable ::$proto_ns$::internal::CachedSize _cached_size_;\n"; - const size_t sizeof_has_bits = HasBitsSize(); + const size_t sizeof_has_bits = HasBitsSize(); const TProtoStringType has_bits_decl = sizeof_has_bits == 0 ? "" : StrCat("::$proto_ns$::internal::HasBits<", @@ -1627,16 +1627,16 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { descriptor_->real_oneof_decl_count()); } - if (num_weak_fields_) { + if (num_weak_fields_) { format("::$proto_ns$::internal::WeakFieldMap _weak_field_map_;\n"); - } + } // Generate _any_metadata_ for the Any type. if (IsAnyMessage(descriptor_, options_)) { format("::$proto_ns$::internal::AnyMetadata _any_metadata_;\n"); } - // The TableStruct struct needs access to the private parts, in order to - // construct the offsets of all members. + // The TableStruct struct needs access to the private parts, in order to + // construct the offsets of all members. format("friend struct ::$tablename$;\n"); format.Outdent(); @@ -1645,7 +1645,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) { } // NOLINT(readability/fn_size) void MessageGenerator::GenerateInlineMethods(io::Printer* printer) { - if (IsMapEntryMessage(descriptor_)) return; + if (IsMapEntryMessage(descriptor_)) return; GenerateFieldAccessorDefinitions(printer); // Generate oneof_case() functions. @@ -1664,69 +1664,69 @@ void MessageGenerator::GenerateInlineMethods(io::Printer* printer) { } } -bool MessageGenerator::GenerateParseTable(io::Printer* printer, size_t offset, - size_t aux_offset) { +bool MessageGenerator::GenerateParseTable(io::Printer* printer, size_t offset, + size_t aux_offset) { Formatter format(printer, variables_); - if (!table_driven_) { + if (!table_driven_) { format("{ nullptr, nullptr, 0, -1, -1, -1, -1, nullptr, false },\n"); - return false; - } - - int max_field_number = 0; + return false; + } + + int max_field_number = 0; for (auto field : FieldRange(descriptor_)) { - if (max_field_number < field->number()) { - max_field_number = field->number(); - } - } - + if (max_field_number < field->number()) { + max_field_number = field->number(); + } + } + format("{\n"); format.Indent(); - + format( "$tablename$::entries + $1$,\n" "$tablename$::aux + $2$,\n" "$3$,\n", offset, aux_offset, max_field_number); - + if (has_bit_indices_.empty()) { // If no fields have hasbits, then _has_bits_ does not exist. format("-1,\n"); - } else { + } else { format("PROTOBUF_FIELD_OFFSET($classtype$, _has_bits_),\n"); - } - + } + if (descriptor_->real_oneof_decl_count() > 0) { format("PROTOBUF_FIELD_OFFSET($classtype$, _oneof_case_),\n"); - } else { + } else { format("-1, // no _oneof_case_\n"); - } - - if (descriptor_->extension_range_count() > 0) { + } + + if (descriptor_->extension_range_count() > 0) { format("PROTOBUF_FIELD_OFFSET($classtype$, _extensions_),\n"); - } else { + } else { format("-1, // no _extensions_\n"); - } - - // TODO(ckennelly): Consolidate this with the calculation for + } + + // TODO(ckennelly): Consolidate this with the calculation for // AuxiliaryParseTableField. format( "PROTOBUF_FIELD_OFFSET($classtype$, _internal_metadata_),\n" "&$package_ns$::_$classname$_default_instance_,\n"); - - if (UseUnknownFieldSet(descriptor_->file(), options_)) { + + if (UseUnknownFieldSet(descriptor_->file(), options_)) { format("true,\n"); - } else { + } else { format("false,\n"); - } - + } + format.Outdent(); format("},\n"); - return true; -} - -void MessageGenerator::GenerateSchema(io::Printer* printer, int offset, - int has_offset) { + return true; +} + +void MessageGenerator::GenerateSchema(io::Printer* printer, int offset, + int has_offset) { Formatter format(printer, variables_); has_offset = !has_bit_indices_.empty() || IsMapEntryMessage(descriptor_) ? offset + has_offset @@ -1735,14 +1735,14 @@ void MessageGenerator::GenerateSchema(io::Printer* printer, int offset, format("{ $1$, $2$, sizeof($classtype$)},\n", offset, has_offset); } -namespace { - +namespace { + // We need to calculate for each field what function the table driven code // should use to serialize it. This returns the index in a lookup table. uint32_t CalcFieldNum(const FieldGenerator& generator, const FieldDescriptor* field, const Options& options) { - bool is_a_map = IsMapEntryMessage(field->containing_type()); - int type = field->type(); + bool is_a_map = IsMapEntryMessage(field->containing_type()); + int type = field->type(); if (type == FieldDescriptor::TYPE_STRING || type == FieldDescriptor::TYPE_BYTES) { // string field @@ -1751,64 +1751,64 @@ uint32_t CalcFieldNum(const FieldGenerator& generator, } else if (IsStringPiece(field, options)) { type = internal::FieldMetadata::kStringPieceType; } - } - + } + if (field->real_containing_oneof()) { - return internal::FieldMetadata::CalculateType( - type, internal::FieldMetadata::kOneOf); + return internal::FieldMetadata::CalculateType( + type, internal::FieldMetadata::kOneOf); } else if (field->is_packed()) { - return internal::FieldMetadata::CalculateType( - type, internal::FieldMetadata::kPacked); - } else if (field->is_repeated()) { - return internal::FieldMetadata::CalculateType( - type, internal::FieldMetadata::kRepeated); + return internal::FieldMetadata::CalculateType( + type, internal::FieldMetadata::kPacked); + } else if (field->is_repeated()) { + return internal::FieldMetadata::CalculateType( + type, internal::FieldMetadata::kRepeated); } else if (HasHasbit(field) || field->real_containing_oneof() || is_a_map) { - return internal::FieldMetadata::CalculateType( + return internal::FieldMetadata::CalculateType( type, internal::FieldMetadata::kPresence); - } else { - return internal::FieldMetadata::CalculateType( + } else { + return internal::FieldMetadata::CalculateType( type, internal::FieldMetadata::kNoPresence); - } -} - -int FindMessageIndexInFile(const Descriptor* descriptor) { - std::vector<const Descriptor*> flatten = - FlattenMessagesInFile(descriptor->file()); - return std::find(flatten.begin(), flatten.end(), descriptor) - - flatten.begin(); -} - -} // namespace - -int MessageGenerator::GenerateFieldMetadata(io::Printer* printer) { + } +} + +int FindMessageIndexInFile(const Descriptor* descriptor) { + std::vector<const Descriptor*> flatten = + FlattenMessagesInFile(descriptor->file()); + return std::find(flatten.begin(), flatten.end(), descriptor) - + flatten.begin(); +} + +} // namespace + +int MessageGenerator::GenerateFieldMetadata(io::Printer* printer) { Formatter format(printer, variables_); - if (!options_.table_driven_serialization) { - return 0; - } - - std::vector<const FieldDescriptor*> sorted = SortFieldsByNumber(descriptor_); - if (IsMapEntryMessage(descriptor_)) { - for (int i = 0; i < 2; i++) { - const FieldDescriptor* field = sorted[i]; + if (!options_.table_driven_serialization) { + return 0; + } + + std::vector<const FieldDescriptor*> sorted = SortFieldsByNumber(descriptor_); + if (IsMapEntryMessage(descriptor_)) { + for (int i = 0; i < 2; i++) { + const FieldDescriptor* field = sorted[i]; const FieldGenerator& generator = field_generators_.get(field); uint32_t tag = internal::WireFormatLite::MakeTag( - field->number(), WireFormat::WireTypeForFieldType(field->type())); - + field->number(), WireFormat::WireTypeForFieldType(field->type())); + std::map<TProtoStringType, TProtoStringType> vars; vars["classtype"] = QualifiedClassName(descriptor_, options_); - vars["field_name"] = FieldName(field); + vars["field_name"] = FieldName(field); vars["tag"] = StrCat(tag); vars["hasbit"] = StrCat(i); vars["type"] = StrCat(CalcFieldNum(generator, field, options_)); vars["ptr"] = "nullptr"; - if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { - GOOGLE_CHECK(!IsMapEntryMessage(field->message_type())); + if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { + GOOGLE_CHECK(!IsMapEntryMessage(field->message_type())); vars["ptr"] = "::" + UniqueName("TableStruct", field->message_type(), options_) + "::serialization_table + " + StrCat(FindMessageIndexInFile(field->message_type())); - } + } Formatter::SaveState saver(&format); format.AddMap(vars); format( @@ -1819,51 +1819,51 @@ int MessageGenerator::GenerateFieldMetadata(io::Printer* printer) { "::$proto_ns$::internal::MapEntryHelper<$classtype$::" "SuperType>, _has_bits_) * 8 + $hasbit$, $type$, " "$ptr$},\n"); - } - return 2; - } + } + return 2; + } format( "{PROTOBUF_FIELD_OFFSET($classtype$, _cached_size_)," " 0, 0, 0, nullptr},\n"); - std::vector<const Descriptor::ExtensionRange*> sorted_extensions; + std::vector<const Descriptor::ExtensionRange*> sorted_extensions; sorted_extensions.reserve(descriptor_->extension_range_count()); - for (int i = 0; i < descriptor_->extension_range_count(); ++i) { - sorted_extensions.push_back(descriptor_->extension_range(i)); - } - std::sort(sorted_extensions.begin(), sorted_extensions.end(), - ExtensionRangeSorter()); - for (int i = 0, extension_idx = 0; /* no range */; i++) { - for (; extension_idx < sorted_extensions.size() && - (i == sorted.size() || - sorted_extensions[extension_idx]->start < sorted[i]->number()); - extension_idx++) { - const Descriptor::ExtensionRange* range = - sorted_extensions[extension_idx]; + for (int i = 0; i < descriptor_->extension_range_count(); ++i) { + sorted_extensions.push_back(descriptor_->extension_range(i)); + } + std::sort(sorted_extensions.begin(), sorted_extensions.end(), + ExtensionRangeSorter()); + for (int i = 0, extension_idx = 0; /* no range */; i++) { + for (; extension_idx < sorted_extensions.size() && + (i == sorted.size() || + sorted_extensions[extension_idx]->start < sorted[i]->number()); + extension_idx++) { + const Descriptor::ExtensionRange* range = + sorted_extensions[extension_idx]; format( "{PROTOBUF_FIELD_OFFSET($classtype$, _extensions_), " "$1$, $2$, ::$proto_ns$::internal::FieldMetadata::kSpecial, " - "reinterpret_cast<const " + "reinterpret_cast<const " "void*>(::$proto_ns$::internal::ExtensionSerializer)},\n", range->start, range->end); - } - if (i == sorted.size()) break; - const FieldDescriptor* field = sorted[i]; - + } + if (i == sorted.size()) break; + const FieldDescriptor* field = sorted[i]; + uint32_t tag = internal::WireFormatLite::MakeTag( - field->number(), WireFormat::WireTypeForFieldType(field->type())); - if (field->is_packed()) { - tag = internal::WireFormatLite::MakeTag( - field->number(), WireFormatLite::WIRETYPE_LENGTH_DELIMITED); - } - + field->number(), WireFormat::WireTypeForFieldType(field->type())); + if (field->is_packed()) { + tag = internal::WireFormatLite::MakeTag( + field->number(), WireFormatLite::WIRETYPE_LENGTH_DELIMITED); + } + TProtoStringType classfieldname = FieldName(field); if (field->real_containing_oneof()) { - classfieldname = field->containing_oneof()->name(); - } + classfieldname = field->containing_oneof()->name(); + } format.Set("field_name", classfieldname); TProtoStringType ptr = "nullptr"; - if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { - if (IsMapEntryMessage(field->message_type())) { + if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { + if (IsMapEntryMessage(field->message_type())) { format( "{PROTOBUF_FIELD_OFFSET($classtype$, $field_name$_), $1$, $2$, " "::$proto_ns$::internal::FieldMetadata::kSpecial, " @@ -1875,7 +1875,7 @@ int MessageGenerator::GenerateFieldMetadata(io::Printer* printer) { "$tablename$::serialization_table>))},\n", tag, FindMessageIndexInFile(field->message_type()), QualifiedClassName(field->message_type(), options_)); - continue; + continue; } else if (!field->message_type()->options().message_set_wire_format()) { // message_set doesn't have the usual table and we need to // dispatch to generated serializer, hence ptr stays zero. @@ -1883,12 +1883,12 @@ int MessageGenerator::GenerateFieldMetadata(io::Printer* printer) { "::" + UniqueName("TableStruct", field->message_type(), options_) + "::serialization_table + " + StrCat(FindMessageIndexInFile(field->message_type())); - } - } - + } + } + const FieldGenerator& generator = field_generators_.get(field); int type = CalcFieldNum(generator, field, options_); - + if (IsLazy(field, options_, scc_analyzer_)) { type = internal::FieldMetadata::kSpecial; ptr = "reinterpret_cast<const void*>(::" + variables_["proto_ns"] + @@ -1901,8 +1901,8 @@ int MessageGenerator::GenerateFieldMetadata(io::Printer* printer) { ptr += ")"; } - if (field->options().weak()) { - // TODO(gerbens) merge weak fields into ranges + if (field->options().weak()) { + // TODO(gerbens) merge weak fields into ranges format( "{PROTOBUF_FIELD_OFFSET(" "$classtype$, _weak_field_map_), $1$, $1$, " @@ -1925,15 +1925,15 @@ int MessageGenerator::GenerateFieldMetadata(io::Printer* printer) { "$1$, PROTOBUF_FIELD_OFFSET($classtype$, _has_bits_) * 8 + " "$hasbitsoffset$, $2$, $3$},\n", tag, type, ptr); - } else { + } else { format( "{PROTOBUF_FIELD_OFFSET($classtype$, $field_name$_), " "$1$, ~0u, $2$, $3$},\n", tag, type, ptr); - } - } - int num_field_metadata = 1 + sorted.size() + sorted_extensions.size(); - num_field_metadata++; + } + } + int num_field_metadata = 1 + sorted.size() + sorted_extensions.size(); + num_field_metadata++; TProtoStringType serializer = UseUnknownFieldSet(descriptor_->file(), options_) ? "UnknownFieldSetSerializer" : "UnknownFieldSerializerLite"; @@ -1942,12 +1942,12 @@ int MessageGenerator::GenerateFieldMetadata(io::Printer* printer) { "::$proto_ns$::internal::FieldMetadata::kSpecial, reinterpret_cast<const " "void*>(::$proto_ns$::internal::$1$)},\n", serializer); - return num_field_metadata; -} - + return num_field_metadata; +} + void MessageGenerator::GenerateClassMethods(io::Printer* printer) { Formatter format(printer, variables_); - if (IsMapEntryMessage(descriptor_)) { + if (IsMapEntryMessage(descriptor_)) { format( "$classname$::$classname$() {}\n" "$classname$::$classname$(::$proto_ns$::Arena* arena)\n" @@ -1964,8 +1964,8 @@ void MessageGenerator::GenerateClassMethods(io::Printer* printer) { "}\n", index_in_file_messages_); } - return; - } + return; + } if (IsAnyMessage(descriptor_, options_)) { if (HasDescriptorMethods(descriptor_->file(), options_)) { @@ -1977,7 +1977,7 @@ void MessageGenerator::GenerateClassMethods(io::Printer* printer) { " return ::$proto_ns$::internal::GetAnyFieldDescriptors(\n" " message, type_url_field, value_field);\n" "}\n"); - } + } format( "bool $classname$::ParseAnyTypeUrl(\n" " ::PROTOBUF_NAMESPACE_ID::ConstStringParam type_url,\n" @@ -2000,7 +2000,7 @@ void MessageGenerator::GenerateClassMethods(io::Printer* printer) { field_generators_.get(field).GenerateInternalAccessorDeclarations(printer); if (IsFieldStripped(field, options_)) { continue; - } + } if (HasHasbit(field)) { int has_bit_index = HasBitIndex(field); GOOGLE_CHECK_NE(has_bit_index, kNoHasbit) << field->full_name(); @@ -2010,7 +2010,7 @@ void MessageGenerator::GenerateClassMethods(io::Printer* printer) { "}\n", FieldName(field), has_bit_index / 32, (1u << (has_bit_index % 32))); } - } + } if (num_required_fields_ > 0) { const std::vector<uint32_t> masks_for_has_bits = RequiredFieldsBitMask(); format( @@ -2020,7 +2020,7 @@ void MessageGenerator::GenerateClassMethods(io::Printer* printer) { "}\n", ConditionalToCheckBitmasks(masks_for_has_bits, false, "has_bits")); } - + format.Outdent(); format("};\n\n"); for (auto field : FieldRange(descriptor_)) { @@ -2086,14 +2086,14 @@ void MessageGenerator::GenerateClassMethods(io::Printer* printer) { GenerateSwap(printer); format("\n"); - if (options_.table_driven_serialization) { + if (options_.table_driven_serialization) { format( "const void* $classname$::InternalGetTable() const {\n" " return ::$tablename$::serialization_table + $1$;\n" "}\n" "\n", index_in_file_messages_); - } + } if (HasDescriptorMethods(descriptor_->file(), options_)) { format( "::$proto_ns$::Metadata $classname$::GetMetadata() const {\n" @@ -2112,91 +2112,91 @@ void MessageGenerator::GenerateClassMethods(io::Printer* printer) { } -size_t MessageGenerator::GenerateParseOffsets(io::Printer* printer) { +size_t MessageGenerator::GenerateParseOffsets(io::Printer* printer) { Formatter format(printer, variables_); - 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. + 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. format("{0, 0, 0, ::$proto_ns$::internal::kInvalidMask, 0, 0},\n"); - int last_field_number = 1; - - std::vector<const FieldDescriptor*> ordered_fields = - SortFieldsByNumber(descriptor_); - + int last_field_number = 1; + + std::vector<const FieldDescriptor*> ordered_fields = + SortFieldsByNumber(descriptor_); + for (auto field : ordered_fields) { Formatter::SaveState saver(&format); - GOOGLE_CHECK_GE(field->number(), last_field_number); - - for (; last_field_number < field->number(); last_field_number++) { + GOOGLE_CHECK_GE(field->number(), last_field_number); + + for (; last_field_number < field->number(); last_field_number++) { format( "{ 0, 0, ::$proto_ns$::internal::kInvalidMask,\n" " ::$proto_ns$::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) { + } + 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, options_)) { - case FieldOptions::STRING: - break; + case FieldOptions::STRING: + break; case FieldOptions::CORD: processing_type = internal::TYPE_STRING_CORD; break; case FieldOptions::STRING_PIECE: processing_type = internal::TYPE_STRING_STRING_PIECE; break; - } - } else if (field->type() == FieldDescriptor::TYPE_BYTES) { + } + } else if (field->type() == FieldDescriptor::TYPE_BYTES) { switch (EffectiveStringCType(field, options_)) { - case FieldOptions::STRING: - break; + case FieldOptions::STRING: + break; case FieldOptions::CORD: processing_type = internal::TYPE_BYTES_CORD; break; case FieldOptions::STRING_PIECE: processing_type = internal::TYPE_BYTES_STRING_PIECE; break; - } - } - - processing_type |= static_cast<unsigned>( + } + } + + processing_type |= static_cast<unsigned>( field->is_repeated() ? internal::kRepeatedMask : 0); - processing_type |= static_cast<unsigned>( + processing_type |= static_cast<unsigned>( field->real_containing_oneof() ? internal::kOneofMask : 0); - - if (field->is_map()) { - processing_type = internal::TYPE_MAP; - } - - const unsigned char tag_size = + + if (field->is_map()) { + processing_type = internal::TYPE_MAP; + } + + const unsigned char tag_size = WireFormat::TagSize(field->number(), field->type()); - + std::map<TProtoStringType, TProtoStringType> vars; if (field->real_containing_oneof()) { - vars["name"] = field->containing_oneof()->name(); + vars["name"] = field->containing_oneof()->name(); vars["presence"] = StrCat(field->containing_oneof()->index()); - } else { - vars["name"] = FieldName(field); + } else { + vars["name"] = FieldName(field); vars["presence"] = StrCat(has_bit_indices_[field->index()]); - } + } vars["nwtype"] = StrCat(normal_wiretype); vars["pwtype"] = StrCat(packed_wiretype); vars["ptype"] = StrCat(processing_type); vars["tag_size"] = StrCat(tag_size); - + format.AddMap(vars); format( @@ -2205,37 +2205,37 @@ size_t MessageGenerator::GenerateParseOffsets(io::Printer* printer) { " static_cast<$uint32$>($presence$),\n" " $nwtype$, $pwtype$, $ptype$, $tag_size$\n" "},\n"); - } - - return last_field_number; -} - -size_t MessageGenerator::GenerateParseAuxTable(io::Printer* printer) { + } + + return last_field_number; +} + +size_t MessageGenerator::GenerateParseAuxTable(io::Printer* printer) { Formatter format(printer, variables_); - if (!table_driven_) { - return 0; - } - - std::vector<const FieldDescriptor*> ordered_fields = - SortFieldsByNumber(descriptor_); - + if (!table_driven_) { + return 0; + } + + std::vector<const FieldDescriptor*> ordered_fields = + SortFieldsByNumber(descriptor_); + format("::$proto_ns$::internal::AuxiliaryParseTableField(),\n"); - int last_field_number = 1; + int last_field_number = 1; for (auto field : ordered_fields) { Formatter::SaveState saver(&format); - - GOOGLE_CHECK_GE(field->number(), last_field_number); - for (; last_field_number < field->number(); last_field_number++) { + + GOOGLE_CHECK_GE(field->number(), last_field_number); + for (; last_field_number < field->number(); last_field_number++) { format("::$proto_ns$::internal::AuxiliaryParseTableField(),\n"); - } - + } + std::map<TProtoStringType, TProtoStringType> vars; - SetCommonFieldVariables(field, &vars, options_); + SetCommonFieldVariables(field, &vars, options_); format.AddMap(vars); - - switch (field->cpp_type()) { - case FieldDescriptor::CPPTYPE_ENUM: + + switch (field->cpp_type()) { + case FieldDescriptor::CPPTYPE_ENUM: if (HasPreservingUnknownEnumSemantics(field)) { format( "{::$proto_ns$::internal::AuxiliaryParseTableField::enum_aux{" @@ -2246,90 +2246,90 @@ size_t MessageGenerator::GenerateParseAuxTable(io::Printer* printer) { "$1$_IsValid}},\n", ClassName(field->enum_type(), true)); } - last_field_number++; - break; - case FieldDescriptor::CPPTYPE_MESSAGE: { - if (field->is_map()) { + last_field_number++; + break; + case FieldDescriptor::CPPTYPE_MESSAGE: { + if (field->is_map()) { format( "{::$proto_ns$::internal::AuxiliaryParseTableField::map_" "aux{&::$proto_ns$::internal::ParseMap<$1$>}},\n", QualifiedClassName(field->message_type(), options_)); - last_field_number++; - break; - } + last_field_number++; + break; + } format.Set("field_classname", ClassName(field->message_type(), false)); format.Set("default_instance", QualifiedDefaultInstanceName( field->message_type(), options_)); - + format( "{::$proto_ns$::internal::AuxiliaryParseTableField::message_aux{\n" " &$default_instance$}},\n"); - last_field_number++; - break; - } + last_field_number++; + break; + } case FieldDescriptor::CPPTYPE_STRING: { TProtoStringType default_val; switch (EffectiveStringCType(field, options_)) { - case FieldOptions::STRING: + case FieldOptions::STRING: default_val = field->default_value_string().empty() ? "&::" + variables_["proto_ns"] + "::internal::fixed_address_empty_string" : "&" + QualifiedClassName(descriptor_, options_) + "::" + MakeDefaultName(field); - break; - case FieldOptions::CORD: - case FieldOptions::STRING_PIECE: + break; + case FieldOptions::CORD: + case FieldOptions::STRING_PIECE: default_val = - "\"" + CEscape(field->default_value_string()) + "\""; - break; - } + "\"" + CEscape(field->default_value_string()) + "\""; + break; + } format( "{::$proto_ns$::internal::AuxiliaryParseTableField::string_aux{\n" " $1$,\n" " \"$2$\"\n" "}},\n", default_val, field->full_name()); - last_field_number++; - break; + last_field_number++; + break; } - default: - break; - } - } - - return last_field_number; -} - -std::pair<size_t, size_t> MessageGenerator::GenerateOffsets( - io::Printer* printer) { + default: + break; + } + } + + return last_field_number; +} + +std::pair<size_t, size_t> MessageGenerator::GenerateOffsets( + io::Printer* printer) { Formatter format(printer, variables_); if (!has_bit_indices_.empty() || IsMapEntryMessage(descriptor_)) { format("PROTOBUF_FIELD_OFFSET($classtype$, _has_bits_),\n"); - } else { + } else { format("~0u, // no _has_bits_\n"); - } + } format("PROTOBUF_FIELD_OFFSET($classtype$, _internal_metadata_),\n"); - if (descriptor_->extension_range_count() > 0) { + if (descriptor_->extension_range_count() > 0) { format("PROTOBUF_FIELD_OFFSET($classtype$, _extensions_),\n"); - } else { + } else { format("~0u, // no _extensions_\n"); - } + } if (descriptor_->real_oneof_decl_count() > 0) { format("PROTOBUF_FIELD_OFFSET($classtype$, _oneof_case_[0]),\n"); - } else { + } else { format("~0u, // no _oneof_case_\n"); - } - if (num_weak_fields_ > 0) { + } + if (num_weak_fields_ > 0) { format("PROTOBUF_FIELD_OFFSET($classtype$, _weak_field_map_),\n"); - } else { + } else { format("~0u, // no _weak_field_map_\n"); - } - const int kNumGenericOffsets = 5; // the number of fixed offsets above + } + const int kNumGenericOffsets = 5; // the number of fixed offsets above const size_t offsets = kNumGenericOffsets + descriptor_->field_count() + descriptor_->real_oneof_decl_count(); - size_t entries = offsets; + size_t entries = offsets; for (auto field : FieldRange(descriptor_)) { if (IsFieldStripped(field, options_)) { format("~0u, // stripped\n"); @@ -2367,15 +2367,15 @@ std::pair<size_t, size_t> MessageGenerator::GenerateOffsets( "0,\n" "1,\n"); } else if (!has_bit_indices_.empty()) { - entries += has_bit_indices_.size(); - for (int i = 0; i < has_bit_indices_.size(); i++) { + entries += has_bit_indices_.size(); + for (int i = 0; i < has_bit_indices_.size(); i++) { const TProtoStringType index = has_bit_indices_[i] >= 0 ? StrCat(has_bit_indices_[i]) : "~0u"; format("$1$,\n", index); - } - } - - return std::make_pair(entries, offsets); + } + } + + return std::make_pair(entries, offsets); } void MessageGenerator::GenerateSharedConstructorCode(io::Printer* printer) { @@ -2383,9 +2383,9 @@ void MessageGenerator::GenerateSharedConstructorCode(io::Printer* printer) { format("void $classname$::SharedCtor() {\n"); - std::vector<bool> processed(optimized_order_.size(), false); - GenerateConstructorBody(printer, processed, false); - + std::vector<bool> processed(optimized_order_.size(), false); + GenerateConstructorBody(printer, processed, false); + for (auto oneof : OneOfRange(descriptor_)) { format("clear_has_$1$();\n", oneof->name()); } @@ -2400,9 +2400,9 @@ void MessageGenerator::GenerateSharedDestructorCode(io::Printer* printer) { format.Indent(); format("$DCHK$(GetArenaForAllocation() == nullptr);\n"); // Write the destructors for each field except oneof members. - // optimized_order_ does not contain oneof fields. + // optimized_order_ does not contain oneof fields. for (auto field : optimized_order_) { - field_generators_.get(field).GenerateDestructorCode(printer); + field_generators_.get(field).GenerateDestructorCode(printer); } // Generate code to destruct oneofs. Clearing should do the work. @@ -2414,9 +2414,9 @@ void MessageGenerator::GenerateSharedDestructorCode(io::Printer* printer) { oneof->name()); } - if (num_weak_fields_) { + if (num_weak_fields_) { format("_weak_field_map_.ClearAll();\n"); - } + } format.Outdent(); format( "}\n" @@ -2441,26 +2441,26 @@ void MessageGenerator::GenerateArenaDestructorCode(io::Printer* printer) { "(void)_this;\n"); bool need_registration = false; - // Process non-oneof fields first. + // Process non-oneof fields first. for (auto field : optimized_order_) { if (field_generators_.get(field).GenerateArenaDestructorCode(printer)) { need_registration = true; } } - - // Process oneof fields. - // - // Note: As of 10/5/2016, GenerateArenaDestructorCode does not emit anything - // and returns false for oneof fields. + + // Process oneof fields. + // + // Note: As of 10/5/2016, GenerateArenaDestructorCode does not emit anything + // and returns false for oneof fields. for (auto oneof : OneOfRange(descriptor_)) { for (auto field : FieldRange(oneof)) { if (!IsFieldStripped(field, options_) && field_generators_.get(field).GenerateArenaDestructorCode(printer)) { - need_registration = true; - } - } - } - + need_registration = true; + } + } + } + format.Outdent(); format("}\n"); @@ -2515,67 +2515,67 @@ void MessageGenerator::GenerateConstexprConstructor(io::Printer* printer) { format("{}\n"); } -void MessageGenerator::GenerateConstructorBody(io::Printer* printer, - std::vector<bool> processed, - bool copy_constructor) const { +void MessageGenerator::GenerateConstructorBody(io::Printer* printer, + std::vector<bool> processed, + bool copy_constructor) const { Formatter format(printer, variables_); - + const RunMap runs = FindRuns( optimized_order_, [copy_constructor, this](const FieldDescriptor* field) { return (copy_constructor && IsPOD(field)) || (!copy_constructor && CanBeManipulatedAsRawBytes(field, options_, scc_analyzer_)); }); - + TProtoStringType pod_template; - if (copy_constructor) { - pod_template = - "::memcpy(&$first$_, &from.$first$_,\n" - " static_cast<size_t>(reinterpret_cast<char*>(&$last$_) -\n" - " reinterpret_cast<char*>(&$first$_)) + sizeof($last$_));\n"; - } else { - pod_template = + if (copy_constructor) { + pod_template = + "::memcpy(&$first$_, &from.$first$_,\n" + " static_cast<size_t>(reinterpret_cast<char*>(&$last$_) -\n" + " reinterpret_cast<char*>(&$first$_)) + sizeof($last$_));\n"; + } else { + pod_template = "::memset(reinterpret_cast<char*>(this) + static_cast<size_t>(\n" " reinterpret_cast<char*>(&$first$_) - " "reinterpret_cast<char*>(this)),\n" " 0, static_cast<size_t>(reinterpret_cast<char*>(&$last$_) -\n" - " reinterpret_cast<char*>(&$first$_)) + sizeof($last$_));\n"; - } - - for (int i = 0; i < optimized_order_.size(); ++i) { - if (processed[i]) { - continue; - } - - const FieldDescriptor* field = optimized_order_[i]; + " reinterpret_cast<char*>(&$first$_)) + sizeof($last$_));\n"; + } + + for (int i = 0; i < optimized_order_.size(); ++i) { + if (processed[i]) { + continue; + } + + const FieldDescriptor* field = optimized_order_[i]; const auto it = runs.find(field); - - // We only apply the memset technique to runs of more than one field, as - // assignment is better than memset for generated code clarity. - if (it != runs.end() && it->second > 1) { - // Use a memset, then skip run_length fields. - const size_t run_length = it->second; + + // We only apply the memset technique to runs of more than one field, as + // assignment is better than memset for generated code clarity. + if (it != runs.end() && it->second > 1) { + // Use a memset, then skip run_length fields. + const size_t run_length = it->second; const TProtoStringType first_field_name = FieldName(field); const TProtoStringType last_field_name = - FieldName(optimized_order_[i + run_length - 1]); - + FieldName(optimized_order_[i + run_length - 1]); + format.Set("first", first_field_name); format.Set("last", last_field_name); - + format(pod_template.c_str()); - i += run_length - 1; - // ++i at the top of the loop. - } else { - if (copy_constructor) { - field_generators_.get(field).GenerateCopyConstructorCode(printer); - } else { - field_generators_.get(field).GenerateConstructorCode(printer); - } - } - } -} - + i += run_length - 1; + // ++i at the top of the loop. + } else { + if (copy_constructor) { + field_generators_.get(field).GenerateCopyConstructorCode(printer); + } else { + field_generators_.get(field).GenerateConstructorCode(printer); + } + } + } +} + void MessageGenerator::GenerateStructors(io::Printer* printer) { Formatter format(printer, variables_); @@ -2590,7 +2590,7 @@ void MessageGenerator::GenerateStructors(io::Printer* printer) { // Initialize member variables with arena constructor. for (auto field : optimized_order_) { GOOGLE_DCHECK(!IsFieldStripped(field, options_)); - bool has_arena_constructor = field->is_repeated(); + bool has_arena_constructor = field->is_repeated(); if (!field->real_containing_oneof() && (IsLazy(field, options_, scc_analyzer_) || IsStringPiece(field, options_))) { @@ -2605,17 +2605,17 @@ void MessageGenerator::GenerateStructors(io::Printer* printer) { if (IsAnyMessage(descriptor_, options_)) { initializer_with_arena += ",\n _any_metadata_(&type_url_, &value_)"; } - if (num_weak_fields_ > 0) { - initializer_with_arena += ", _weak_field_map_(arena)"; - } + if (num_weak_fields_ > 0) { + initializer_with_arena += ", _weak_field_map_(arena)"; + } TProtoStringType initializer_null = superclass + "()"; if (IsAnyMessage(descriptor_, options_)) { initializer_null += ", _any_metadata_(&type_url_, &value_)"; } - if (num_weak_fields_ > 0) { + if (num_weak_fields_ > 0) { initializer_null += ", _weak_field_map_(nullptr)"; - } + } format( "$classname$::$classname$(::$proto_ns$::Arena* arena,\n" @@ -2651,11 +2651,11 @@ void MessageGenerator::GenerateStructors(io::Printer* printer) { format.Indent(); format.Indent(); format.Indent(); - + if (!has_bit_indices_.empty()) { format(",\n_has_bits_(from._has_bits_)"); } - + std::vector<bool> processed(optimized_order_.size(), false); for (int i = 0; i < optimized_order_.size(); i++) { auto field = optimized_order_[i]; @@ -2663,32 +2663,32 @@ void MessageGenerator::GenerateStructors(io::Printer* printer) { !IsCord(field, options_)) { continue; } - + processed[i] = true; format(",\n$1$_(from.$1$_)", FieldName(field)); } - + if (IsAnyMessage(descriptor_, options_)) { format(",\n_any_metadata_(&type_url_, &value_)"); - } + } if (num_weak_fields_ > 0) { format(",\n_weak_field_map_(from._weak_field_map_)"); } - + format.Outdent(); format.Outdent(); format(" {\n"); - + format( "_internal_metadata_.MergeFrom<$unknown_fields_type$>(from._internal_" "metadata_);\n"); - + if (descriptor_->extension_range_count() > 0) { format("_extensions_.MergeFrom(from._extensions_);\n"); } - + GenerateConstructorBody(printer, processed, true); - + // Copy oneof fields. Oneof field requires oneof case check. for (auto oneof : OneOfRange(descriptor_)) { format( @@ -2714,14 +2714,14 @@ void MessageGenerator::GenerateStructors(io::Printer* printer) { format.Outdent(); format("}\n"); } - + format.Outdent(); format( " // @@protoc_insertion_point(copy_constructor:$full_name$)\n" "}\n" "\n"); - } - + } + // Generate the shared constructor code. GenerateSharedConstructorCode(printer); @@ -2760,7 +2760,7 @@ void MessageGenerator::GenerateSourceInProto2Namespace(io::Printer* printer) { void MessageGenerator::GenerateClear(io::Printer* printer) { Formatter format(printer, variables_); - + // The maximum number of bytes we will memset to zero without checking their // hasbit to see if a zero-init is necessary. const int kMaxUnconditionalPrimitiveBytesClear = 4; @@ -2771,12 +2771,12 @@ void MessageGenerator::GenerateClear(io::Printer* printer) { format.Indent(); format( - // TODO(jwb): It would be better to avoid emitting this if it is not used, - // rather than emitting a workaround for the resulting warning. + // TODO(jwb): It would be better to avoid emitting this if it is not used, + // rather than emitting a workaround for the resulting warning. "$uint32$ cached_has_bits = 0;\n" - "// Prevent compiler warnings about cached_has_bits being unused\n" - "(void) cached_has_bits;\n\n"); - + "// Prevent compiler warnings about cached_has_bits being unused\n" + "(void) cached_has_bits;\n\n"); + if (descriptor_->extension_range_count() > 0) { format("_extensions_.Clear();\n"); } @@ -2806,10 +2806,10 @@ void MessageGenerator::GenerateClear(io::Printer* printer) { if (!same) chunk_count = 0; return same; }); - + ColdChunkSkipper cold_skipper(options_, chunks, has_bit_indices_, kColdRatio); int cached_has_word_index = -1; - + for (int chunk_index = 0; chunk_index < chunks.size(); chunk_index++) { std::vector<const FieldDescriptor*>& chunk = chunks[chunk_index]; cold_skipper.OnStartChunk(chunk_index, cached_has_word_index, "", printer); @@ -2848,11 +2848,11 @@ void MessageGenerator::GenerateClear(io::Printer* printer) { // _has_bits_[last_chunk * 8 / 32] multiple times. GOOGLE_DCHECK_LE(2, popcnt(chunk_mask)); GOOGLE_DCHECK_GE(8, popcnt(chunk_mask)); - + if (cached_has_word_index != HasWordIndex(chunk.front())) { cached_has_word_index = HasWordIndex(chunk.front()); format("cached_has_bits = _has_bits_[$1$];\n", cached_has_word_index); - } + } format("if (cached_has_bits & 0x$1$u) {\n", chunk_mask_str); format.Indent(); } @@ -2868,7 +2868,7 @@ void MessageGenerator::GenerateClear(io::Printer* printer) { " reinterpret_cast<char*>(&$2$_) -\n" " reinterpret_cast<char*>(&$1$_)) + sizeof($2$_));\n", FieldName(memset_start), FieldName(memset_end)); - } + } } // Clear all non-zero-initializable fields in the chunk. @@ -2887,20 +2887,20 @@ void MessageGenerator::GenerateClear(io::Printer* printer) { PrintPresenceCheck(format, field, has_bit_indices_, printer, &cached_has_word_index); } - + field_generators_.get(field).GenerateMessageClearingCode(printer); - + if (have_enclosing_if) { format.Outdent(); format("}\n"); - } + } } - + if (have_outer_if) { format.Outdent(); format("}\n"); } - + if (cold_skipper.OnEndChunk(chunk_index, printer)) { // Reset here as it may have been updated in just closed if statement. cached_has_word_index = -1; @@ -2912,10 +2912,10 @@ void MessageGenerator::GenerateClear(io::Printer* printer) { format("clear_$1$();\n", oneof->name()); } - if (num_weak_fields_) { + if (num_weak_fields_) { format("_weak_field_map_.ClearAll();\n"); - } - + } + if (!has_bit_indices_.empty()) { // Step 5: Everything else. format("_has_bits_.Clear();\n"); @@ -3043,9 +3043,9 @@ void MessageGenerator::GenerateSwap(io::Printer* printer) { format("swap(_oneof_case_[$1$], other->_oneof_case_[$1$]);\n", i); } - if (num_weak_fields_) { + if (num_weak_fields_) { format("_weak_field_map_.UnsafeArenaSwap(&other->_weak_field_map_);\n"); - } + } } else { format("GetReflection()->Swap(this, other);"); } @@ -3111,48 +3111,48 @@ void MessageGenerator::GenerateClassSpecificMergeFrom(io::Printer* printer) { [&](const FieldDescriptor* a, const FieldDescriptor* b) -> bool { return HasByteIndex(a) == HasByteIndex(b); }); - + ColdChunkSkipper cold_skipper(options_, chunks, has_bit_indices_, kColdRatio); - + // cached_has_word_index maintains that: // cached_has_bits = from._has_bits_[cached_has_word_index] // for cached_has_word_index >= 0 int cached_has_word_index = -1; - + for (int chunk_index = 0; chunk_index < chunks.size(); chunk_index++) { const std::vector<const FieldDescriptor*>& chunk = chunks[chunk_index]; bool have_outer_if = chunk.size() > 1 && HasByteIndex(chunk.front()) != kNoHasbit; cold_skipper.OnStartChunk(chunk_index, cached_has_word_index, "from.", printer); - + if (have_outer_if) { // Emit an if() that will let us skip the whole chunk if none are set. uint32_t chunk_mask = GenChunkMask(chunk, has_bit_indices_); TProtoStringType chunk_mask_str = StrCat(strings::Hex(chunk_mask, strings::ZERO_PAD_8)); - + // Check (up to) 8 has_bits at a time if we have more than one field in // this chunk. Due to field layout ordering, we may check // _has_bits_[last_chunk * 8 / 32] multiple times. GOOGLE_DCHECK_LE(2, popcnt(chunk_mask)); GOOGLE_DCHECK_GE(8, popcnt(chunk_mask)); - + if (cached_has_word_index != HasWordIndex(chunk.front())) { cached_has_word_index = HasWordIndex(chunk.front()); format("cached_has_bits = from._has_bits_[$1$];\n", cached_has_word_index); - } - + } + format("if (cached_has_bits & 0x$1$u) {\n", chunk_mask_str); format.Indent(); - } - + } + // Go back and emit merging code for each of the fields we processed. bool deferred_has_bit_changes = false; for (const auto field : chunk) { const FieldGenerator& generator = field_generators_.get(field); - + if (field->is_repeated()) { generator.GenerateMergingCode(printer); } else if (field->is_optional() && !HasHasbit(field)) { @@ -3164,7 +3164,7 @@ void MessageGenerator::GenerateClassSpecificMergeFrom(io::Printer* printer) { if (have_enclosing_if) { format.Outdent(); format("}\n"); - } + } } else if (field->options().weak() || cached_has_word_index != HasWordIndex(field)) { // Check hasbit, not using cached bits. @@ -3182,31 +3182,31 @@ void MessageGenerator::GenerateClassSpecificMergeFrom(io::Printer* printer) { strings::Hex(1u << (has_bit_index % 32), strings::ZERO_PAD_8)); format("if (cached_has_bits & 0x$1$u) {\n", mask); format.Indent(); - - if (have_outer_if && IsPOD(field)) { + + if (have_outer_if && IsPOD(field)) { // Defer hasbit modification until the end of chunk. - // 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); - } - + // 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); + } + format.Outdent(); format("}\n"); - } + } } - + if (have_outer_if) { if (deferred_has_bit_changes) { // Flush the has bits for the primitives we deferred. GOOGLE_CHECK_LE(0, cached_has_word_index); format("_has_bits_[$1$] |= cached_has_bits;\n", cached_has_word_index); } - + format.Outdent(); format("}\n"); - } + } if (cold_skipper.OnEndChunk(chunk_index, printer)) { // Reset here as it may have been updated in just closed if statement. @@ -3236,9 +3236,9 @@ void MessageGenerator::GenerateClassSpecificMergeFrom(io::Printer* printer) { format.Outdent(); format("}\n"); } - if (num_weak_fields_) { + if (num_weak_fields_) { format("_weak_field_map_.MergeFrom(from._weak_field_map_);\n"); - } + } // Merging of extensions and unknown fields is done last, to maximize // the opportunity for tail calls. @@ -3301,16 +3301,16 @@ void MessageGenerator::GenerateCopyFrom(io::Printer* printer) { format("}\n"); } -void MessageGenerator::GenerateSerializeOneofFields( +void MessageGenerator::GenerateSerializeOneofFields( io::Printer* printer, const std::vector<const FieldDescriptor*>& fields) { Formatter format(printer, variables_); - GOOGLE_CHECK(!fields.empty()); - if (fields.size() == 1) { + GOOGLE_CHECK(!fields.empty()); + if (fields.size() == 1) { GenerateSerializeOneField(printer, fields[0], -1); - return; - } - // We have multiple mutually exclusive choices. Emit a switch statement. - const OneofDescriptor* oneof = fields[0]->containing_oneof(); + return; + } + // We have multiple mutually exclusive choices. Emit a switch statement. + const OneofDescriptor* oneof = fields[0]->containing_oneof(); format("switch ($1$_case()) {\n", oneof->name()); format.Indent(); for (auto field : fields) { @@ -3321,37 +3321,37 @@ void MessageGenerator::GenerateSerializeOneofFields( format("break;\n"); format.Outdent(); format("}\n"); - } + } format.Outdent(); - // Doing nothing is an option. + // Doing nothing is an option. format( " default: ;\n" "}\n"); -} - +} + void MessageGenerator::GenerateSerializeOneField(io::Printer* printer, const FieldDescriptor* field, int cached_has_bits_index) { Formatter format(printer, variables_); - if (!field->options().weak()) { - // For weakfields, PrintFieldComment is called during iteration. + if (!field->options().weak()) { + // For weakfields, PrintFieldComment is called during iteration. PrintFieldComment(format, field); - } + } bool have_enclosing_if = false; - if (field->options().weak()) { + if (field->options().weak()) { } else if (HasHasbit(field)) { - // Attempt to use the state of cached_has_bits, if possible. + // Attempt to use the state of cached_has_bits, if possible. int has_bit_index = HasBitIndex(field); - if (cached_has_bits_index == has_bit_index / 32) { + if (cached_has_bits_index == has_bit_index / 32) { const TProtoStringType mask = StrCat(strings::Hex(1u << (has_bit_index % 32), strings::ZERO_PAD_8)); - + format("if (cached_has_bits & 0x$1$u) {\n", mask); - } else { + } else { format("if (_internal_has_$1$()) {\n", FieldName(field)); - } - + } + format.Indent(); have_enclosing_if = true; } else if (field->is_optional() && !HasHasbit(field)) { @@ -3444,84 +3444,84 @@ void MessageGenerator::GenerateSerializeWithCachedSizesToArray( void MessageGenerator::GenerateSerializeWithCachedSizesBody( io::Printer* printer) { Formatter format(printer, variables_); - // If there are multiple fields in a row from the same oneof then we - // coalesce them and emit a switch statement. This is more efficient - // because it lets the C++ compiler know this is a "at most one can happen" - // situation. If we emitted "if (has_x()) ...; if (has_y()) ..." the C++ - // compiler's emitted code might check has_y() even when has_x() is true. - class LazySerializerEmitter { - public: + // If there are multiple fields in a row from the same oneof then we + // coalesce them and emit a switch statement. This is more efficient + // because it lets the C++ compiler know this is a "at most one can happen" + // situation. If we emitted "if (has_x()) ...; if (has_y()) ..." the C++ + // compiler's emitted code might check has_y() even when has_x() is true. + class LazySerializerEmitter { + public: LazySerializerEmitter(MessageGenerator* mg, io::Printer* printer) - : mg_(mg), + : mg_(mg), format_(printer), eager_(IsProto3(mg->descriptor_->file())), cached_has_bit_index_(kNoHasbit) {} - ~LazySerializerEmitter() { Flush(); } - - // If conditions allow, try to accumulate a run of fields from the same - // oneof, and handle them at the next Flush(). - void Emit(const FieldDescriptor* field) { - if (eager_ || MustFlush(field)) { - Flush(); - } + ~LazySerializerEmitter() { Flush(); } + + // If conditions allow, try to accumulate a run of fields from the same + // oneof, and handle them at the next Flush(). + void Emit(const FieldDescriptor* field) { + if (eager_ || MustFlush(field)) { + Flush(); + } if (!field->real_containing_oneof()) { - // 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; - + // 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; + format_("cached_has_bits = _has_bits_[$1$];\n", new_index); - - cached_has_bit_index_ = new_index; - } - } - + + cached_has_bit_index_ = new_index; + } + } + mg_->GenerateSerializeOneField(format_.printer(), field, cached_has_bit_index_); - } else { - v_.push_back(field); - } - } - + } else { + v_.push_back(field); + } + } + void EmitIfNotNull(const FieldDescriptor* field) { if (field != nullptr) { Emit(field); } } - void Flush() { - if (!v_.empty()) { + void Flush() { + if (!v_.empty()) { mg_->GenerateSerializeOneofFields(format_.printer(), v_); - v_.clear(); - } - } - - private: - // If we have multiple fields in v_ then they all must be from the same - // oneof. Would adding field to v_ break that invariant? - bool MustFlush(const FieldDescriptor* field) { - return !v_.empty() && - v_[0]->containing_oneof() != field->containing_oneof(); - } - - MessageGenerator* mg_; + v_.clear(); + } + } + + private: + // If we have multiple fields in v_ then they all must be from the same + // oneof. Would adding field to v_ break that invariant? + bool MustFlush(const FieldDescriptor* field) { + return !v_.empty() && + v_[0]->containing_oneof() != field->containing_oneof(); + } + + MessageGenerator* mg_; Formatter format_; - 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_; - }; - + 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_; + }; + class LazyExtensionRangeEmitter { public: LazyExtensionRangeEmitter(MessageGenerator* mg, io::Printer* printer) @@ -3577,9 +3577,9 @@ void MessageGenerator::GenerateSerializeWithCachedSizesBody( const FieldDescriptor* field_ = nullptr; }; - std::vector<const FieldDescriptor*> ordered_fields = - SortFieldsByNumber(descriptor_); - + std::vector<const FieldDescriptor*> ordered_fields = + SortFieldsByNumber(descriptor_); + std::vector<const Descriptor::ExtensionRange*> sorted_extensions; sorted_extensions.reserve(descriptor_->extension_range_count()); for (int i = 0; i < descriptor_->extension_range_count(); ++i) { @@ -3587,44 +3587,44 @@ void MessageGenerator::GenerateSerializeWithCachedSizesBody( } std::sort(sorted_extensions.begin(), sorted_extensions.end(), ExtensionRangeSorter()); - if (num_weak_fields_) { + if (num_weak_fields_) { format( "::$proto_ns$::internal::WeakFieldMap::FieldWriter field_writer(" - "_weak_field_map_);\n"); - } + "_weak_field_map_);\n"); + } format( "$uint32$ cached_has_bits = 0;\n" - "(void) cached_has_bits;\n\n"); - + "(void) cached_has_bits;\n\n"); + // Merge the fields and the extension ranges, both sorted by field number. - { + { LazySerializerEmitter e(this, printer); LazyExtensionRangeEmitter re(this, printer); LargestWeakFieldHolder largest_weak_field; - int i, j; - for (i = 0, j = 0; - i < ordered_fields.size() || j < sorted_extensions.size();) { - if ((j == sorted_extensions.size()) || - (i < descriptor_->field_count() && - ordered_fields[i]->number() < sorted_extensions[j]->start)) { - const FieldDescriptor* field = ordered_fields[i++]; + int i, j; + for (i = 0, j = 0; + i < ordered_fields.size() || j < sorted_extensions.size();) { + if ((j == sorted_extensions.size()) || + (i < descriptor_->field_count() && + ordered_fields[i]->number() < sorted_extensions[j]->start)) { + const FieldDescriptor* field = ordered_fields[i++]; if (IsFieldStripped(field, options_)) { continue; } re.Flush(); - if (field->options().weak()) { + if (field->options().weak()) { largest_weak_field.ReplaceIfLarger(field); PrintFieldComment(format, field); - } else { + } else { e.EmitIfNotNull(largest_weak_field.Release()); - e.Emit(field); - } + e.Emit(field); + } } else { e.EmitIfNotNull(largest_weak_field.Release()); - e.Flush(); + e.Flush(); re.AddToRange(sorted_extensions[j++]); - } + } } re.Flush(); e.EmitIfNotNull(largest_weak_field.Release()); @@ -3635,9 +3635,9 @@ void MessageGenerator::GenerateSerializeWithCachedSizesBody( format.AddMap(vars); format("if (PROTOBUF_PREDICT_FALSE($have_unknown_fields$)) {\n"); format.Indent(); - if (UseUnknownFieldSet(descriptor_->file(), options_)) { + if (UseUnknownFieldSet(descriptor_->file(), options_)) { format( - "target = " + "target = " "::$proto_ns$::internal::WireFormat::" "InternalSerializeUnknownFieldsToArray(\n" " $unknown_fields$, target, stream);\n"); @@ -3649,7 +3649,7 @@ void MessageGenerator::GenerateSerializeWithCachedSizesBody( format.Outdent(); format("}\n"); } - + void MessageGenerator::GenerateSerializeWithCachedSizesBodyShuffled( io::Printer* printer) { Formatter format(printer, variables_); @@ -3733,7 +3733,7 @@ void MessageGenerator::GenerateSerializeWithCachedSizesBodyShuffled( "::$proto_ns$::internal::WireFormat::" "InternalSerializeUnknownFieldsToArray(\n" " $unknown_fields$, target, stream);\n"); - } else { + } else { format( "target = stream->WriteRaw($unknown_fields$.data(),\n" " static_cast<int>($unknown_fields$.size()), target);\n"); @@ -3743,19 +3743,19 @@ void MessageGenerator::GenerateSerializeWithCachedSizesBodyShuffled( } std::vector<uint32_t> MessageGenerator::RequiredFieldsBitMask() const { - const int array_size = HasBitsSize(); + const int array_size = HasBitsSize(); std::vector<uint32_t> masks(array_size, 0); - + for (auto field : FieldRange(descriptor_)) { - if (!field->is_required()) { - continue; + if (!field->is_required()) { + continue; } - - const int has_bit_index = has_bit_indices_[field->index()]; + + const int has_bit_index = has_bit_indices_[field->index()]; masks[has_bit_index / 32] |= static_cast<uint32_t>(1) << (has_bit_index % 32); } - return masks; + return masks; } void MessageGenerator::GenerateByteSize(io::Printer* printer) { @@ -3787,7 +3787,7 @@ void MessageGenerator::GenerateByteSize(io::Printer* printer) { // Emit a function (rarely used, we hope) that handles the required fields // by checking for each one individually. format( - "size_t $classname$::RequiredFieldsByteSizeFallback() const {\n" + "size_t $classname$::RequiredFieldsByteSizeFallback() const {\n" "// @@protoc_insertion_point(required_fields_byte_size_fallback_start:" "$full_name$)\n"); format.Indent(); @@ -3813,7 +3813,7 @@ void MessageGenerator::GenerateByteSize(io::Printer* printer) { } format( - "size_t $classname$::ByteSizeLong() const {\n" + "size_t $classname$::ByteSizeLong() const {\n" "$annotate_bytesize$" "// @@protoc_insertion_point(message_byte_size_start:$full_name$)\n"); format.Indent(); @@ -3821,16 +3821,16 @@ void MessageGenerator::GenerateByteSize(io::Printer* printer) { "size_t total_size = 0;\n" "\n"); - if (descriptor_->extension_range_count() > 0) { + if (descriptor_->extension_range_count() > 0) { format( "total_size += _extensions_.ByteSize();\n" "\n"); - } - + } + std::map<TProtoStringType, TProtoStringType> vars; SetUnknownFieldsVariable(descriptor_, options_, &vars); format.AddMap(vars); - + // Handle required fields (if any). We expect all of them to be // present, so emit one conditional that checks for that. If they are all // present then the fast path executes; otherwise the slow path executes. @@ -3840,8 +3840,8 @@ void MessageGenerator::GenerateByteSize(io::Printer* printer) { format("if ($1$) { // All required fields are present.\n", ConditionalToCheckBitmasks(masks_for_has_bits)); format.Indent(); - // Oneof fields cannot be required, so optimized_order_ contains all of the - // fields that we need to potentially emit. + // Oneof fields cannot be required, so optimized_order_ contains all of the + // fields that we need to potentially emit. for (auto field : optimized_order_) { if (!field->is_required()) continue; PrintFieldComment(format, field); @@ -3871,7 +3871,7 @@ void MessageGenerator::GenerateByteSize(io::Printer* printer) { [&](const FieldDescriptor* a, const FieldDescriptor* b) -> bool { return a->label() == b->label() && HasByteIndex(a) == HasByteIndex(b); }); - + // Remove chunks with required fields. chunks.erase(std::remove_if(chunks.begin(), chunks.end(), IsRequired), chunks.end()); @@ -3931,19 +3931,19 @@ void MessageGenerator::GenerateByteSize(io::Printer* printer) { // non-default value. have_enclosing_if = EmitFieldNonDefaultCondition(printer, "this->", field); - } - + } + generator.GenerateByteSize(printer); - + if (have_enclosing_if) { format.Outdent(); format( - "}\n" - "\n"); - } + "}\n" + "\n"); + } if (need_extra_newline) { format("\n"); - } + } } if (have_outer_if) { @@ -3982,11 +3982,11 @@ void MessageGenerator::GenerateByteSize(io::Printer* printer) { format("}\n"); } - if (num_weak_fields_) { - // TagSize + MessageSize + if (num_weak_fields_) { + // TagSize + MessageSize format("total_size += _weak_field_map_.ByteSizeLong();\n"); - } - + } + format("if (PROTOBUF_PREDICT_FALSE($have_unknown_fields$)) {\n"); if (UseUnknownFieldSet(descriptor_->file(), options_)) { // We go out of our way to put the computation of the uncommon path of @@ -4022,25 +4022,25 @@ void MessageGenerator::GenerateIsInitialized(io::Printer* printer) { format("bool $classname$::IsInitialized() const {\n"); format.Indent(); - if (descriptor_->extension_range_count() > 0) { + if (descriptor_->extension_range_count() > 0) { format( "if (!_extensions_.IsInitialized()) {\n" " return false;\n" "}\n\n"); - } - + } + if (num_required_fields_ > 0) { format( "if (_Internal::MissingRequiredFields(_has_bits_))" " return false;\n"); } - // Now check that all non-oneof embedded messages are initialized. + // Now check that all non-oneof embedded messages are initialized. for (auto field : optimized_order_) { - // TODO(ckennelly): Push this down into a generator? + // TODO(ckennelly): Push this down into a generator? if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE && !ShouldIgnoreRequiredFieldCheck(field, options_) && - scc_analyzer_->HasRequiredFields(field->message_type())) { + scc_analyzer_->HasRequiredFields(field->message_type())) { if (field->is_repeated()) { if (IsImplicitWeakField(field, options_, scc_analyzer_)) { format( @@ -4055,8 +4055,8 @@ void MessageGenerator::GenerateIsInitialized(io::Printer* printer) { " return false;\n", FieldName(field)); } - } else if (field->options().weak()) { - continue; + } else if (field->options().weak()) { + continue; } else if (IsEagerlyVerifiedLazy(field, options_, scc_analyzer_)) { GOOGLE_CHECK(!field->real_containing_oneof()); format( @@ -4069,45 +4069,45 @@ void MessageGenerator::GenerateIsInitialized(io::Printer* printer) { format( "if (_internal_has_$1$()) {\n" " if (!$1$_->IsInitialized()) return false;\n" - "}\n", + "}\n", FieldName(field)); - } - } - } - if (num_weak_fields_) { - // For Weak fields. + } + } + } + if (num_weak_fields_) { + // For Weak fields. format("if (!_weak_field_map_.IsInitialized()) return false;\n"); - } - // Go through the oneof fields, emitting a switch if any might have required - // fields. + } + // Go through the oneof fields, emitting a switch if any might have required + // fields. for (auto oneof : OneOfRange(descriptor_)) { - bool has_required_fields = false; + bool has_required_fields = false; for (auto field : FieldRange(oneof)) { - if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE && - !ShouldIgnoreRequiredFieldCheck(field, options_) && - scc_analyzer_->HasRequiredFields(field->message_type())) { - has_required_fields = true; - break; - } - } - - if (!has_required_fields) { - continue; - } - + if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE && + !ShouldIgnoreRequiredFieldCheck(field, options_) && + scc_analyzer_->HasRequiredFields(field->message_type())) { + has_required_fields = true; + break; + } + } + + if (!has_required_fields) { + continue; + } + format("switch ($1$_case()) {\n", oneof->name()); format.Indent(); for (auto field : FieldRange(oneof)) { format("case k$1$: {\n", UnderscoresToCamelCase(field->name(), true)); format.Indent(); - + if (!IsFieldStripped(field, options_) && field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE && - !ShouldIgnoreRequiredFieldCheck(field, options_) && - scc_analyzer_->HasRequiredFields(field->message_type())) { + !ShouldIgnoreRequiredFieldCheck(field, options_) && + scc_analyzer_->HasRequiredFields(field->message_type())) { GOOGLE_CHECK(!(field->options().weak() || !field->real_containing_oneof())); - if (field->options().weak()) { - // Just skip. + if (field->options().weak()) { + // Just skip. } else { format( "if (has_$1$()) {\n" @@ -4116,16 +4116,16 @@ void MessageGenerator::GenerateIsInitialized(io::Printer* printer) { FieldName(field)); } } - + format("break;\n"); format.Outdent(); format("}\n"); } format( "case $1$_NOT_SET: {\n" - " break;\n" - "}\n", - ToUpper(oneof->name())); + " break;\n" + "}\n", + ToUpper(oneof->name())); format.Outdent(); format("}\n"); } diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message.h index eca6edd05e..904a98acfe 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message.h +++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message.h @@ -71,11 +71,11 @@ class MessageGenerator { MessageSCCAnalyzer* scc_analyzer); ~MessageGenerator(); - // Append the two types of nested generators to the corresponding vector. + // Append the two types of nested generators to the corresponding vector. void AddGenerators( std::vector<std::unique_ptr<EnumGenerator>>* enum_generators, std::vector<std::unique_ptr<ExtensionGenerator>>* extension_generators); - + // Generate definitions for this class and all its nested types. void GenerateClassDefinition(io::Printer* printer); @@ -96,22 +96,22 @@ class MessageGenerator { void GenerateFieldAccessorDeclarations(io::Printer* printer); void GenerateFieldAccessorDefinitions(io::Printer* printer); - // Generate the table-driven parsing array. Returns the number of entries - // generated. - size_t GenerateParseOffsets(io::Printer* printer); - size_t GenerateParseAuxTable(io::Printer* printer); + // 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); - + bool GenerateParseTable(io::Printer* printer, size_t offset, + size_t aux_offset); + // Generate the field offsets array. Returns the a pair of the total number - // of entries generated and the index of the first has_bit entry. - std::pair<size_t, size_t> GenerateOffsets(io::Printer* printer); - void GenerateSchema(io::Printer* printer, int offset, int has_offset); - // For each field generates a table entry describing the field for the - // table driven serializer. - int GenerateFieldMetadata(io::Printer* printer); + // of entries generated and the index of the first has_bit entry. + std::pair<size_t, size_t> GenerateOffsets(io::Printer* printer); + void GenerateSchema(io::Printer* printer, int offset, int has_offset); + // For each field generates a table entry describing the field for the + // table driven serializer. + int GenerateFieldMetadata(io::Printer* printer); // Generate constructors and destructor. void GenerateStructors(io::Printer* printer); @@ -130,7 +130,7 @@ class MessageGenerator { // Generate the constexpr constructor for constant initialization of the // default instance. void GenerateConstexprConstructor(io::Printer* printer); - + // Generate standard Message methods. void GenerateClear(io::Printer* printer); void GenerateOneofClear(io::Printer* printer); @@ -146,16 +146,16 @@ 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 + // + // 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, - 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( + 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( io::Printer* printer, const std::vector<const FieldDescriptor*>& fields); void GenerateSerializeOneExtensionRange( io::Printer* printer, const Descriptor::ExtensionRange* range); @@ -172,17 +172,17 @@ class MessageGenerator { void GenerateFieldClear(const FieldDescriptor* field, bool is_inline, Formatter format); - void GenerateConstructorBody(io::Printer* printer, - std::vector<bool> already_processed, - bool copy_constructor) const; - - size_t HasBitsSize() const; + void GenerateConstructorBody(io::Printer* printer, + std::vector<bool> already_processed, + bool copy_constructor) const; + + size_t HasBitsSize() const; int HasBitIndex(const FieldDescriptor* a) const; int HasByteIndex(const FieldDescriptor* a) const; int HasWordIndex(const FieldDescriptor* a) const; bool SameHasByte(const FieldDescriptor* a, const FieldDescriptor* b) const; std::vector<uint32_t> RequiredFieldsBitMask() const; - + const Descriptor* descriptor_; int index_in_file_messages_; TProtoStringType classname_; @@ -191,26 +191,26 @@ 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 and weak 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_; + std::vector<int> has_bit_indices_; + int max_has_bit_index_; std::vector<const EnumGenerator*> enum_generators_; std::vector<const ExtensionGenerator*> extension_generators_; int num_required_fields_; - int num_weak_fields_; - // table_driven_ indicates the generated message uses table-driven parsing. - bool table_driven_; + int num_weak_fields_; + // table_driven_ indicates the generated message uses table-driven parsing. + bool table_driven_; std::unique_ptr<MessageLayoutHelper> message_layout_helper_; std::unique_ptr<ParseFunctionGenerator> parse_function_generator_; - + MessageSCCAnalyzer* scc_analyzer_; - + std::map<TProtoStringType, TProtoStringType> variables_; - friend class FileGenerator; + friend class FileGenerator; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageGenerator); }; diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message_field.cc index d40df23211..720ce273bd 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message_field.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message_field.cc @@ -35,7 +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 { @@ -61,7 +61,7 @@ void SetMessageVariables(const FieldDescriptor* descriptor, (*variables)["type"] = FieldMessageTypeName(descriptor, options); (*variables)["casted_member"] = ReinterpretCast( (*variables)["type"] + "*", (*variables)["name"] + "_", implicit_weak); - (*variables)["type_default_instance"] = + (*variables)["type_default_instance"] = QualifiedDefaultInstanceName(descriptor->message_type(), options); (*variables)["type_default_instance_ptr"] = QualifiedDefaultInstancePtr(descriptor->message_type(), options); @@ -386,20 +386,20 @@ void MessageFieldGenerator::GenerateMessageClearingCode( Formatter format(printer, variables_); if (!HasHasbit(descriptor_)) { - // If we don't have has-bits, message presence is indicated only by ptr != - // NULL. Thus on clear, we need to delete the object. + // If we don't have has-bits, message presence is indicated only by ptr != + // NULL. Thus on clear, we need to delete the object. format( "if (GetArenaForAllocation() == nullptr && $name$_ != nullptr) {\n" " delete $name$_;\n" "}\n" "$name$_ = nullptr;\n"); - } else { + } else { format( "$DCHK$($name$_ != nullptr);\n" "$name$_->Clear();\n"); - } -} - + } +} + void MessageFieldGenerator::GenerateMergingCode(io::Printer* printer) const { GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_)); @@ -420,8 +420,8 @@ void MessageFieldGenerator::GenerateSwappingCode(io::Printer* printer) const { Formatter format(printer, variables_); format("swap($name$_, other->$name$_);\n"); -} - +} + void MessageFieldGenerator::GenerateDestructorCode(io::Printer* printer) const { GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_)); @@ -440,11 +440,11 @@ void MessageFieldGenerator::GenerateDestructorCode(io::Printer* printer) const { void MessageFieldGenerator::GenerateConstructorCode( io::Printer* printer) const { GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_)); - + Formatter format(printer, variables_); format("$name$_ = nullptr;\n"); -} - +} + void MessageFieldGenerator::GenerateCopyConstructorCode( io::Printer* printer) const { GOOGLE_CHECK(!IsFieldStripped(descriptor_, options_)); @@ -621,9 +621,9 @@ void MessageOneofFieldGenerator::GenerateClearingCode( void MessageOneofFieldGenerator::GenerateMessageClearingCode( io::Printer* printer) const { - GenerateClearingCode(printer); -} - + GenerateClearingCode(printer); +} + void MessageOneofFieldGenerator::GenerateSwappingCode( io::Printer* printer) const { // Don't print any swapping code. Swapping the union will swap this field. @@ -631,10 +631,10 @@ void MessageOneofFieldGenerator::GenerateSwappingCode( void MessageOneofFieldGenerator::GenerateDestructorCode( io::Printer* printer) const { - // We inherit from MessageFieldGenerator, so we need to override the default - // behavior. -} - + // We inherit from MessageFieldGenerator, so we need to override the default + // behavior. +} + void MessageOneofFieldGenerator::GenerateConstructorCode( io::Printer* printer) const { // Don't print any constructor code. The field is in a union. We allocate diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message_field.h index ba01425625..4b4b8ea59b 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message_field.h +++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message_field.h @@ -60,12 +60,12 @@ class MessageFieldGenerator : public FieldGenerator { void GenerateInternalAccessorDeclarations(io::Printer* printer) const; void GenerateInternalAccessorDefinitions(io::Printer* printer) const; void GenerateClearingCode(io::Printer* printer) const; - void GenerateMessageClearingCode(io::Printer* printer) const; + void GenerateMessageClearingCode(io::Printer* printer) const; void GenerateMergingCode(io::Printer* printer) const; void GenerateSwappingCode(io::Printer* printer) const; - void GenerateDestructorCode(io::Printer* printer) const; + void GenerateDestructorCode(io::Printer* printer) const; void GenerateConstructorCode(io::Printer* printer) const; - void GenerateCopyConstructorCode(io::Printer* printer) const; + void GenerateCopyConstructorCode(io::Printer* printer) const; void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const; void GenerateByteSize(io::Printer* printer) const; void GenerateConstinitInitializer(io::Printer* printer) const; @@ -88,12 +88,12 @@ class MessageOneofFieldGenerator : public MessageFieldGenerator { void GenerateInlineAccessorDefinitions(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 - // override it as well. - void GenerateMessageClearingCode(io::Printer* printer) const; + + // MessageFieldGenerator, from which we inherit, overrides this so we need to + // override it as well. + void GenerateMessageClearingCode(io::Printer* printer) const; void GenerateSwappingCode(io::Printer* printer) const; - void GenerateDestructorCode(io::Printer* printer) const; + void GenerateDestructorCode(io::Printer* printer) const; void GenerateConstructorCode(io::Printer* printer) const; private: @@ -115,7 +115,7 @@ class RepeatedMessageFieldGenerator : public FieldGenerator { void GenerateMergingCode(io::Printer* printer) const; void GenerateSwappingCode(io::Printer* printer) const; void GenerateConstructorCode(io::Printer* printer) const; - void GenerateCopyConstructorCode(io::Printer* printer) const {} + void GenerateCopyConstructorCode(io::Printer* printer) const {} void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const; void GenerateByteSize(io::Printer* printer) const; void GenerateConstinitInitializer(io::Printer* printer) const; diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc index 1e65d302b5..da229ce3c4 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc @@ -193,8 +193,8 @@ void PrimitiveFieldGenerator::GenerateCopyConstructorCode( io::Printer* printer) const { Formatter format(printer, variables_); format("$name$_ = from.$name$_;\n"); -} - +} + void PrimitiveFieldGenerator::GenerateSerializeWithCachedSizesToArray( io::Printer* printer) const { Formatter format(printer, variables_); @@ -404,8 +404,8 @@ void RepeatedPrimitiveFieldGenerator::GenerateCopyConstructorCode( io::Printer* printer) const { Formatter format(printer, variables_); format("$name$_.CopyFrom(from.$name$_);\n"); -} - +} + void RepeatedPrimitiveFieldGenerator::GenerateSerializeWithCachedSizesToArray( io::Printer* printer) const { Formatter format(printer, variables_); @@ -426,7 +426,7 @@ void RepeatedPrimitiveFieldGenerator::GenerateSerializeWithCachedSizesToArray( " target = stream->WriteFixedPacked($number$, _internal_$name$(), " "target);\n" "}\n"); - } + } } else { format( "for (int i = 0, n = this->_internal_$name$_size(); i < n; i++) {\n" diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_primitive_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_primitive_field.h index b364e7aabf..394b304770 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_primitive_field.h +++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_primitive_field.h @@ -58,7 +58,7 @@ class PrimitiveFieldGenerator : public FieldGenerator { void GenerateMergingCode(io::Printer* printer) const; void GenerateSwappingCode(io::Printer* printer) const; void GenerateConstructorCode(io::Printer* printer) const; - void GenerateCopyConstructorCode(io::Printer* printer) const; + void GenerateCopyConstructorCode(io::Printer* printer) const; void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const; void GenerateByteSize(io::Printer* printer) const; void GenerateConstinitInitializer(io::Printer* printer) const; @@ -97,7 +97,7 @@ class RepeatedPrimitiveFieldGenerator : public FieldGenerator { void GenerateMergingCode(io::Printer* printer) const; void GenerateSwappingCode(io::Printer* printer) const; void GenerateConstructorCode(io::Printer* printer) const; - void GenerateCopyConstructorCode(io::Printer* printer) const; + void GenerateCopyConstructorCode(io::Printer* printer) const; void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const; void GenerateByteSize(io::Printer* printer) const; void GenerateConstinitInitializer(io::Printer* printer) const; diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_service.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_service.cc index d7c32d8aae..0a30646fd0 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_service.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_service.cc @@ -170,17 +170,17 @@ void ServiceGenerator::GenerateMethodSignatures(VirtualOrNon virtual_or_non, void ServiceGenerator::GenerateImplementation(io::Printer* printer) { Formatter format(printer, vars_); format( - "$classname$::~$classname$() {}\n" - "\n" + "$classname$::~$classname$() {}\n" + "\n" "const ::$proto_ns$::ServiceDescriptor* $classname$::descriptor() {\n" " " "::$proto_ns$::internal::AssignDescriptors(&$desc_table$);\n" " return $file_level_service_descriptors$[$1$];\n" - "}\n" - "\n" + "}\n" + "\n" "const ::$proto_ns$::ServiceDescriptor* $classname$::GetDescriptor() {\n" - " return descriptor();\n" - "}\n" + " return descriptor();\n" + "}\n" "\n", index_in_metadata_); @@ -234,7 +234,7 @@ void ServiceGenerator::GenerateCallMethod(io::Printer* printer) { " ::$proto_ns$::RpcController* controller,\n" " const ::$proto_ns$::Message* request,\n" " ::$proto_ns$::Message* response,\n" - " ::google::protobuf::Closure* done) {\n" + " ::google::protobuf::Closure* done) {\n" " GOOGLE_DCHECK_EQ(method->service(), $file_level_service_descriptors$[$1$]);\n" " switch(method->index()) {\n", index_in_metadata_); diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_service.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_service.h index 7a5c3449b8..f510716fed 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_service.h +++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_service.h @@ -108,9 +108,9 @@ class ServiceGenerator { std::map<TProtoStringType, TProtoStringType> vars_; const Options& options_; - int index_in_metadata_; - - friend class FileGenerator; + int index_in_metadata_; + + friend class FileGenerator; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ServiceGenerator); }; diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_string_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_string_field.cc index f3b148722b..12faeaf7a0 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_string_field.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_string_field.cc @@ -54,7 +54,7 @@ void SetStringVariables(const FieldDescriptor* descriptor, (*variables)["default_length"] = StrCat(descriptor->default_value_string().length()); TProtoStringType default_variable_string = MakeDefaultName(descriptor); - (*variables)["default_variable_name"] = default_variable_string; + (*variables)["default_variable_name"] = default_variable_string; if (!descriptor->default_value_string().empty()) { (*variables)["lazy_variable"] = @@ -235,7 +235,7 @@ void StringFieldGenerator::GenerateInlineAccessorDefinitions( " if (!_internal_has_$name$()) {\n" " return nullptr;\n" " }\n" - " $clear_hasbit$\n" + " $clear_hasbit$\n" " return $name$_.ReleaseNonDefault($init_value$, " "GetArenaForAllocation());\n"); } else { @@ -282,30 +282,30 @@ void StringFieldGenerator::GenerateClearingCode(io::Printer* printer) const { void StringFieldGenerator::GenerateMessageClearingCode( io::Printer* printer) const { Formatter format(printer, variables_); - // Two-dimension specialization here: supporting arenas, field presence, or - // not, and default value is the empty string or not. Complexity here ensures - // the minimal number of branches / amount of extraneous code at runtime - // (given that the below methods are inlined one-liners)! - + // Two-dimension specialization here: supporting arenas, field presence, or + // not, and default value is the empty string or not. Complexity here ensures + // the minimal number of branches / amount of extraneous code at runtime + // (given that the below methods are inlined one-liners)! + // If we have a hasbit, then the Clear() method of the protocol buffer - // will have checked that this field is set. If so, we can avoid redundant + // will have checked that this field is set. If so, we can avoid redundant // checks against the default variable. const bool must_be_present = HasHasbit(descriptor_); - + if (descriptor_->default_value_string().empty()) { if (must_be_present) { format("$name$_.ClearNonDefaultToEmpty();\n"); - } else { + } else { format("$name$_.ClearToEmpty();\n"); - } - } else { + } + } else { // Clear to a non-empty default is more involved, as we try to use the // Arena if one is present and may need to reallocate the string. format( "$name$_.ClearToDefault($lazy_variable$, GetArenaForAllocation());\n "); - } -} - + } +} + void StringFieldGenerator::GenerateMergingCode(io::Printer* printer) const { Formatter format(printer, variables_); // TODO(gpike): improve this @@ -330,25 +330,25 @@ void StringFieldGenerator::GenerateConstructorCode(io::Printer* printer) const { void StringFieldGenerator::GenerateCopyConstructorCode( io::Printer* printer) const { Formatter format(printer, variables_); - GenerateConstructorCode(printer); - + GenerateConstructorCode(printer); + if (HasHasbit(descriptor_)) { format("if (from._internal_has_$name$()) {\n"); - } else { + } else { format("if (!from._internal_$name$().empty()) {\n"); - } - + } + format.Indent(); - + // TODO(gpike): improve this format( "$name$_.Set($default_value_tag$, from._internal_$name$(), \n" " GetArenaForAllocation());\n"); - + format.Outdent(); format("}\n"); -} - +} + void StringFieldGenerator::GenerateDestructorCode(io::Printer* printer) const { Formatter format(printer, variables_); format("$name$_.DestroyNoArena($init_value$);\n"); @@ -491,9 +491,9 @@ void StringOneofFieldGenerator::GenerateClearingCode( void StringOneofFieldGenerator::GenerateMessageClearingCode( io::Printer* printer) const { - return GenerateClearingCode(printer); -} - + return GenerateClearingCode(printer); +} + void StringOneofFieldGenerator::GenerateSwappingCode( io::Printer* printer) const { // Don't print any swapping code. Swapping the union will swap this field. @@ -733,8 +733,8 @@ void RepeatedStringFieldGenerator::GenerateCopyConstructorCode( io::Printer* printer) const { Formatter format(printer, variables_); format("$name$_.CopyFrom(from.$name$_);"); -} - +} + void RepeatedStringFieldGenerator::GenerateSerializeWithCachedSizesToArray( io::Printer* printer) const { Formatter format(printer, variables_); diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_string_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_string_field.h index 4fba8c3f48..213f13465d 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_string_field.h +++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_string_field.h @@ -57,11 +57,11 @@ class StringFieldGenerator : public FieldGenerator { void GenerateInlineAccessorDefinitions(io::Printer* printer) const; void GenerateNonInlineAccessorDefinitions(io::Printer* printer) const; void GenerateClearingCode(io::Printer* printer) const; - void GenerateMessageClearingCode(io::Printer* printer) const; + void GenerateMessageClearingCode(io::Printer* printer) const; void GenerateMergingCode(io::Printer* printer) const; void GenerateSwappingCode(io::Printer* printer) const; void GenerateConstructorCode(io::Printer* printer) const; - void GenerateCopyConstructorCode(io::Printer* printer) const; + void GenerateCopyConstructorCode(io::Printer* printer) const; void GenerateDestructorCode(io::Printer* printer) const; void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const; void GenerateByteSize(io::Printer* printer) const; @@ -80,10 +80,10 @@ class StringOneofFieldGenerator : public StringFieldGenerator { // implements FieldGenerator --------------------------------------- void GenerateInlineAccessorDefinitions(io::Printer* printer) const; void GenerateClearingCode(io::Printer* printer) const; - - // StringFieldGenerator, from which we inherit, overrides this so we need to - // override it as well. - void GenerateMessageClearingCode(io::Printer* printer) const; + + // StringFieldGenerator, from which we inherit, overrides this so we need to + // override it as well. + void GenerateMessageClearingCode(io::Printer* printer) const; void GenerateSwappingCode(io::Printer* printer) const; void GenerateConstructorCode(io::Printer* printer) const; @@ -105,7 +105,7 @@ class RepeatedStringFieldGenerator : public FieldGenerator { void GenerateMergingCode(io::Printer* printer) const; void GenerateSwappingCode(io::Printer* printer) const; void GenerateConstructorCode(io::Printer* printer) const; - void GenerateCopyConstructorCode(io::Printer* printer) const; + void GenerateCopyConstructorCode(io::Printer* printer) const; void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const; void GenerateByteSize(io::Printer* printer) const; void GenerateConstinitInitializer(io::Printer* printer) const; diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/importer.cc b/contrib/libs/protoc/src/google/protobuf/compiler/importer.cc index e3d66b72dd..2fdbf5ce1f 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/importer.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/importer.cc @@ -52,21 +52,21 @@ #include <google/protobuf/stubs/strutil.h> #include <google/protobuf/io/io_win32.h> -#ifdef _WIN32 -#include <ctype.h> -#endif - +#ifdef _WIN32 +#include <ctype.h> +#endif + namespace google { namespace protobuf { namespace compiler { #ifdef _WIN32 -// DO NOT include <io.h>, instead create functions in io_win32.{h,cc} and import -// them like we do below. +// DO NOT include <io.h>, instead create functions in io_win32.{h,cc} and import +// them like we do below. using google::protobuf::io::win32::access; using google::protobuf::io::win32::open; -#endif - +#endif + // 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 command_line_interface.cc? @@ -240,7 +240,7 @@ void Importer::ClearUnusedImportTrackFiles() { pool_.ClearUnusedImportTrackFiles(); } - + // =================================================================== SourceTree::~SourceTree() {} @@ -311,7 +311,7 @@ static TProtoStringType CanonicalizePath(TProtoStringType path) { } static inline bool ContainsParentReference(const TProtoStringType& path) { - return path == ".." || HasPrefixString(path, "../") || + return path == ".." || HasPrefixString(path, "../") || HasSuffixString(path, "/..") || path.find("/../") != TProtoStringType::npos; } @@ -341,7 +341,7 @@ static bool ApplyMapping(const TProtoStringType& filename, // We do not allow the file name to use "..". return false; } - if (HasPrefixString(filename, "/") || IsWindowsAbsolutePath(filename)) { + if (HasPrefixString(filename, "/") || IsWindowsAbsolutePath(filename)) { // This is an absolute path, so it isn't matched by the empty string. return false; } diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/importer.h b/contrib/libs/protoc/src/google/protobuf/compiler/importer.h index a08977b868..f38fcf2d67 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/importer.h +++ b/contrib/libs/protoc/src/google/protobuf/compiler/importer.h @@ -182,7 +182,7 @@ class PROTOBUF_EXPORT Importer { bool is_error = false); void ClearUnusedImportTrackFiles(); - + private: SourceTreeDescriptorDatabase database_; DescriptorPool pool_; diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_context.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_context.cc index 7d9cd14c0a..3403cfca2c 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_context.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_context.cc @@ -49,7 +49,7 @@ Context::Context(const FileDescriptor* file, const Options& options) Context::~Context() {} -ClassNameResolver* Context::GetNameResolver() const { +ClassNameResolver* Context::GetNameResolver() const { return name_resolver_.get(); } @@ -154,7 +154,7 @@ void Context::InitializeFieldGeneratorInfoForFields( for (int i = 0; i < fields.size(); ++i) { const FieldDescriptor* field = fields[i]; FieldGeneratorInfo info; - info.name = CamelCaseFieldName(field); + info.name = CamelCaseFieldName(field); info.capitalized_name = UnderscoresToCapitalizedCamelCase(field); // For fields conflicting with some other fields, we append the field // number to their field names in generated code to avoid conflicts. diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_context.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_context.h index 1640802aba..3fa6af1778 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_context.h +++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_context.h @@ -69,7 +69,7 @@ class Context { // Get the name resolver associated with this context. The resolver // can be used to map descriptors to Java class names. - ClassNameResolver* GetNameResolver() const; + ClassNameResolver* GetNameResolver() const; // Get the FieldGeneratorInfo for a given field. const FieldGeneratorInfo* GetFieldGeneratorInfo( @@ -97,10 +97,10 @@ class Context { const std::vector<const FieldDescriptor*>& fields); std::unique_ptr<ClassNameResolver> name_resolver_; - std::map<const FieldDescriptor*, FieldGeneratorInfo> - field_generator_info_map_; - std::map<const OneofDescriptor*, OneofGeneratorInfo> - oneof_generator_info_map_; + std::map<const FieldDescriptor*, FieldGeneratorInfo> + field_generator_info_map_; + std::map<const OneofDescriptor*, OneofGeneratorInfo> + oneof_generator_info_map_; Options options_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Context); }; diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum.cc index 2233e93bc3..d9070eeaab 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum.cc @@ -108,16 +108,16 @@ void EnumGenerator::Generate(io::Printer* printer) { } else { printer->Print(vars, "$name$($index$, $number$),\n"); } - printer->Annotate("name", canonical_values_[i]); + printer->Annotate("name", canonical_values_[i]); } if (SupportUnknownEnumValue(descriptor_->file())) { if (ordinal_is_index) { - printer->Print("${$UNRECOGNIZED$}$(-1),\n", "{", "", "}", ""); + printer->Print("${$UNRECOGNIZED$}$(-1),\n", "{", "", "}", ""); } else { - printer->Print("${$UNRECOGNIZED$}$(-1, -1),\n", "{", "", "}", ""); + printer->Print("${$UNRECOGNIZED$}$(-1, -1),\n", "{", "", "}", ""); } - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); } printer->Print( @@ -134,15 +134,15 @@ void EnumGenerator::Generate(io::Printer* printer) { WriteEnumValueDocComment(printer, aliases_[i].value); printer->Print( vars, "public static final $classname$ $name$ = $canonical_name$;\n"); - printer->Annotate("name", aliases_[i].value); + printer->Annotate("name", aliases_[i].value); } for (int i = 0; i < descriptor_->value_count(); i++) { std::map<TProtoStringType, TProtoStringType> vars; vars["name"] = descriptor_->value(i)->name(); vars["number"] = StrCat(descriptor_->value(i)->number()); - vars["{"] = ""; - vars["}"] = ""; + vars["{"] = ""; + vars["}"] = ""; vars["deprecation"] = descriptor_->value(i)->options().deprecated() ? "@java.lang.Deprecated " : ""; @@ -150,7 +150,7 @@ void EnumGenerator::Generate(io::Printer* printer) { printer->Print(vars, "$deprecation$public static final int ${$$name$_VALUE$}$ = " "$number$;\n"); - printer->Annotate("{", "}", descriptor_->value(i)); + printer->Annotate("{", "}", descriptor_->value(i)); } printer->Print("\n"); @@ -266,10 +266,10 @@ void EnumGenerator::Generate(io::Printer* printer) { // at module init time because it wouldn't work with descriptor.proto, but // we can cache the value the first time getDescriptor() is called. if (descriptor_->containing_type() == NULL) { - // The class generated for the File fully populates the descriptor with - // extensions in both the mutable and immutable cases. (In the mutable api - // this is accomplished by attempting to load the immutable outer class). - printer->Print( + // The class generated for the File fully populates the descriptor with + // extensions in both the mutable and immutable cases. (In the mutable api + // this is accomplished by attempting to load the immutable outer class). + printer->Print( " return $file$.getDescriptor().getEnumTypes().get($index$);\n", "file", name_resolver_->GetClassName(descriptor_->file(), immutable_api_), diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_field.cc index 0d7eeca610..318c820198 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_field.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_field.cc @@ -186,7 +186,7 @@ void ImmutableEnumFieldGenerator::GenerateMembers(io::Printer* printer) const { "${$has$capitalized_name$$}$() {\n" " return $get_has_field_bit_message$;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); } if (SupportUnknownEnumValue(descriptor_->file())) { WriteFieldEnumValueAccessorDocComment(printer, descriptor_, GETTER); @@ -195,7 +195,7 @@ void ImmutableEnumFieldGenerator::GenerateMembers(io::Printer* printer) const { "${$get$capitalized_name$Value$}$() {\n" " return $name$_;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); } WriteFieldAccessorDocComment(printer, descriptor_, GETTER); printer->Print(variables_, @@ -205,7 +205,7 @@ void ImmutableEnumFieldGenerator::GenerateMembers(io::Printer* printer) const { " $type$ result = $type$.$for_number$($name$_);\n" " return result == null ? $unknown$ : result;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); } void ImmutableEnumFieldGenerator::GenerateBuilderMembers( @@ -218,7 +218,7 @@ void ImmutableEnumFieldGenerator::GenerateBuilderMembers( "${$has$capitalized_name$$}$() {\n" " return $get_has_field_bit_builder$;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); } if (SupportUnknownEnumValue(descriptor_->file())) { WriteFieldEnumValueAccessorDocComment(printer, descriptor_, GETTER); @@ -227,7 +227,7 @@ void ImmutableEnumFieldGenerator::GenerateBuilderMembers( "${$get$capitalized_name$Value$}$() {\n" " return $name$_;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldEnumValueAccessorDocComment(printer, descriptor_, SETTER, /* builder */ true); printer->Print(variables_, @@ -238,7 +238,7 @@ void ImmutableEnumFieldGenerator::GenerateBuilderMembers( " $on_changed$\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); } WriteFieldAccessorDocComment(printer, descriptor_, GETTER); printer->Print(variables_, @@ -248,7 +248,7 @@ void ImmutableEnumFieldGenerator::GenerateBuilderMembers( " $type$ result = $type$.$for_number$($name$_);\n" " return result == null ? $unknown$ : result;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, SETTER, /* builder */ true); printer->Print(variables_, @@ -262,7 +262,7 @@ void ImmutableEnumFieldGenerator::GenerateBuilderMembers( " $on_changed$\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, CLEARER, /* builder */ true); printer->Print( @@ -443,7 +443,7 @@ void ImmutableEnumOneofFieldGenerator::GenerateMembers( " }\n" " return $default_number$;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); } WriteFieldAccessorDocComment(printer, descriptor_, GETTER); printer->Print(variables_, @@ -456,7 +456,7 @@ void ImmutableEnumOneofFieldGenerator::GenerateMembers( " }\n" " return $default$;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); } void ImmutableEnumOneofFieldGenerator::GenerateBuilderMembers( @@ -481,7 +481,7 @@ void ImmutableEnumOneofFieldGenerator::GenerateBuilderMembers( " }\n" " return $default_number$;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldEnumValueAccessorDocComment(printer, descriptor_, SETTER, /* builder */ true); printer->Print(variables_, @@ -492,7 +492,7 @@ void ImmutableEnumOneofFieldGenerator::GenerateBuilderMembers( " $on_changed$\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); } WriteFieldAccessorDocComment(printer, descriptor_, GETTER); printer->Print(variables_, @@ -506,7 +506,7 @@ void ImmutableEnumOneofFieldGenerator::GenerateBuilderMembers( " }\n" " return $default$;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, SETTER, /* builder */ true); printer->Print(variables_, @@ -520,7 +520,7 @@ void ImmutableEnumOneofFieldGenerator::GenerateBuilderMembers( " $on_changed$\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, CLEARER, /* builder */ true); printer->Print( @@ -533,7 +533,7 @@ void ImmutableEnumOneofFieldGenerator::GenerateBuilderMembers( " }\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); } void ImmutableEnumOneofFieldGenerator::GenerateBuildingCode( @@ -696,7 +696,7 @@ void RepeatedImmutableEnumFieldGenerator::GenerateMembers( " return new com.google.protobuf.Internal.ListAdapter<\n" " java.lang.Integer, $type$>($name$_, $name$_converter_);\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, LIST_COUNT); printer->Print( variables_, @@ -704,7 +704,7 @@ void RepeatedImmutableEnumFieldGenerator::GenerateMembers( "$deprecation$public int ${$get$capitalized_name$Count$}$() {\n" " return $name$_.size();\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER); printer->Print( variables_, @@ -712,7 +712,7 @@ void RepeatedImmutableEnumFieldGenerator::GenerateMembers( "$deprecation$public $type$ ${$get$capitalized_name$$}$(int index) {\n" " return $name$_converter_.convert($name$_.get(index));\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); if (SupportUnknownEnumValue(descriptor_->file())) { WriteFieldEnumValueAccessorDocComment(printer, descriptor_, LIST_GETTER); printer->Print(variables_, @@ -721,7 +721,7 @@ void RepeatedImmutableEnumFieldGenerator::GenerateMembers( "${$get$capitalized_name$ValueList$}$() {\n" " return $name$_;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldEnumValueAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER); printer->Print(variables_, @@ -730,7 +730,7 @@ void RepeatedImmutableEnumFieldGenerator::GenerateMembers( "${$get$capitalized_name$Value$}$(int index) {\n" " return $name$_.get(index);\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); } if (descriptor_->is_packed()) { @@ -773,21 +773,21 @@ void RepeatedImmutableEnumFieldGenerator::GenerateBuilderMembers( " return new com.google.protobuf.Internal.ListAdapter<\n" " java.lang.Integer, $type$>($name$_, $name$_converter_);\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, LIST_COUNT); printer->Print( variables_, "$deprecation$public int ${$get$capitalized_name$Count$}$() {\n" " return $name$_.size();\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER); printer->Print( variables_, "$deprecation$public $type$ ${$get$capitalized_name$$}$(int index) {\n" " return $name$_converter_.convert($name$_.get(index));\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_SETTER, /* builder */ true); printer->Print(variables_, @@ -801,7 +801,7 @@ void RepeatedImmutableEnumFieldGenerator::GenerateBuilderMembers( " $on_changed$\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER, /* builder */ true); printer->Print(variables_, @@ -815,7 +815,7 @@ void RepeatedImmutableEnumFieldGenerator::GenerateBuilderMembers( " $on_changed$\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER, /* builder */ true); printer->Print(variables_, @@ -828,7 +828,7 @@ void RepeatedImmutableEnumFieldGenerator::GenerateBuilderMembers( " $on_changed$\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, CLEARER, /* builder */ true); printer->Print( @@ -839,7 +839,7 @@ void RepeatedImmutableEnumFieldGenerator::GenerateBuilderMembers( " $on_changed$\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); if (SupportUnknownEnumValue(descriptor_->file())) { WriteFieldEnumValueAccessorDocComment(printer, descriptor_, LIST_GETTER); @@ -848,7 +848,7 @@ void RepeatedImmutableEnumFieldGenerator::GenerateBuilderMembers( "${$get$capitalized_name$ValueList$}$() {\n" " return java.util.Collections.unmodifiableList($name$_);\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldEnumValueAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER); printer->Print(variables_, @@ -856,7 +856,7 @@ void RepeatedImmutableEnumFieldGenerator::GenerateBuilderMembers( "${$get$capitalized_name$Value$}$(int index) {\n" " return $name$_.get(index);\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldEnumValueAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER, /* builder */ true); @@ -869,7 +869,7 @@ void RepeatedImmutableEnumFieldGenerator::GenerateBuilderMembers( " $on_changed$\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldEnumValueAccessorDocComment(printer, descriptor_, LIST_ADDER, /* builder */ true); printer->Print(variables_, @@ -880,7 +880,7 @@ void RepeatedImmutableEnumFieldGenerator::GenerateBuilderMembers( " $on_changed$\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldEnumValueAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER, /* builder */ true); printer->Print( @@ -894,7 +894,7 @@ void RepeatedImmutableEnumFieldGenerator::GenerateBuilderMembers( " $on_changed$\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); } } diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_field_lite.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_field_lite.cc index 06ba0084a0..e94f70289b 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_field_lite.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_field_lite.cc @@ -89,7 +89,7 @@ void SetEnumVariables(const FieldDescriptor* descriptor, int messageBitIndex, ? "@kotlin.Deprecated(message = \"Field " + (*variables)["name"] + " is deprecated\") " : ""; - (*variables)["required"] = descriptor->is_required() ? "true" : "false"; + (*variables)["required"] = descriptor->is_required() ? "true" : "false"; if (HasHasbit(descriptor)) { // For singular messages and builders, one bit is used for the hasField bit. @@ -176,7 +176,7 @@ void ImmutableEnumFieldLiteGenerator::GenerateMembers( "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return $get_has_field_bit_message$;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); } if (SupportUnknownEnumValue(descriptor_->file())) { WriteFieldEnumValueAccessorDocComment(printer, descriptor_, GETTER); @@ -186,7 +186,7 @@ void ImmutableEnumFieldLiteGenerator::GenerateMembers( "$deprecation$public int ${$get$capitalized_name$Value$}$() {\n" " return $name$_;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); } WriteFieldAccessorDocComment(printer, descriptor_, GETTER); printer->Print(variables_, @@ -195,7 +195,7 @@ void ImmutableEnumFieldLiteGenerator::GenerateMembers( " $type$ result = $type$.forNumber($name$_);\n" " return result == null ? $unknown$ : result;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); // Generate private setters for the builder to proxy into. if (SupportUnknownEnumValue(descriptor_->file())) { @@ -230,7 +230,7 @@ void ImmutableEnumFieldLiteGenerator::GenerateBuilderMembers( "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return instance.has$capitalized_name$();\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); } if (SupportUnknownEnumValue(descriptor_->file())) { WriteFieldEnumValueAccessorDocComment(printer, descriptor_, GETTER); @@ -240,7 +240,7 @@ void ImmutableEnumFieldLiteGenerator::GenerateBuilderMembers( "$deprecation$public int ${$get$capitalized_name$Value$}$() {\n" " return instance.get$capitalized_name$Value();\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, SETTER, /* builder */ true); printer->Print(variables_, @@ -250,7 +250,7 @@ void ImmutableEnumFieldLiteGenerator::GenerateBuilderMembers( " instance.set$capitalized_name$Value(value);\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); } WriteFieldAccessorDocComment(printer, descriptor_, GETTER); printer->Print(variables_, @@ -258,7 +258,7 @@ void ImmutableEnumFieldLiteGenerator::GenerateBuilderMembers( "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n" " return instance.get$capitalized_name$();\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldEnumValueAccessorDocComment(printer, descriptor_, SETTER, /* builder */ true); printer->Print(variables_, @@ -268,7 +268,7 @@ void ImmutableEnumFieldLiteGenerator::GenerateBuilderMembers( " instance.set$capitalized_name$(value);\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, CLEARER, /* builder */ true); printer->Print( @@ -278,7 +278,7 @@ void ImmutableEnumFieldLiteGenerator::GenerateBuilderMembers( " instance.clear$capitalized_name$();\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); } void ImmutableEnumFieldLiteGenerator::GenerateKotlinDslMembers( @@ -372,7 +372,7 @@ void ImmutableEnumOneofFieldLiteGenerator::GenerateMembers( " }\n" " return $default_number$;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); } WriteFieldAccessorDocComment(printer, descriptor_, GETTER); printer->Print(variables_, @@ -385,7 +385,7 @@ void ImmutableEnumOneofFieldLiteGenerator::GenerateMembers( " }\n" " return $default$;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); // Generate private setters for the builder to proxy into. if (SupportUnknownEnumValue(descriptor_->file())) { @@ -425,7 +425,7 @@ void ImmutableEnumOneofFieldLiteGenerator::GenerateFieldInfo( /*enforce_lite=*/context_->EnforceLite()); } } - + void ImmutableEnumOneofFieldLiteGenerator::GenerateBuilderMembers( io::Printer* printer) const { GOOGLE_DCHECK(HasHazzer(descriptor_)); @@ -445,7 +445,7 @@ void ImmutableEnumOneofFieldLiteGenerator::GenerateBuilderMembers( "$deprecation$public int ${$get$capitalized_name$Value$}$() {\n" " return instance.get$capitalized_name$Value();\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldEnumValueAccessorDocComment(printer, descriptor_, SETTER, /* builder */ true); printer->Print(variables_, @@ -455,7 +455,7 @@ void ImmutableEnumOneofFieldLiteGenerator::GenerateBuilderMembers( " instance.set$capitalized_name$Value(value);\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); } WriteFieldAccessorDocComment(printer, descriptor_, GETTER); printer->Print(variables_, @@ -463,7 +463,7 @@ void ImmutableEnumOneofFieldLiteGenerator::GenerateBuilderMembers( "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n" " return instance.get$capitalized_name$();\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, SETTER, /* builder */ true); printer->Print(variables_, @@ -473,7 +473,7 @@ void ImmutableEnumOneofFieldLiteGenerator::GenerateBuilderMembers( " instance.set$capitalized_name$(value);\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, CLEARER, /* builder */ true); printer->Print( @@ -483,7 +483,7 @@ void ImmutableEnumOneofFieldLiteGenerator::GenerateBuilderMembers( " instance.clear$capitalized_name$();\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); } // =================================================================== @@ -557,7 +557,7 @@ void RepeatedImmutableEnumFieldLiteGenerator::GenerateMembers( " return new com.google.protobuf.Internal.ListAdapter<\n" " java.lang.Integer, $type$>($name$_, $name$_converter_);\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, LIST_COUNT); printer->Print( variables_, @@ -565,7 +565,7 @@ void RepeatedImmutableEnumFieldLiteGenerator::GenerateMembers( "$deprecation$public int ${$get$capitalized_name$Count$}$() {\n" " return $name$_.size();\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER); printer->Print( variables_, @@ -573,7 +573,7 @@ void RepeatedImmutableEnumFieldLiteGenerator::GenerateMembers( "$deprecation$public $type$ ${$get$capitalized_name$$}$(int index) {\n" " return $name$_converter_.convert($name$_.getInt(index));\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); if (SupportUnknownEnumValue(descriptor_->file())) { WriteFieldEnumValueAccessorDocComment(printer, descriptor_, LIST_GETTER); printer->Print(variables_, @@ -582,7 +582,7 @@ void RepeatedImmutableEnumFieldLiteGenerator::GenerateMembers( "${$get$capitalized_name$ValueList$}$() {\n" " return $name$_;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldEnumValueAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER); printer->Print(variables_, @@ -591,7 +591,7 @@ void RepeatedImmutableEnumFieldLiteGenerator::GenerateMembers( "${$get$capitalized_name$Value$}$(int index) {\n" " return $name$_.getInt(index);\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); } if (!EnableExperimentalRuntimeForLite() && descriptor_->is_packed() && @@ -680,7 +680,7 @@ void RepeatedImmutableEnumFieldLiteGenerator::GenerateFieldInfo( /*enforce_lite=*/context_->EnforceLite()); } } - + void RepeatedImmutableEnumFieldLiteGenerator::GenerateBuilderMembers( io::Printer* printer) const { WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER); @@ -690,7 +690,7 @@ void RepeatedImmutableEnumFieldLiteGenerator::GenerateBuilderMembers( "${$get$capitalized_name$List$}$() {\n" " return instance.get$capitalized_name$List();\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, LIST_COUNT); printer->Print( variables_, @@ -698,7 +698,7 @@ void RepeatedImmutableEnumFieldLiteGenerator::GenerateBuilderMembers( "$deprecation$public int ${$get$capitalized_name$Count$}$() {\n" " return instance.get$capitalized_name$Count();\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER); printer->Print( variables_, @@ -706,7 +706,7 @@ void RepeatedImmutableEnumFieldLiteGenerator::GenerateBuilderMembers( "$deprecation$public $type$ ${$get$capitalized_name$$}$(int index) {\n" " return instance.get$capitalized_name$(index);\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_SETTER, /* builder */ true); printer->Print(variables_, @@ -716,7 +716,7 @@ void RepeatedImmutableEnumFieldLiteGenerator::GenerateBuilderMembers( " instance.set$capitalized_name$(index, value);\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER, /* builder */ true); printer->Print(variables_, @@ -726,7 +726,7 @@ void RepeatedImmutableEnumFieldLiteGenerator::GenerateBuilderMembers( " instance.add$capitalized_name$(value);\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER, /* builder */ true); printer->Print(variables_, @@ -736,7 +736,7 @@ void RepeatedImmutableEnumFieldLiteGenerator::GenerateBuilderMembers( " instance.addAll$capitalized_name$(values);" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, CLEARER, /* builder */ true); printer->Print( @@ -746,7 +746,7 @@ void RepeatedImmutableEnumFieldLiteGenerator::GenerateBuilderMembers( " instance.clear$capitalized_name$();\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); if (SupportUnknownEnumValue(descriptor_->file())) { WriteFieldEnumValueAccessorDocComment(printer, descriptor_, LIST_GETTER); @@ -757,7 +757,7 @@ void RepeatedImmutableEnumFieldLiteGenerator::GenerateBuilderMembers( " return java.util.Collections.unmodifiableList(\n" " instance.get$capitalized_name$ValueList());\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldEnumValueAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER); printer->Print(variables_, @@ -766,7 +766,7 @@ void RepeatedImmutableEnumFieldLiteGenerator::GenerateBuilderMembers( "${$get$capitalized_name$Value$}$(int index) {\n" " return instance.get$capitalized_name$Value(index);\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldEnumValueAccessorDocComment(printer, descriptor_, LIST_INDEXED_SETTER, /* builder */ true); @@ -778,7 +778,7 @@ void RepeatedImmutableEnumFieldLiteGenerator::GenerateBuilderMembers( " instance.set$capitalized_name$Value(index, value);\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldEnumValueAccessorDocComment(printer, descriptor_, LIST_ADDER, /* builder */ true); printer->Print(variables_, @@ -787,7 +787,7 @@ void RepeatedImmutableEnumFieldLiteGenerator::GenerateBuilderMembers( " instance.add$capitalized_name$Value(value);\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldEnumValueAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER, /* builder */ true); @@ -799,7 +799,7 @@ void RepeatedImmutableEnumFieldLiteGenerator::GenerateBuilderMembers( " instance.addAll$capitalized_name$Value(values);\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); } } diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_lite.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_lite.cc index bb2f6dc9c2..bf84607aac 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_lite.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_enum_lite.cc @@ -94,12 +94,12 @@ void EnumLiteGenerator::Generate(io::Printer* printer) { printer->Print("@java.lang.Deprecated\n"); } printer->Print(vars, "$name$($number$),\n"); - printer->Annotate("name", canonical_values_[i]); + printer->Annotate("name", canonical_values_[i]); } if (SupportUnknownEnumValue(descriptor_->file())) { - printer->Print("${$UNRECOGNIZED$}$(-1),\n", "{", "", "}", ""); - printer->Annotate("{", "}", descriptor_); + printer->Print("${$UNRECOGNIZED$}$(-1),\n", "{", "", "}", ""); + printer->Annotate("{", "}", descriptor_); } printer->Print( @@ -116,15 +116,15 @@ void EnumLiteGenerator::Generate(io::Printer* printer) { WriteEnumValueDocComment(printer, aliases_[i].value); printer->Print( vars, "public static final $classname$ $name$ = $canonical_name$;\n"); - printer->Annotate("name", aliases_[i].value); + printer->Annotate("name", aliases_[i].value); } for (int i = 0; i < descriptor_->value_count(); i++) { std::map<TProtoStringType, TProtoStringType> vars; vars["name"] = descriptor_->value(i)->name(); vars["number"] = StrCat(descriptor_->value(i)->number()); - vars["{"] = ""; - vars["}"] = ""; + vars["{"] = ""; + vars["}"] = ""; vars["deprecation"] = descriptor_->value(i)->options().deprecated() ? "@java.lang.Deprecated " : ""; @@ -132,40 +132,40 @@ void EnumLiteGenerator::Generate(io::Printer* printer) { printer->Print(vars, "$deprecation$public static final int ${$$name$_VALUE$}$ = " "$number$;\n"); - printer->Annotate("{", "}", descriptor_->value(i)); + printer->Annotate("{", "}", descriptor_->value(i)); } printer->Print("\n"); // ----------------------------------------------------------------- printer->Print( - "\n" + "\n" "@java.lang.Override\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" + "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" " * @param value The number of the enum to look for.\n" " * @return The enum associated with the given number.\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()); + " * @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/contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension.cc index 04486b3ee3..9602780c49 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_extension.cc @@ -60,7 +60,7 @@ ImmutableExtensionGenerator::ImmutableExtensionGenerator( ImmutableExtensionGenerator::~ImmutableExtensionGenerator() {} // Initializes the vars referenced in the generated code templates. -void ExtensionGenerator::InitTemplateVars( +void ExtensionGenerator::InitTemplateVars( const FieldDescriptor* descriptor, const TProtoStringType& scope, bool immutable, ClassNameResolver* name_resolver, std::map<TProtoStringType, TProtoStringType>* vars_pointer) { @@ -76,7 +76,7 @@ void ExtensionGenerator::InitTemplateVars( ? "" : DefaultValue(descriptor, immutable, name_resolver); vars["type_constant"] = FieldTypeName(GetType(descriptor)); - vars["packed"] = descriptor->is_packed() ? "true" : "false"; + vars["packed"] = descriptor->is_packed() ? "true" : "false"; vars["enum_map"] = "null"; vars["prototype"] = "null"; diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_field.cc index 3a0bc21722..15283e1083 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_field.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_field.cc @@ -73,8 +73,8 @@ ImmutableFieldGenerator* MakeImmutableGenerator(const FieldDescriptor* field, return new ImmutableMapFieldGenerator(field, messageBitIndex, builderBitIndex, context); } else { - return new RepeatedImmutableMessageFieldGenerator( - field, messageBitIndex, builderBitIndex, context); + return new RepeatedImmutableMessageFieldGenerator( + field, messageBitIndex, builderBitIndex, context); } case JAVATYPE_ENUM: return new RepeatedImmutableEnumFieldGenerator( @@ -90,8 +90,8 @@ ImmutableFieldGenerator* MakeImmutableGenerator(const FieldDescriptor* field, if (IsRealOneof(field)) { switch (GetJavaType(field)) { case JAVATYPE_MESSAGE: - return new ImmutableMessageOneofFieldGenerator( - field, messageBitIndex, builderBitIndex, context); + return new ImmutableMessageOneofFieldGenerator( + field, messageBitIndex, builderBitIndex, context); case JAVATYPE_ENUM: return new ImmutableEnumOneofFieldGenerator(field, messageBitIndex, builderBitIndex, context); @@ -130,7 +130,7 @@ ImmutableFieldLiteGenerator* MakeImmutableLiteGenerator( return new ImmutableMapFieldLiteGenerator(field, messageBitIndex, context); } else { - return new RepeatedImmutableMessageFieldLiteGenerator( + return new RepeatedImmutableMessageFieldLiteGenerator( field, messageBitIndex, context); } case JAVATYPE_ENUM: @@ -147,7 +147,7 @@ ImmutableFieldLiteGenerator* MakeImmutableLiteGenerator( if (IsRealOneof(field)) { switch (GetJavaType(field)) { case JAVATYPE_MESSAGE: - return new ImmutableMessageOneofFieldLiteGenerator( + return new ImmutableMessageOneofFieldLiteGenerator( field, messageBitIndex, context); case JAVATYPE_ENUM: return new ImmutableEnumOneofFieldLiteGenerator( @@ -246,18 +246,18 @@ void SetCommonFieldVariables(const FieldDescriptor* descriptor, std::map<TProtoStringType, TProtoStringType>* variables) { (*variables)["field_name"] = descriptor->name(); (*variables)["name"] = info->name; - (*variables)["classname"] = descriptor->containing_type()->name(); + (*variables)["classname"] = descriptor->containing_type()->name(); (*variables)["capitalized_name"] = info->capitalized_name; (*variables)["disambiguated_reason"] = info->disambiguated_reason; (*variables)["constant_name"] = FieldConstantName(descriptor); (*variables)["number"] = StrCat(descriptor->number()); (*variables)["kt_dsl_builder"] = "_builder"; - // These variables are placeholders to pick out the beginning and ends of - // identifiers for annotations (when doing so with existing variables would - // be ambiguous or impossible). They should never be set to anything but the - // empty string. - (*variables)["{"] = ""; - (*variables)["}"] = ""; + // These variables are placeholders to pick out the beginning and ends of + // identifiers for annotations (when doing so with existing variables would + // be ambiguous or impossible). They should never be set to anything but the + // empty string. + (*variables)["{"] = ""; + (*variables)["}"] = ""; (*variables)["kt_name"] = IsForbiddenKotlin(info->name) ? info->name + "_" : info->name; (*variables)["kt_capitalized_name"] = IsForbiddenKotlin(info->name) diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_field.h index 947be7fb1a..09384c483a 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_field.h +++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_field.h @@ -163,7 +163,7 @@ struct FieldGeneratorInfo { TProtoStringType disambiguated_reason; }; -// Oneof information used in OneofFieldGenerators. +// Oneof information used in OneofFieldGenerators. struct OneofGeneratorInfo { TProtoStringType name; TProtoStringType capitalized_name; diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_file.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_file.cc index a93754b908..0809febb8b 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_file.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_file.cc @@ -519,57 +519,57 @@ void FileGenerator::GenerateDescriptorInitializationCodeForMutable( // Try to load immutable messages' outer class. Its initialization code // will take care of interpreting custom options. printer->Print( - "try {\n" - // Note that we have to load the immutable class dynamically here as - // we want the mutable code to be independent from the immutable code - // at compile time. It is required to implement dual-compile for - // mutable and immutable API in blaze. + "try {\n" + // Note that we have to load the immutable class dynamically here as + // we want the mutable code to be independent from the immutable code + // at compile time. It is required to implement dual-compile for + // mutable and immutable API in blaze. " java.lang.Class<?> immutableClass = java.lang.Class.forName(\n" - " \"$immutable_classname$\");\n" - "} catch (java.lang.ClassNotFoundException e) {\n", - "immutable_classname", name_resolver_->GetImmutableClassName(file_)); - printer->Indent(); - - // The immutable class can not be found. We try our best to collect all - // custom option extensions to interpret the custom options. - printer->Print( - "com.google.protobuf.ExtensionRegistry registry =\n" - " com.google.protobuf.ExtensionRegistry.newInstance();\n" - "com.google.protobuf.MessageLite defaultExtensionInstance = null;\n"); - FieldDescriptorSet::iterator it; - for (it = extensions.begin(); it != extensions.end(); it++) { - const FieldDescriptor* field = *it; + " \"$immutable_classname$\");\n" + "} catch (java.lang.ClassNotFoundException e) {\n", + "immutable_classname", name_resolver_->GetImmutableClassName(file_)); + printer->Indent(); + + // The immutable class can not be found. We try our best to collect all + // custom option extensions to interpret the custom options. + printer->Print( + "com.google.protobuf.ExtensionRegistry registry =\n" + " com.google.protobuf.ExtensionRegistry.newInstance();\n" + "com.google.protobuf.MessageLite defaultExtensionInstance = null;\n"); + FieldDescriptorSet::iterator it; + for (it = extensions.begin(); it != extensions.end(); it++) { + const FieldDescriptor* field = *it; TProtoStringType scope; - if (field->extension_scope() != NULL) { - scope = name_resolver_->GetMutableClassName(field->extension_scope()) + - ".getDescriptor()"; - } else { - scope = FileJavaPackage(field->file(), true) + "." + - name_resolver_->GetDescriptorClassName(field->file()) + - ".descriptor"; - } - if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { - printer->Print( - "defaultExtensionInstance = com.google.protobuf.Internal\n" - " .getDefaultInstance(\"$class$\");\n" - "if (defaultExtensionInstance != null) {\n" - " registry.add(\n" - " $scope$.getExtensions().get($index$),\n" - " (com.google.protobuf.Message) defaultExtensionInstance);\n" - "}\n", + if (field->extension_scope() != NULL) { + scope = name_resolver_->GetMutableClassName(field->extension_scope()) + + ".getDescriptor()"; + } else { + scope = FileJavaPackage(field->file(), true) + "." + + name_resolver_->GetDescriptorClassName(field->file()) + + ".descriptor"; + } + if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { + printer->Print( + "defaultExtensionInstance = com.google.protobuf.Internal\n" + " .getDefaultInstance(\"$class$\");\n" + "if (defaultExtensionInstance != null) {\n" + " registry.add(\n" + " $scope$.getExtensions().get($index$),\n" + " (com.google.protobuf.Message) defaultExtensionInstance);\n" + "}\n", "scope", scope, "index", StrCat(field->index()), "class", - name_resolver_->GetImmutableClassName(field->message_type())); - } else { - printer->Print("registry.add($scope$.getExtensions().get($index$));\n", + name_resolver_->GetImmutableClassName(field->message_type())); + } else { + printer->Print("registry.add($scope$.getExtensions().get($index$));\n", "scope", scope, "index", StrCat(field->index())); - } - } - printer->Print( - "com.google.protobuf.Descriptors.FileDescriptor\n" - " .internalUpdateFileDescriptor(descriptor, registry);\n"); - - printer->Outdent(); - printer->Print("}\n"); + } + } + printer->Print( + "com.google.protobuf.Descriptors.FileDescriptor\n" + " .internalUpdateFileDescriptor(descriptor, registry);\n"); + + printer->Outdent(); + printer->Print("}\n"); } // Force descriptor initialization of all dependencies. diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_generator.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_generator.cc index ff428c166e..2b5728579e 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_generator.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_generator.cc @@ -46,7 +46,7 @@ #include <google/protobuf/descriptor.pb.h> #include <google/protobuf/io/printer.h> #include <google/protobuf/io/zero_copy_stream.h> - + #include <google/protobuf/stubs/strutil.h> namespace google { diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_helpers.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_helpers.cc index 81b5a3f220..a498388ade 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_helpers.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_helpers.cc @@ -271,12 +271,12 @@ TProtoStringType UniqueFileScopeIdentifier(const Descriptor* descriptor) { TProtoStringType CamelCaseFieldName(const FieldDescriptor* field) { TProtoStringType fieldName = UnderscoresToCamelCase(field); - if ('0' <= fieldName[0] && fieldName[0] <= '9') { + if ('0' <= fieldName[0] && fieldName[0] <= '9') { return '_' + fieldName; - } - return fieldName; -} - + } + return fieldName; +} + TProtoStringType FileClassName(const FileDescriptor* file, bool immutable) { ClassNameResolver name_resolver; return name_resolver.GetFileClassName(file, immutable); @@ -328,7 +328,7 @@ TProtoStringType ClassName(const FileDescriptor* descriptor) { return name_resolver.GetClassName(descriptor, true); } - + TProtoStringType ExtraMessageInterfaces(const Descriptor* descriptor) { TProtoStringType interfaces = "// @@protoc_insertion_point(message_implements:" + descriptor->full_name() + ")"; @@ -469,7 +469,7 @@ const char* BoxedPrimitiveTypeName(JavaType type) { const char* BoxedPrimitiveTypeName(const FieldDescriptor* descriptor) { return BoxedPrimitiveTypeName(GetJavaType(descriptor)); } - + const char* KotlinTypeName(JavaType type) { switch (type) { case JAVATYPE_INT: diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_helpers.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_helpers.h index 1520bbadb7..5acc729c1d 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_helpers.h +++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_helpers.h @@ -98,9 +98,9 @@ TProtoStringType UnderscoresToCamelCase(const MethodDescriptor* method); TProtoStringType UnderscoresToCamelCaseCheckReserved(const FieldDescriptor* field); // Similar to UnderscoresToCamelCase, but guarantees that the result is a -// complete Java identifier by adding a _ if needed. +// complete Java identifier by adding a _ if needed. TProtoStringType CamelCaseFieldName(const FieldDescriptor* field); - + // Get an identifier that uniquely identifies this type within the file. // This is used to declare static variables related to this type at the // outermost file scope. diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_map_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_map_field.cc index 6d7580cf79..353bff46db 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_map_field.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_map_field.cc @@ -101,12 +101,12 @@ void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex, (*variables)["key_type"] = TypeName(key, name_resolver, false); TProtoStringType boxed_key_type = TypeName(key, name_resolver, true); - (*variables)["boxed_key_type"] = boxed_key_type; + (*variables)["boxed_key_type"] = boxed_key_type; (*variables)["kt_key_type"] = KotlinTypeName(key, name_resolver); (*variables)["kt_value_type"] = KotlinTypeName(value, name_resolver); - // Used for calling the serialization function. - (*variables)["short_key_type"] = - boxed_key_type.substr(boxed_key_type.rfind('.') + 1); + // Used for calling the serialization function. + (*variables)["short_key_type"] = + boxed_key_type.substr(boxed_key_type.rfind('.') + 1); (*variables)["key_wire_type"] = WireType(key); (*variables)["key_default_value"] = DefaultValue(key, true, name_resolver); (*variables)["key_null_check"] = @@ -169,7 +169,7 @@ void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex, (*variables)["descriptor"] = name_resolver->GetImmutableClassName(descriptor->file()) + ".internal_" + UniqueFileScopeIdentifier(descriptor->message_type()) + "_descriptor, "; - (*variables)["ver"] = GeneratedCodeVersionSuffix(); + (*variables)["ver"] = GeneratedCodeVersionSuffix(); } } // namespace @@ -194,12 +194,12 @@ void ImmutableMapFieldGenerator::GenerateInterfaceMembers( WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "$deprecation$int ${$get$capitalized_name$Count$}$();\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "$deprecation$boolean ${$contains$capitalized_name$$}$(\n" " $key_type$ key);\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); if (GetJavaType(ValueField(descriptor_)) == JAVATYPE_ENUM) { printer->Print(variables_, "/**\n" @@ -208,26 +208,26 @@ void ImmutableMapFieldGenerator::GenerateInterfaceMembers( "@java.lang.Deprecated\n" "java.util.Map<$boxed_key_type$, $value_enum_type$>\n" "${$get$capitalized_name$$}$();\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "$deprecation$java.util.Map<$boxed_key_type$, $value_enum_type$>\n" - "${$get$capitalized_name$Map$}$();\n"); - printer->Annotate("{", "}", descriptor_); + "${$get$capitalized_name$Map$}$();\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, - "$deprecation$$value_enum_type$ ${$get$capitalized_name$OrDefault$}$(\n" + "$deprecation$$value_enum_type$ ${$get$capitalized_name$OrDefault$}$(\n" " $key_type$ key,\n" " $value_enum_type$ defaultValue);\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, - "$deprecation$$value_enum_type$ ${$get$capitalized_name$OrThrow$}$(\n" + "$deprecation$$value_enum_type$ ${$get$capitalized_name$OrThrow$}$(\n" " $key_type$ key);\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); if (SupportUnknownEnumValue(descriptor_->file())) { printer->Print( variables_, @@ -236,26 +236,26 @@ void ImmutableMapFieldGenerator::GenerateInterfaceMembers( " */\n" "@java.lang.Deprecated\n" "java.util.Map<$type_parameters$>\n" - "${$get$capitalized_name$Value$}$();\n"); - printer->Annotate("{", "}", descriptor_); + "${$get$capitalized_name$Value$}$();\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "$deprecation$java.util.Map<$type_parameters$>\n" "${$get$capitalized_name$ValueMap$}$();\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "$deprecation$\n" "$value_type$ ${$get$capitalized_name$ValueOrDefault$}$(\n" " $key_type$ key,\n" " $value_type$ defaultValue);\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "$deprecation$\n" "$value_type$ ${$get$capitalized_name$ValueOrThrow$}$(\n" " $key_type$ key);\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); } } else { printer->Print(variables_, @@ -265,25 +265,25 @@ void ImmutableMapFieldGenerator::GenerateInterfaceMembers( "@java.lang.Deprecated\n" "java.util.Map<$type_parameters$>\n" "${$get$capitalized_name$$}$();\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "$deprecation$java.util.Map<$type_parameters$>\n" "${$get$capitalized_name$Map$}$();\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "$deprecation$\n" "$value_type$ ${$get$capitalized_name$OrDefault$}$(\n" " $key_type$ key,\n" " $value_type$ defaultValue);\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "$deprecation$\n" "$value_type$ ${$get$capitalized_name$OrThrow$}$(\n" " $key_type$ key);\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); } } @@ -321,16 +321,16 @@ void ImmutableMapFieldGenerator::GenerateMembers(io::Printer* printer) const { " com.google.protobuf.Internal.MapAdapter.newEnumConverter(\n" " $value_enum_type$.internalGetValueMap(),\n" " $unrecognized_value$);\n"); - printer->Print( - variables_, - "private static final java.util.Map<$boxed_key_type$, " - "$value_enum_type$>\n" - "internalGetAdapted$capitalized_name$Map(\n" - " java.util.Map<$boxed_key_type$, $boxed_value_type$> map) {\n" - " return new com.google.protobuf.Internal.MapAdapter<\n" - " $boxed_key_type$, $value_enum_type$, java.lang.Integer>(\n" - " map, $name$ValueConverter);\n" - "}\n"); + printer->Print( + variables_, + "private static final java.util.Map<$boxed_key_type$, " + "$value_enum_type$>\n" + "internalGetAdapted$capitalized_name$Map(\n" + " java.util.Map<$boxed_key_type$, $boxed_value_type$> map) {\n" + " return new com.google.protobuf.Internal.MapAdapter<\n" + " $boxed_key_type$, $value_enum_type$, java.lang.Integer>(\n" + " map, $name$ValueConverter);\n" + "}\n"); } GenerateMapGetters(printer); } @@ -368,7 +368,7 @@ void ImmutableMapFieldGenerator::GenerateBuilderMembers( " .clear();\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "$deprecation$\n" @@ -379,7 +379,7 @@ void ImmutableMapFieldGenerator::GenerateBuilderMembers( " .remove(key);\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); if (GetJavaType(ValueField(descriptor_)) == JAVATYPE_ENUM) { printer->Print( variables_, @@ -388,34 +388,34 @@ void ImmutableMapFieldGenerator::GenerateBuilderMembers( " */\n" "@java.lang.Deprecated\n" "public java.util.Map<$boxed_key_type$, $value_enum_type$>\n" - "${$getMutable$capitalized_name$$}$() {\n" - " return internalGetAdapted$capitalized_name$Map(\n" - " internalGetMutable$capitalized_name$().getMutableMap());\n" + "${$getMutable$capitalized_name$$}$() {\n" + " return internalGetAdapted$capitalized_name$Map(\n" + " internalGetMutable$capitalized_name$().getMutableMap());\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, - "$deprecation$public Builder ${$put$capitalized_name$$}$(\n" - " $key_type$ key,\n" - " $value_enum_type$ value) {\n" - " $key_null_check$\n" - " $value_null_check$\n" - " internalGetMutable$capitalized_name$().getMutableMap()\n" - " .put(key, $name$ValueConverter.doBackward(value));\n" - " return this;\n" - "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Print(variables_, + "$deprecation$public Builder ${$put$capitalized_name$$}$(\n" + " $key_type$ key,\n" + " $value_enum_type$ value) {\n" + " $key_null_check$\n" + " $value_null_check$\n" + " internalGetMutable$capitalized_name$().getMutableMap()\n" + " .put(key, $name$ValueConverter.doBackward(value));\n" + " return this;\n" + "}\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, - "$deprecation$public Builder ${$putAll$capitalized_name$$}$(\n" + "$deprecation$public Builder ${$putAll$capitalized_name$$}$(\n" " java.util.Map<$boxed_key_type$, $value_enum_type$> values) {\n" - " internalGetAdapted$capitalized_name$Map(\n" - " internalGetMutable$capitalized_name$().getMutableMap())\n" - " .putAll(values);\n" + " internalGetAdapted$capitalized_name$Map(\n" + " internalGetMutable$capitalized_name$().getMutableMap())\n" + " .putAll(values);\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); if (SupportUnknownEnumValue(descriptor_->file())) { printer->Print( variables_, @@ -424,32 +424,32 @@ void ImmutableMapFieldGenerator::GenerateBuilderMembers( " */\n" "@java.lang.Deprecated\n" "public java.util.Map<$boxed_key_type$, $boxed_value_type$>\n" - "${$getMutable$capitalized_name$Value$}$() {\n" + "${$getMutable$capitalized_name$Value$}$() {\n" " return internalGetMutable$capitalized_name$().getMutableMap();\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, - "$deprecation$public Builder ${$put$capitalized_name$Value$}$(\n" + "$deprecation$public Builder ${$put$capitalized_name$Value$}$(\n" " $key_type$ key,\n" " $value_type$ value) {\n" " $key_null_check$\n" - " internalGetMutable$capitalized_name$().getMutableMap()\n" - " .put(key, value);\n" + " internalGetMutable$capitalized_name$().getMutableMap()\n" + " .put(key, value);\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, - "$deprecation$public Builder ${$putAll$capitalized_name$Value$}$(\n" + "$deprecation$public Builder ${$putAll$capitalized_name$Value$}$(\n" " java.util.Map<$boxed_key_type$, $boxed_value_type$> values) {\n" - " internalGetMutable$capitalized_name$().getMutableMap()\n" - " .putAll(values);\n" + " internalGetMutable$capitalized_name$().getMutableMap()\n" + " .putAll(values);\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); } } else { printer->Print( @@ -459,10 +459,10 @@ void ImmutableMapFieldGenerator::GenerateBuilderMembers( " */\n" "@java.lang.Deprecated\n" "public java.util.Map<$type_parameters$>\n" - "${$getMutable$capitalized_name$$}$() {\n" + "${$getMutable$capitalized_name$$}$() {\n" " return internalGetMutable$capitalized_name$().getMutableMap();\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "$deprecation$" @@ -475,7 +475,7 @@ void ImmutableMapFieldGenerator::GenerateBuilderMembers( " .put(key, value);\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "$deprecation$\n" @@ -485,7 +485,7 @@ void ImmutableMapFieldGenerator::GenerateBuilderMembers( " .putAll(values);\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); } } @@ -496,18 +496,18 @@ void ImmutableMapFieldGenerator::GenerateMapGetters( "public int ${$get$capitalized_name$Count$}$() {\n" " return internalGet$capitalized_name$().getMap().size();\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "$deprecation$\n" "@java.lang.Override\n" - "public boolean ${$contains$capitalized_name$$}$(\n" + "public boolean ${$contains$capitalized_name$$}$(\n" " $key_type$ key) {\n" " $key_null_check$\n" " return internalGet$capitalized_name$().getMap().containsKey(key);\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); if (GetJavaType(ValueField(descriptor_)) == JAVATYPE_ENUM) { printer->Print(variables_, "/**\n" @@ -519,7 +519,7 @@ void ImmutableMapFieldGenerator::GenerateMapGetters( "${$get$capitalized_name$$}$() {\n" " return get$capitalized_name$Map();\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "@java.lang.Override\n" @@ -529,13 +529,13 @@ void ImmutableMapFieldGenerator::GenerateMapGetters( " return internalGetAdapted$capitalized_name$Map(\n" " internalGet$capitalized_name$().getMap());" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "@java.lang.Override\n" "$deprecation$\n" - "public $value_enum_type$ ${$get$capitalized_name$OrDefault$}$(\n" + "public $value_enum_type$ ${$get$capitalized_name$OrDefault$}$(\n" " $key_type$ key,\n" " $value_enum_type$ defaultValue) {\n" " $key_null_check$\n" @@ -545,13 +545,13 @@ void ImmutableMapFieldGenerator::GenerateMapGetters( " ? $name$ValueConverter.doForward(map.get(key))\n" " : defaultValue;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "@java.lang.Override\n" "$deprecation$\n" - "public $value_enum_type$ ${$get$capitalized_name$OrThrow$}$(\n" + "public $value_enum_type$ ${$get$capitalized_name$OrThrow$}$(\n" " $key_type$ key) {\n" " $key_null_check$\n" " java.util.Map<$boxed_key_type$, $boxed_value_type$> map =\n" @@ -561,7 +561,7 @@ void ImmutableMapFieldGenerator::GenerateMapGetters( " }\n" " return $name$ValueConverter.doForward(map.get(key));\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); if (SupportUnknownEnumValue(descriptor_->file())) { printer->Print( variables_, @@ -571,26 +571,26 @@ void ImmutableMapFieldGenerator::GenerateMapGetters( "@java.lang.Override\n" "@java.lang.Deprecated\n" "public java.util.Map<$boxed_key_type$, $boxed_value_type$>\n" - "${$get$capitalized_name$Value$}$() {\n" + "${$get$capitalized_name$Value$}$() {\n" " return get$capitalized_name$ValueMap();\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "@java.lang.Override\n" "$deprecation$\n" "public java.util.Map<$boxed_key_type$, $boxed_value_type$>\n" - "${$get$capitalized_name$ValueMap$}$() {\n" + "${$get$capitalized_name$ValueMap$}$() {\n" " return internalGet$capitalized_name$().getMap();\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "@java.lang.Override\n" "$deprecation$\n" - "public $value_type$ ${$get$capitalized_name$ValueOrDefault$}$(\n" + "public $value_type$ ${$get$capitalized_name$ValueOrDefault$}$(\n" " $key_type$ key,\n" " $value_type$ defaultValue) {\n" " $key_null_check$\n" @@ -598,13 +598,13 @@ void ImmutableMapFieldGenerator::GenerateMapGetters( " internalGet$capitalized_name$().getMap();\n" " return map.containsKey(key) ? map.get(key) : defaultValue;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "@java.lang.Override\n" "$deprecation$\n" - "public $value_type$ ${$get$capitalized_name$ValueOrThrow$}$(\n" + "public $value_type$ ${$get$capitalized_name$ValueOrThrow$}$(\n" " $key_type$ key) {\n" " $key_null_check$\n" " java.util.Map<$boxed_key_type$, $boxed_value_type$> map =\n" @@ -614,7 +614,7 @@ void ImmutableMapFieldGenerator::GenerateMapGetters( " }\n" " return map.get(key);\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); } } else { printer->Print(variables_, @@ -627,7 +627,7 @@ void ImmutableMapFieldGenerator::GenerateMapGetters( "${$get$capitalized_name$$}$() {\n" " return get$capitalized_name$Map();\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "@java.lang.Override\n" @@ -636,13 +636,13 @@ void ImmutableMapFieldGenerator::GenerateMapGetters( "${$get$capitalized_name$Map$}$() {\n" " return internalGet$capitalized_name$().getMap();\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "@java.lang.Override\n" "$deprecation$\n" - "public $value_type$ ${$get$capitalized_name$OrDefault$}$(\n" + "public $value_type$ ${$get$capitalized_name$OrDefault$}$(\n" " $key_type$ key,\n" " $value_type$ defaultValue) {\n" " $key_null_check$\n" @@ -650,7 +650,7 @@ void ImmutableMapFieldGenerator::GenerateMapGetters( " internalGet$capitalized_name$().getMap();\n" " return map.containsKey(key) ? map.get(key) : defaultValue;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "@java.lang.Override\n" @@ -665,7 +665,7 @@ void ImmutableMapFieldGenerator::GenerateMapGetters( " }\n" " return map.get(key);\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); } } @@ -794,23 +794,23 @@ void ImmutableMapFieldGenerator::GenerateParsingCode( variables_, "com.google.protobuf.ByteString bytes = input.readBytes();\n" "com.google.protobuf.MapEntry<$type_parameters$>\n" - "$name$__ = $default_entry$.getParserForType().parseFrom(bytes);\n"); + "$name$__ = $default_entry$.getParserForType().parseFrom(bytes);\n"); printer->Print( variables_, - "if ($value_enum_type$.forNumber($name$__.getValue()) == null) {\n" + "if ($value_enum_type$.forNumber($name$__.getValue()) == null) {\n" " unknownFields.mergeLengthDelimitedField($number$, bytes);\n" "} else {\n" - " $name$_.getMutableMap().put(\n" - " $name$__.getKey(), $name$__.getValue());\n" + " $name$_.getMutableMap().put(\n" + " $name$__.getKey(), $name$__.getValue());\n" "}\n"); } else { printer->Print( variables_, "com.google.protobuf.MapEntry<$type_parameters$>\n" - "$name$__ = input.readMessage(\n" + "$name$__ = input.readMessage(\n" " $default_entry$.getParserForType(), extensionRegistry);\n" - "$name$_.getMutableMap().put(\n" - " $name$__.getKey(), $name$__.getValue());\n"); + "$name$_.getMutableMap().put(\n" + " $name$__.getKey(), $name$__.getValue());\n"); } } @@ -837,12 +837,12 @@ void ImmutableMapFieldGenerator::GenerateSerializedSizeCode( "for (java.util.Map.Entry<$type_parameters$> entry\n" " : internalGet$capitalized_name$().getMap().entrySet()) {\n" " com.google.protobuf.MapEntry<$type_parameters$>\n" - " $name$__ = $default_entry$.newBuilderForType()\n" + " $name$__ = $default_entry$.newBuilderForType()\n" " .setKey(entry.getKey())\n" " .setValue(entry.getValue())\n" " .build();\n" " size += com.google.protobuf.CodedOutputStream\n" - " .computeMessageSize($number$, $name$__);\n" + " .computeMessageSize($number$, $name$__);\n" "}\n"); } diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_map_field_lite.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_map_field_lite.cc index 716c910954..79bd924701 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_map_field_lite.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_map_field_lite.cc @@ -181,12 +181,12 @@ void ImmutableMapFieldLiteGenerator::GenerateInterfaceMembers( WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "$deprecation$int ${$get$capitalized_name$Count$}$();\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "$deprecation$boolean ${$contains$capitalized_name$$}$(\n" " $key_type$ key);\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); if (GetJavaType(ValueField(descriptor_)) == JAVATYPE_ENUM) { printer->Print(variables_, "/**\n" @@ -195,26 +195,26 @@ void ImmutableMapFieldLiteGenerator::GenerateInterfaceMembers( "@java.lang.Deprecated\n" "java.util.Map<$boxed_key_type$, $value_enum_type$>\n" "${$get$capitalized_name$$}$();\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "$deprecation$java.util.Map<$boxed_key_type$, $value_enum_type$>\n" - "${$get$capitalized_name$Map$}$();\n"); - printer->Annotate("{", "}", descriptor_); + "${$get$capitalized_name$Map$}$();\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, - "$deprecation$$value_enum_type$ ${$get$capitalized_name$OrDefault$}$(\n" + "$deprecation$$value_enum_type$ ${$get$capitalized_name$OrDefault$}$(\n" " $key_type$ key,\n" " $value_enum_type$ defaultValue);\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, - "$deprecation$$value_enum_type$ ${$get$capitalized_name$OrThrow$}$(\n" + "$deprecation$$value_enum_type$ ${$get$capitalized_name$OrThrow$}$(\n" " $key_type$ key);\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); if (SupportUnknownEnumValue(descriptor_->file())) { printer->Print( variables_, @@ -223,26 +223,26 @@ void ImmutableMapFieldLiteGenerator::GenerateInterfaceMembers( " */\n" "@java.lang.Deprecated\n" "java.util.Map<$type_parameters$>\n" - "${$get$capitalized_name$Value$}$();\n"); - printer->Annotate("{", "}", descriptor_); + "${$get$capitalized_name$Value$}$();\n"); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "$deprecation$java.util.Map<$type_parameters$>\n" "${$get$capitalized_name$ValueMap$}$();\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "$deprecation$\n" "$value_type$ ${$get$capitalized_name$ValueOrDefault$}$(\n" " $key_type$ key,\n" " $value_type$ defaultValue);\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "$deprecation$\n" "$value_type$ ${$get$capitalized_name$ValueOrThrow$}$(\n" " $key_type$ key);\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); } } else { printer->Print(variables_, @@ -252,25 +252,25 @@ void ImmutableMapFieldLiteGenerator::GenerateInterfaceMembers( "@java.lang.Deprecated\n" "java.util.Map<$type_parameters$>\n" "${$get$capitalized_name$$}$();\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "$deprecation$java.util.Map<$type_parameters$>\n" "${$get$capitalized_name$Map$}$();\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "$deprecation$\n" "$value_type$ ${$get$capitalized_name$OrDefault$}$(\n" " $key_type$ key,\n" " $value_type$ defaultValue);\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "$deprecation$\n" "$value_type$ ${$get$capitalized_name$OrThrow$}$(\n" " $key_type$ key);\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); } } @@ -309,7 +309,7 @@ void ImmutableMapFieldLiteGenerator::GenerateMembers( "public int ${$get$capitalized_name$Count$}$() {\n" " return internalGet$capitalized_name$().size();\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "@java.lang.Override\n" @@ -319,7 +319,7 @@ void ImmutableMapFieldLiteGenerator::GenerateMembers( " $key_null_check$\n" " return internalGet$capitalized_name$().containsKey(key);\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); if (GetJavaType(ValueField(descriptor_)) == JAVATYPE_ENUM) { printer->Print( variables_, @@ -338,27 +338,27 @@ void ImmutableMapFieldLiteGenerator::GenerateMembers( "${$get$capitalized_name$$}$() {\n" " return get$capitalized_name$Map();\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "@java.lang.Override\n" "$deprecation$\n" "public java.util.Map<$boxed_key_type$, $value_enum_type$>\n" - "${$get$capitalized_name$Map$}$() {\n" + "${$get$capitalized_name$Map$}$() {\n" " return java.util.Collections.unmodifiableMap(\n" " new com.google.protobuf.Internal.MapAdapter<\n" " $boxed_key_type$, $value_enum_type$, java.lang.Integer>(\n" " internalGet$capitalized_name$(),\n" " $name$ValueConverter));\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "@java.lang.Override\n" "$deprecation$\n" - "public $value_enum_type$ ${$get$capitalized_name$OrDefault$}$(\n" + "public $value_enum_type$ ${$get$capitalized_name$OrDefault$}$(\n" " $key_type$ key,\n" " $value_enum_type$ defaultValue) {\n" " $key_null_check$\n" @@ -368,13 +368,13 @@ void ImmutableMapFieldLiteGenerator::GenerateMembers( " ? $name$ValueConverter.doForward(map.get(key))\n" " : defaultValue;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "@java.lang.Override\n" "$deprecation$\n" - "public $value_enum_type$ ${$get$capitalized_name$OrThrow$}$(\n" + "public $value_enum_type$ ${$get$capitalized_name$OrThrow$}$(\n" " $key_type$ key) {\n" " $key_null_check$\n" " java.util.Map<$boxed_key_type$, $boxed_value_type$> map =\n" @@ -384,7 +384,7 @@ void ImmutableMapFieldLiteGenerator::GenerateMembers( " }\n" " return $name$ValueConverter.doForward(map.get(key));\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); if (SupportUnknownEnumValue(descriptor_->file())) { printer->Print( variables_, @@ -394,27 +394,27 @@ void ImmutableMapFieldLiteGenerator::GenerateMembers( "@java.lang.Override\n" "@java.lang.Deprecated\n" "public java.util.Map<$boxed_key_type$, $boxed_value_type$>\n" - "${$get$capitalized_name$Value$}$() {\n" + "${$get$capitalized_name$Value$}$() {\n" " return get$capitalized_name$ValueMap();\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "@java.lang.Override\n" "$deprecation$\n" "public java.util.Map<$boxed_key_type$, $boxed_value_type$>\n" - "${$get$capitalized_name$ValueMap$}$() {\n" + "${$get$capitalized_name$ValueMap$}$() {\n" " return java.util.Collections.unmodifiableMap(\n" " internalGet$capitalized_name$());\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "@java.lang.Override\n" "$deprecation$\n" - "public $value_type$ ${$get$capitalized_name$ValueOrDefault$}$(\n" + "public $value_type$ ${$get$capitalized_name$ValueOrDefault$}$(\n" " $key_type$ key,\n" " $value_type$ defaultValue) {\n" " $key_null_check$\n" @@ -422,13 +422,13 @@ void ImmutableMapFieldLiteGenerator::GenerateMembers( " internalGet$capitalized_name$();\n" " return map.containsKey(key) ? map.get(key) : defaultValue;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "@java.lang.Override\n" "$deprecation$\n" - "public $value_type$ ${$get$capitalized_name$ValueOrThrow$}$(\n" + "public $value_type$ ${$get$capitalized_name$ValueOrThrow$}$(\n" " $key_type$ key) {\n" " $key_null_check$\n" " java.util.Map<$boxed_key_type$, $boxed_value_type$> map =\n" @@ -438,7 +438,7 @@ void ImmutableMapFieldLiteGenerator::GenerateMembers( " }\n" " return map.get(key);\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); } } else { printer->Print(variables_, @@ -451,7 +451,7 @@ void ImmutableMapFieldLiteGenerator::GenerateMembers( "${$get$capitalized_name$$}$() {\n" " return get$capitalized_name$Map();\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "@java.lang.Override\n" @@ -461,13 +461,13 @@ void ImmutableMapFieldLiteGenerator::GenerateMembers( " return java.util.Collections.unmodifiableMap(\n" " internalGet$capitalized_name$());\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "@java.lang.Override\n" "$deprecation$\n" - "public $value_type$ ${$get$capitalized_name$OrDefault$}$(\n" + "public $value_type$ ${$get$capitalized_name$OrDefault$}$(\n" " $key_type$ key,\n" " $value_type$ defaultValue) {\n" " $key_null_check$\n" @@ -475,7 +475,7 @@ void ImmutableMapFieldLiteGenerator::GenerateMembers( " internalGet$capitalized_name$();\n" " return map.containsKey(key) ? map.get(key) : defaultValue;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "@java.lang.Override\n" @@ -490,7 +490,7 @@ void ImmutableMapFieldLiteGenerator::GenerateMembers( " }\n" " return map.get(key);\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); } // Generate private setters for the builder to proxy into. @@ -540,7 +540,7 @@ void ImmutableMapFieldLiteGenerator::GenerateFieldInfo( /*enforce_lite=*/context_->EnforceLite()); } } - + void ImmutableMapFieldLiteGenerator::GenerateBuilderMembers( io::Printer* printer) const { printer->Print(variables_, @@ -549,18 +549,18 @@ void ImmutableMapFieldLiteGenerator::GenerateBuilderMembers( "public int ${$get$capitalized_name$Count$}$() {\n" " return instance.get$capitalized_name$Map().size();\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "@java.lang.Override\n" "$deprecation$\n" - "public boolean ${$contains$capitalized_name$$}$(\n" + "public boolean ${$contains$capitalized_name$$}$(\n" " $key_type$ key) {\n" " $key_null_check$\n" " return instance.get$capitalized_name$Map().containsKey(key);\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); printer->Print(variables_, "$deprecation$\n" "public Builder ${$clear$capitalized_name$$}$() {\n" @@ -568,7 +568,7 @@ void ImmutableMapFieldLiteGenerator::GenerateBuilderMembers( " instance.getMutable$capitalized_name$Map().clear();\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "$deprecation$\n" @@ -579,7 +579,7 @@ void ImmutableMapFieldLiteGenerator::GenerateBuilderMembers( " instance.getMutable$capitalized_name$Map().remove(key);\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); if (GetJavaType(ValueField(descriptor_)) == JAVATYPE_ENUM) { printer->Print(variables_, "/**\n" @@ -590,7 +590,7 @@ void ImmutableMapFieldLiteGenerator::GenerateBuilderMembers( "${$get$capitalized_name$$}$() {\n" " return get$capitalized_name$Map();\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "@java.lang.Override\n" @@ -600,13 +600,13 @@ void ImmutableMapFieldLiteGenerator::GenerateBuilderMembers( " return java.util.Collections.unmodifiableMap(\n" " instance.get$capitalized_name$Map());\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "@java.lang.Override\n" "$deprecation$\n" - "public $value_enum_type$ ${$get$capitalized_name$OrDefault$}$(\n" + "public $value_enum_type$ ${$get$capitalized_name$OrDefault$}$(\n" " $key_type$ key,\n" " $value_enum_type$ defaultValue) {\n" " $key_null_check$\n" @@ -616,13 +616,13 @@ void ImmutableMapFieldLiteGenerator::GenerateBuilderMembers( " ? map.get(key)\n" " : defaultValue;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "@java.lang.Override\n" "$deprecation$\n" - "public $value_enum_type$ ${$get$capitalized_name$OrThrow$}$(\n" + "public $value_enum_type$ ${$get$capitalized_name$OrThrow$}$(\n" " $key_type$ key) {\n" " $key_null_check$\n" " java.util.Map<$boxed_key_type$, $value_enum_type$> map =\n" @@ -632,11 +632,11 @@ void ImmutableMapFieldLiteGenerator::GenerateBuilderMembers( " }\n" " return map.get(key);\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, - "$deprecation$public Builder ${$put$capitalized_name$$}$(\n" + "$deprecation$public Builder ${$put$capitalized_name$$}$(\n" " $key_type$ key,\n" " $value_enum_type$ value) {\n" " $key_null_check$\n" @@ -645,17 +645,17 @@ void ImmutableMapFieldLiteGenerator::GenerateBuilderMembers( " instance.getMutable$capitalized_name$Map().put(key, value);\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, - "$deprecation$public Builder ${$putAll$capitalized_name$$}$(\n" + "$deprecation$public Builder ${$putAll$capitalized_name$$}$(\n" " java.util.Map<$boxed_key_type$, $value_enum_type$> values) {\n" " copyOnWrite();\n" " instance.getMutable$capitalized_name$Map().putAll(values);\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); if (SupportUnknownEnumValue(descriptor_->file())) { printer->Print( variables_, @@ -665,27 +665,27 @@ void ImmutableMapFieldLiteGenerator::GenerateBuilderMembers( "@java.lang.Override\n" "@java.lang.Deprecated\n" "public java.util.Map<$boxed_key_type$, $boxed_value_type$>\n" - "${$get$capitalized_name$Value$}$() {\n" + "${$get$capitalized_name$Value$}$() {\n" " return get$capitalized_name$ValueMap();\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "@java.lang.Override\n" "$deprecation$\n" "public java.util.Map<$boxed_key_type$, $boxed_value_type$>\n" - "${$get$capitalized_name$ValueMap$}$() {\n" + "${$get$capitalized_name$ValueMap$}$() {\n" " return java.util.Collections.unmodifiableMap(\n" " instance.get$capitalized_name$ValueMap());\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "@java.lang.Override\n" "$deprecation$\n" - "public $value_type$ ${$get$capitalized_name$ValueOrDefault$}$(\n" + "public $value_type$ ${$get$capitalized_name$ValueOrDefault$}$(\n" " $key_type$ key,\n" " $value_type$ defaultValue) {\n" " $key_null_check$\n" @@ -693,13 +693,13 @@ void ImmutableMapFieldLiteGenerator::GenerateBuilderMembers( " instance.get$capitalized_name$ValueMap();\n" " return map.containsKey(key) ? map.get(key) : defaultValue;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "@java.lang.Override\n" "$deprecation$\n" - "public $value_type$ ${$get$capitalized_name$ValueOrThrow$}$(\n" + "public $value_type$ ${$get$capitalized_name$ValueOrThrow$}$(\n" " $key_type$ key) {\n" " $key_null_check$\n" " java.util.Map<$boxed_key_type$, $boxed_value_type$> map =\n" @@ -709,11 +709,11 @@ void ImmutableMapFieldLiteGenerator::GenerateBuilderMembers( " }\n" " return map.get(key);\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, - "$deprecation$public Builder ${$put$capitalized_name$Value$}$(\n" + "$deprecation$public Builder ${$put$capitalized_name$Value$}$(\n" " $key_type$ key,\n" " $value_type$ value) {\n" " $key_null_check$\n" @@ -721,17 +721,17 @@ void ImmutableMapFieldLiteGenerator::GenerateBuilderMembers( " instance.getMutable$capitalized_name$ValueMap().put(key, value);\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, - "$deprecation$public Builder ${$putAll$capitalized_name$Value$}$(\n" + "$deprecation$public Builder ${$putAll$capitalized_name$Value$}$(\n" " java.util.Map<$boxed_key_type$, $boxed_value_type$> values) {\n" " copyOnWrite();\n" " instance.getMutable$capitalized_name$ValueMap().putAll(values);\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); } } else { printer->Print(variables_, @@ -744,7 +744,7 @@ void ImmutableMapFieldLiteGenerator::GenerateBuilderMembers( "${$get$capitalized_name$$}$() {\n" " return get$capitalized_name$Map();\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "@java.lang.Override\n" @@ -754,13 +754,13 @@ void ImmutableMapFieldLiteGenerator::GenerateBuilderMembers( " return java.util.Collections.unmodifiableMap(\n" " instance.get$capitalized_name$Map());\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "@java.lang.Override\n" "$deprecation$\n" - "public $value_type$ ${$get$capitalized_name$OrDefault$}$(\n" + "public $value_type$ ${$get$capitalized_name$OrDefault$}$(\n" " $key_type$ key,\n" " $value_type$ defaultValue) {\n" " $key_null_check$\n" @@ -768,7 +768,7 @@ void ImmutableMapFieldLiteGenerator::GenerateBuilderMembers( " instance.get$capitalized_name$Map();\n" " return map.containsKey(key) ? map.get(key) : defaultValue;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "@java.lang.Override\n" @@ -783,12 +783,12 @@ void ImmutableMapFieldLiteGenerator::GenerateBuilderMembers( " }\n" " return map.get(key);\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "$deprecation$" - "public Builder ${$put$capitalized_name$$}$(\n" + "public Builder ${$put$capitalized_name$$}$(\n" " $key_type$ key,\n" " $value_type$ value) {\n" " $key_null_check$\n" @@ -797,18 +797,18 @@ void ImmutableMapFieldLiteGenerator::GenerateBuilderMembers( " instance.getMutable$capitalized_name$Map().put(key, value);\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, "$deprecation$" - "public Builder ${$putAll$capitalized_name$$}$(\n" + "public Builder ${$putAll$capitalized_name$$}$(\n" " java.util.Map<$type_parameters$> values) {\n" " copyOnWrite();\n" " instance.getMutable$capitalized_name$Map().putAll(values);\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); } } diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_map_field_lite.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_map_field_lite.h index 99a3eb8a16..f2773f5b35 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_map_field_lite.h +++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_map_field_lite.h @@ -58,7 +58,7 @@ class ImmutableMapFieldLiteGenerator : public ImmutableFieldLiteGenerator { void GenerateKotlinDslMembers(io::Printer* printer) const override; TProtoStringType GetBoxedType() const override; - + private: const FieldDescriptor* descriptor_; std::map<TProtoStringType, TProtoStringType> variables_; diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message.cc index f3e814554e..029d886cde 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message.cc @@ -259,7 +259,7 @@ void ImmutableMessageGenerator::GenerateInterface(io::Printer* printer) { /* immutable = */ true, "OrBuilder"); if (descriptor_->extension_range_count() > 0) { printer->Print( - "$deprecation$public interface ${$$classname$OrBuilder$}$ extends\n" + "$deprecation$public interface ${$$classname$OrBuilder$}$ extends\n" " $extra_interfaces$\n" " com.google.protobuf.GeneratedMessage$ver$.\n" " ExtendableMessageOrBuilder<$classname$> {\n", @@ -270,7 +270,7 @@ void ImmutableMessageGenerator::GenerateInterface(io::Printer* printer) { GeneratedCodeVersionSuffix()); } else { printer->Print( - "$deprecation$public interface ${$$classname$OrBuilder$}$ extends\n" + "$deprecation$public interface ${$$classname$OrBuilder$}$ extends\n" " $extra_interfaces$\n" " com.google.protobuf.MessageOrBuilder {\n", "deprecation", @@ -278,7 +278,7 @@ void ImmutableMessageGenerator::GenerateInterface(io::Printer* printer) { "extra_interfaces", ExtraMessageOrBuilderInterfaces(descriptor_), "classname", descriptor_->name(), "{", "", "}", ""); } - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); printer->Indent(); for (int i = 0; i < descriptor_->field_count(); i++) { @@ -320,9 +320,9 @@ void ImmutableMessageGenerator::Generate(io::Printer* printer) { // The builder_type stores the super type name of the nested Builder class. TProtoStringType builder_type; if (descriptor_->extension_range_count() > 0) { - printer->Print( - variables, - "$deprecation$public $static$final class $classname$ extends\n"); + printer->Print( + variables, + "$deprecation$public $static$final class $classname$ extends\n"); printer->Annotate("classname", descriptor_); printer->Print( variables, @@ -335,9 +335,9 @@ void ImmutableMessageGenerator::Generate(io::Printer* printer) { name_resolver_->GetImmutableClassName(descriptor_), GeneratedCodeVersionSuffix()); } else { - printer->Print( - variables, - "$deprecation$public $static$final class $classname$ extends\n"); + printer->Print( + variables, + "$deprecation$public $static$final class $classname$ extends\n"); printer->Annotate("classname", descriptor_); printer->Print(variables, " com.google.protobuf.GeneratedMessage$ver$ implements\n" @@ -348,7 +348,7 @@ void ImmutableMessageGenerator::Generate(io::Printer* printer) { GeneratedCodeVersionSuffix()); } printer->Print("private static final long serialVersionUID = 0L;\n"); - + printer->Indent(); // Using builder_type, instead of Builder, prevents the Builder class from // being loaded into PermGen space when the default instance is created. @@ -635,9 +635,9 @@ void ImmutableMessageGenerator::GenerateMessageSerializationMethods( } } - if (descriptor_->options().message_set_wire_format()) { + if (descriptor_->options().message_set_wire_format()) { printer->Print("unknownFields.writeAsMessageSetTo(output);\n"); - } else { + } else { printer->Print("unknownFields.writeTo(output);\n"); } @@ -666,9 +666,9 @@ void ImmutableMessageGenerator::GenerateMessageSerializationMethods( } } - if (descriptor_->options().message_set_wire_format()) { + if (descriptor_->options().message_set_wire_format()) { printer->Print("size += unknownFields.getSerializedSizeAsMessageSet();\n"); - } else { + } else { printer->Print("size += unknownFields.getSerializedSize();\n"); } @@ -1062,10 +1062,10 @@ void ImmutableMessageGenerator::GenerateEqualsAndHashCode( printer->Print("}\n"); } - // Always consider unknown fields for equality. This will sometimes return - // false for non-canonical ordering when running in LITE_RUNTIME but it's - // the best we can do. - printer->Print( + // Always consider unknown fields for equality. This will sometimes return + // false for non-canonical ordering when running in LITE_RUNTIME but it's + // the best we can do. + printer->Print( "if (!unknownFields.equals(other.unknownFields)) return false;\n"); if (descriptor_->extension_range_count() > 0) { printer->Print( @@ -1090,12 +1090,12 @@ void ImmutableMessageGenerator::GenerateEqualsAndHashCode( "}\n" "int hash = 41;\n"); - // If we output a getDescriptor() method, use that as it is more efficient. - if (descriptor_->options().no_standard_descriptor_accessor()) { - printer->Print("hash = (19 * hash) + getDescriptorForType().hashCode();\n"); - } else { - printer->Print("hash = (19 * hash) + getDescriptor().hashCode();\n"); - } + // If we output a getDescriptor() method, use that as it is more efficient. + if (descriptor_->options().no_standard_descriptor_accessor()) { + printer->Print("hash = (19 * hash) + getDescriptorForType().hashCode();\n"); + } else { + printer->Print("hash = (19 * hash) + getDescriptor().hashCode();\n"); + } // hashCode non-oneofs. for (int i = 0; i < descriptor_->field_count(); i++) { @@ -1199,7 +1199,7 @@ void ImmutableMessageGenerator::GenerateParsingConstructor( GetBitFieldName(i)); } - printer->Print( + printer->Print( "com.google.protobuf.UnknownFieldSet.Builder unknownFields =\n" " com.google.protobuf.UnknownFieldSet.newBuilder();\n"); @@ -1286,8 +1286,8 @@ void ImmutableMessageGenerator::GenerateParsingConstructor( field_generators_.get(field).GenerateParsingDoneCode(printer); } - // Make unknown fields immutable. - printer->Print("this.unknownFields = unknownFields.build();\n"); + // Make unknown fields immutable. + printer->Print("this.unknownFields = unknownFields.build();\n"); // Make extensions immutable. printer->Print("makeExtensionsImmutable();\n"); diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_builder.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_builder.cc index 32e9701509..510b9d785c 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_builder.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_builder.cc @@ -170,7 +170,7 @@ void MessageBuilderGenerator::Generate(io::Printer* printer) { // is needed to keep binary compatibility when we change generated code // to subclass a different GeneratedMessage class (e.g., in v3.0.0 release // we changed all generated code to subclass GeneratedMessageV3). - printer->Print( + printer->Print( "@java.lang.Override\n" "public final Builder setUnknownFields(\n" " final com.google.protobuf.UnknownFieldSet unknownFields) {\n" @@ -440,11 +440,11 @@ void MessageBuilderGenerator::GenerateCommonBuilderMethods( "\n", "classname", name_resolver_->GetImmutableClassName(descriptor_)); - // Override methods declared in GeneratedMessage to return the concrete - // generated type so callsites won't depend on GeneratedMessage. This - // is needed to keep binary compatibility when we change generated code - // to subclass a different GeneratedMessage class (e.g., in v3.0.0 release - // we changed all generated code to subclass GeneratedMessageV3). + // Override methods declared in GeneratedMessage to return the concrete + // generated type so callsites won't depend on GeneratedMessage. This + // is needed to keep binary compatibility when we change generated code + // to subclass a different GeneratedMessage class (e.g., in v3.0.0 release + // we changed all generated code to subclass GeneratedMessageV3). printer->Print( "@java.lang.Override\n" "public Builder clone() {\n" diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field.cc index 44e88b8cc7..6e2f181387 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field.cc @@ -175,7 +175,7 @@ void ImmutableMessageFieldGenerator::GenerateMembers( "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return $get_has_field_bit_message$;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, GETTER); printer->Print( variables_, @@ -183,7 +183,7 @@ void ImmutableMessageFieldGenerator::GenerateMembers( "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n" " return $name$_ == null ? $type$.getDefaultInstance() : $name$_;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( @@ -193,7 +193,7 @@ void ImmutableMessageFieldGenerator::GenerateMembers( "${$get$capitalized_name$OrBuilder$}$() {\n" " return $name$_ == null ? $type$.getDefaultInstance() : $name$_;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); } else { WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); printer->Print( @@ -202,7 +202,7 @@ void ImmutableMessageFieldGenerator::GenerateMembers( "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return $name$_ != null;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, GETTER); printer->Print( variables_, @@ -210,7 +210,7 @@ void ImmutableMessageFieldGenerator::GenerateMembers( "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n" " return $name$_ == null ? $type$.getDefaultInstance() : $name$_;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, @@ -219,7 +219,7 @@ void ImmutableMessageFieldGenerator::GenerateMembers( "${$get$capitalized_name$OrBuilder$}$() {\n" " return get$capitalized_name$();\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); } } @@ -242,7 +242,7 @@ void ImmutableMessageFieldGenerator::PrintNestedBuilderFunction( const char* regular_case, const char* nested_builder_case, const char* trailing_code) const { printer->Print(variables_, method_prototype); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); printer->Print(" {\n"); printer->Indent(); PrintNestedBuilderCondition(printer, regular_case, nested_builder_case); @@ -281,14 +281,14 @@ void ImmutableMessageFieldGenerator::GenerateBuilderMembers( "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return $get_has_field_bit_builder$;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); } else { printer->Print( variables_, "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return $name$Builder_ != null || $name$_ != null;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); } // Field getField() @@ -382,7 +382,7 @@ void ImmutableMessageFieldGenerator::GenerateBuilderMembers( " $on_changed$\n" " return get$capitalized_name$FieldBuilder().getBuilder();\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "$deprecation$public $type$OrBuilder " @@ -394,7 +394,7 @@ void ImmutableMessageFieldGenerator::GenerateBuilderMembers( " $type$.getDefaultInstance() : $name$_;\n" " }\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, @@ -580,9 +580,9 @@ void ImmutableMessageOneofFieldGenerator::GenerateMembers( "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return $has_oneof_case_message$;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, GETTER); - printer->Print(variables_, + printer->Print(variables_, "@java.lang.Override\n" "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n" " if ($has_oneof_case_message$) {\n" @@ -590,7 +590,7 @@ void ImmutableMessageOneofFieldGenerator::GenerateMembers( " }\n" " return $type$.getDefaultInstance();\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, @@ -602,7 +602,7 @@ void ImmutableMessageOneofFieldGenerator::GenerateMembers( " }\n" " return $type$.getDefaultInstance();\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); } void ImmutableMessageOneofFieldGenerator::GenerateBuilderMembers( @@ -620,14 +620,14 @@ void ImmutableMessageOneofFieldGenerator::GenerateBuilderMembers( // The comments above the methods below are based on a hypothetical // field of type "Field" called "Field". - // boolean hasField() + // boolean hasField() WriteFieldAccessorDocComment(printer, descriptor_, HAZZER); - printer->Print(variables_, + printer->Print(variables_, "@java.lang.Override\n" "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return $has_oneof_case_message$;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); // Field getField() WriteFieldAccessorDocComment(printer, descriptor_, GETTER); @@ -728,7 +728,7 @@ void ImmutableMessageOneofFieldGenerator::GenerateBuilderMembers( "${$get$capitalized_name$Builder$}$() {\n" " return get$capitalized_name$FieldBuilder().getBuilder();\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, @@ -744,7 +744,7 @@ void ImmutableMessageOneofFieldGenerator::GenerateBuilderMembers( " return $type$.getDefaultInstance();\n" " }\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, @@ -766,7 +766,7 @@ void ImmutableMessageOneofFieldGenerator::GenerateBuilderMembers( " $on_changed$;\n" " return $name$Builder_;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); } void ImmutableMessageOneofFieldGenerator::GenerateBuildingCode( @@ -897,7 +897,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateMembers( "${$get$capitalized_name$List$}$() {\n" " return $name$_;\n" // note: unmodifiable list "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, @@ -906,7 +906,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateMembers( " ${$get$capitalized_name$OrBuilderList$}$() {\n" " return $name$_;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, @@ -914,7 +914,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateMembers( "$deprecation$public int ${$get$capitalized_name$Count$}$() {\n" " return $name$_.size();\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, @@ -922,7 +922,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateMembers( "$deprecation$public $type$ ${$get$capitalized_name$$}$(int index) {\n" " return $name$_.get(index);\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "@java.lang.Override\n" @@ -931,7 +931,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateMembers( " int index) {\n" " return $name$_.get(index);\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); } void RepeatedImmutableMessageFieldGenerator::PrintNestedBuilderCondition( @@ -953,7 +953,7 @@ void RepeatedImmutableMessageFieldGenerator::PrintNestedBuilderFunction( const char* regular_case, const char* nested_builder_case, const char* trailing_code) const { printer->Print(variables_, method_prototype); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); printer->Print(" {\n"); printer->Indent(); PrintNestedBuilderCondition(printer, regular_case, nested_builder_case); @@ -1182,7 +1182,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateBuilderMembers( " int index) {\n" " return get$capitalized_name$FieldBuilder().getBuilder(index);\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, @@ -1195,7 +1195,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateBuilderMembers( " return $name$Builder_.getMessageOrBuilder(index);\n" " }\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( @@ -1208,7 +1208,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateBuilderMembers( " return java.util.Collections.unmodifiableList($name$_);\n" " }\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, @@ -1217,7 +1217,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateBuilderMembers( " return get$capitalized_name$FieldBuilder().addBuilder(\n" " $type$.getDefaultInstance());\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, @@ -1226,7 +1226,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateBuilderMembers( " return get$capitalized_name$FieldBuilder().addBuilder(\n" " index, $type$.getDefaultInstance());\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, @@ -1249,7 +1249,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateBuilderMembers( " }\n" " return $name$Builder_;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); } void RepeatedImmutableMessageFieldGenerator:: diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field_lite.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field_lite.cc index 30e51a4fc1..f36555f00c 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field_lite.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field_lite.cc @@ -76,7 +76,7 @@ void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex, ? "@kotlin.Deprecated(message = \"Field " + (*variables)["name"] + " is deprecated\") " : ""; - (*variables)["required"] = descriptor->is_required() ? "true" : "false"; + (*variables)["required"] = descriptor->is_required() ? "true" : "false"; if (HasHasbit(descriptor)) { // For singular messages and builders, one bit is used for the hasField bit. @@ -153,7 +153,7 @@ void ImmutableMessageFieldLiteGenerator::GenerateMembers( "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return $get_has_field_bit_message$;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, @@ -161,7 +161,7 @@ void ImmutableMessageFieldLiteGenerator::GenerateMembers( "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n" " return $name$_ == null ? $type$.getDefaultInstance() : $name$_;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); } else { WriteFieldDocComment(printer, descriptor_); printer->Print( @@ -170,7 +170,7 @@ void ImmutableMessageFieldLiteGenerator::GenerateMembers( "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return $name$_ != null;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, @@ -178,7 +178,7 @@ void ImmutableMessageFieldLiteGenerator::GenerateMembers( "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n" " return $name$_ == null ? $type$.getDefaultInstance() : $name$_;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); } // Field.Builder setField(Field value) @@ -228,7 +228,7 @@ void ImmutableMessageFieldLiteGenerator::GenerateBuilderMembers( "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return instance.has$capitalized_name$();\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); // Field getField() WriteFieldDocComment(printer, descriptor_); @@ -237,7 +237,7 @@ void ImmutableMessageFieldLiteGenerator::GenerateBuilderMembers( "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n" " return instance.get$capitalized_name$();\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); // Field.Builder setField(Field value) WriteFieldDocComment(printer, descriptor_); @@ -248,7 +248,7 @@ void ImmutableMessageFieldLiteGenerator::GenerateBuilderMembers( " instance.set$capitalized_name$(value);\n" " return this;\n" " }\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); // Field.Builder setField(Field.Builder builderForValue) WriteFieldDocComment(printer, descriptor_); @@ -259,7 +259,7 @@ void ImmutableMessageFieldLiteGenerator::GenerateBuilderMembers( " instance.set$capitalized_name$(builderForValue.build());\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); // Field.Builder mergeField(Field value) WriteFieldDocComment(printer, descriptor_); @@ -270,7 +270,7 @@ void ImmutableMessageFieldLiteGenerator::GenerateBuilderMembers( " instance.merge$capitalized_name$(value);\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); // Field.Builder clearField() WriteFieldDocComment(printer, descriptor_); @@ -280,7 +280,7 @@ void ImmutableMessageFieldLiteGenerator::GenerateBuilderMembers( " instance.clear$capitalized_name$();\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); } void ImmutableMessageFieldLiteGenerator::GenerateKotlinDslMembers( @@ -351,9 +351,9 @@ void ImmutableMessageOneofFieldLiteGenerator::GenerateMembers( "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return $has_oneof_case_message$;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, + printer->Annotate("{", "}", descriptor_); + WriteFieldDocComment(printer, descriptor_); + printer->Print(variables_, "@java.lang.Override\n" "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n" " if ($has_oneof_case_message$) {\n" @@ -361,7 +361,7 @@ void ImmutableMessageOneofFieldLiteGenerator::GenerateMembers( " }\n" " return $type$.getDefaultInstance();\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); // Field.Builder setField(Field value) WriteFieldDocComment(printer, descriptor_); @@ -407,20 +407,20 @@ void ImmutableMessageOneofFieldLiteGenerator::GenerateFieldInfo( WriteIntToUtf16CharSequence(descriptor_->containing_oneof()->index(), output); printer->Print(variables_, "$oneof_stored_type$.class,\n"); } - + void ImmutableMessageOneofFieldLiteGenerator::GenerateBuilderMembers( io::Printer* printer) const { // The comments above the methods below are based on a hypothetical // field of type "Field" called "Field". - // boolean hasField() - WriteFieldDocComment(printer, descriptor_); - printer->Print(variables_, + // boolean hasField() + WriteFieldDocComment(printer, descriptor_); + printer->Print(variables_, "@java.lang.Override\n" "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return instance.has$capitalized_name$();\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); // Field getField() WriteFieldDocComment(printer, descriptor_); @@ -429,7 +429,7 @@ void ImmutableMessageOneofFieldLiteGenerator::GenerateBuilderMembers( "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n" " return instance.get$capitalized_name$();\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); // Field.Builder setField(Field value) WriteFieldDocComment(printer, descriptor_); @@ -440,7 +440,7 @@ void ImmutableMessageOneofFieldLiteGenerator::GenerateBuilderMembers( " instance.set$capitalized_name$(value);\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); // Field.Builder setField(Field.Builder builderForValue) WriteFieldDocComment(printer, descriptor_); @@ -451,7 +451,7 @@ void ImmutableMessageOneofFieldLiteGenerator::GenerateBuilderMembers( " instance.set$capitalized_name$(builderForValue.build());\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); // Field.Builder mergeField(Field value) WriteFieldDocComment(printer, descriptor_); @@ -462,7 +462,7 @@ void ImmutableMessageOneofFieldLiteGenerator::GenerateBuilderMembers( " instance.merge$capitalized_name$(value);\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); // Field.Builder clearField() WriteFieldDocComment(printer, descriptor_); @@ -473,7 +473,7 @@ void ImmutableMessageOneofFieldLiteGenerator::GenerateBuilderMembers( " instance.clear$capitalized_name$();\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); } // =================================================================== @@ -526,7 +526,7 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateMembers( "${$get$capitalized_name$List$}$() {\n" " return $name$_;\n" // note: unmodifiable list "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, @@ -534,7 +534,7 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateMembers( " ${$get$capitalized_name$OrBuilderList$}$() {\n" " return $name$_;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, @@ -542,7 +542,7 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateMembers( "$deprecation$public int ${$get$capitalized_name$Count$}$() {\n" " return $name$_.size();\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print( variables_, @@ -550,7 +550,7 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateMembers( "$deprecation$public $type$ ${$get$capitalized_name$$}$(int index) {\n" " return $name$_.get(index);\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, "$deprecation$public $type$OrBuilder " @@ -558,7 +558,7 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateMembers( " int index) {\n" " return $name$_.get(index);\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); printer->Print( variables_, @@ -641,7 +641,7 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateBuilderMembers( " return java.util.Collections.unmodifiableList(\n" " instance.get$capitalized_name$List());\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); // int getRepeatedFieldCount() WriteFieldDocComment(printer, descriptor_); @@ -651,7 +651,7 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateBuilderMembers( "$deprecation$public int ${$get$capitalized_name$Count$}$() {\n" " return instance.get$capitalized_name$Count();\n" "}"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); // Field getRepeatedField(int index) WriteFieldDocComment(printer, descriptor_); @@ -661,7 +661,7 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateBuilderMembers( "$deprecation$public $type$ ${$get$capitalized_name$$}$(int index) {\n" " return instance.get$capitalized_name$(index);\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); // Builder setRepeatedField(int index, Field value) WriteFieldDocComment(printer, descriptor_); @@ -672,7 +672,7 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateBuilderMembers( " instance.set$capitalized_name$(index, value);\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); // Builder setRepeatedField(int index, Field.Builder builderForValue) WriteFieldDocComment(printer, descriptor_); @@ -684,7 +684,7 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateBuilderMembers( " builderForValue.build());\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); // Builder addRepeatedField(Field value) WriteFieldDocComment(printer, descriptor_); @@ -695,7 +695,7 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateBuilderMembers( " instance.add$capitalized_name$(value);\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); // Builder addRepeatedField(int index, Field value) WriteFieldDocComment(printer, descriptor_); @@ -706,7 +706,7 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateBuilderMembers( " instance.add$capitalized_name$(index, value);\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); // Builder addRepeatedField(Field.Builder builderForValue) WriteFieldDocComment(printer, descriptor_); printer->Print(variables_, @@ -716,7 +716,7 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateBuilderMembers( " instance.add$capitalized_name$(builderForValue.build());\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); // Builder addRepeatedField(int index, Field.Builder builderForValue) WriteFieldDocComment(printer, descriptor_); @@ -728,7 +728,7 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateBuilderMembers( " builderForValue.build());\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); // Builder addAllRepeatedField(Iterable<Field> values) WriteFieldDocComment(printer, descriptor_); @@ -739,7 +739,7 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateBuilderMembers( " instance.addAll$capitalized_name$(values);\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); // Builder clearAllRepeatedField() WriteFieldDocComment(printer, descriptor_); @@ -750,7 +750,7 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateBuilderMembers( " instance.clear$capitalized_name$();\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); // Builder removeRepeatedField(int index) WriteFieldDocComment(printer, descriptor_); @@ -761,7 +761,7 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateBuilderMembers( " instance.remove$capitalized_name$(index);\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); } void RepeatedImmutableMessageFieldLiteGenerator::GenerateFieldInfo( diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field_lite.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field_lite.h index 7ad9645fe5..22a12ce857 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field_lite.h +++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_field_lite.h @@ -122,7 +122,7 @@ class RepeatedImmutableMessageFieldLiteGenerator void GenerateKotlinDslMembers(io::Printer* printer) const override; TProtoStringType GetBoxedType() const override; - + protected: const FieldDescriptor* descriptor_; std::map<TProtoStringType, TProtoStringType> variables_; diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_lite.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_lite.cc index e10c0da2b9..bec5a7f47c 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_lite.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_message_lite.cc @@ -113,7 +113,7 @@ void ImmutableMessageLiteGenerator::GenerateInterface(io::Printer* printer) { /* immutable = */ true, "OrBuilder"); if (descriptor_->extension_range_count() > 0) { printer->Print( - "$deprecation$public interface ${$$classname$OrBuilder$}$ extends \n" + "$deprecation$public interface ${$$classname$OrBuilder$}$ extends \n" " $extra_interfaces$\n" " com.google.protobuf.GeneratedMessageLite.\n" " ExtendableMessageOrBuilder<\n" @@ -124,7 +124,7 @@ void ImmutableMessageLiteGenerator::GenerateInterface(io::Printer* printer) { "classname", descriptor_->name(), "{", "", "}", ""); } else { printer->Print( - "$deprecation$public interface ${$$classname$OrBuilder$}$ extends\n" + "$deprecation$public interface ${$$classname$OrBuilder$}$ extends\n" " $extra_interfaces$\n" " com.google.protobuf.MessageLiteOrBuilder {\n", "deprecation", @@ -132,7 +132,7 @@ void ImmutableMessageLiteGenerator::GenerateInterface(io::Printer* printer) { "extra_interfaces", ExtraMessageOrBuilderInterfaces(descriptor_), "classname", descriptor_->name(), "{", "", "}", ""); } - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); printer->Indent(); for (int i = 0; i < descriptor_->field_count(); i++) { @@ -170,7 +170,7 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) { MaybePrintGeneratedAnnotation(context_, printer, descriptor_, /* immutable = */ true); - + // The builder_type stores the super type name of the nested Builder class. TProtoStringType builder_type; if (descriptor_->extension_range_count() > 0) { @@ -187,7 +187,7 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) { } else { printer->Print( variables, - "$deprecation$public $static$final class $classname$ extends\n" + "$deprecation$public $static$final class $classname$ extends\n" " com.google.protobuf.GeneratedMessageLite<\n" " $classname$, $classname$.Builder> implements\n" " $extra_interfaces$\n" @@ -229,7 +229,7 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) { // oneof std::map<TProtoStringType, TProtoStringType> vars; for (auto oneof : oneofs_) { - vars["oneof_name"] = context_->GetOneofGeneratorInfo(oneof)->name; + vars["oneof_name"] = context_->GetOneofGeneratorInfo(oneof)->name; vars["oneof_capitalized_name"] = context_->GetOneofGeneratorInfo(oneof)->capitalized_name; vars["oneof_index"] = StrCat((oneof)->index()); @@ -321,15 +321,15 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) { printer->Print( "@java.lang.Override\n" - "@java.lang.SuppressWarnings({\"unchecked\", \"fallthrough\"})\n" - "protected final java.lang.Object dynamicMethod(\n" - " com.google.protobuf.GeneratedMessageLite.MethodToInvoke method,\n" - " java.lang.Object arg0, java.lang.Object arg1) {\n" - " switch (method) {\n" - " case NEW_MUTABLE_INSTANCE: {\n" - " return new $classname$();\n" - " }\n", - "classname", name_resolver_->GetImmutableClassName(descriptor_)); + "@java.lang.SuppressWarnings({\"unchecked\", \"fallthrough\"})\n" + "protected final java.lang.Object dynamicMethod(\n" + " com.google.protobuf.GeneratedMessageLite.MethodToInvoke method,\n" + " java.lang.Object arg0, java.lang.Object arg1) {\n" + " switch (method) {\n" + " case NEW_MUTABLE_INSTANCE: {\n" + " return new $classname$();\n" + " }\n", + "classname", name_resolver_->GetImmutableClassName(descriptor_)); printer->Indent(); printer->Indent(); diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_options.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_options.h index a7b003427e..1454c23206 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_options.h +++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_options.h @@ -59,10 +59,10 @@ struct Options { bool annotate_code; // Name of a file where we will write a list of generated .meta file names, // one per line. - TProtoStringType annotation_list_file; + TProtoStringType annotation_list_file; // Name of a file where we will write a list of generated file names, one // per line. - TProtoStringType output_list_file; + TProtoStringType output_list_file; }; } // namespace java diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field.cc index d7e6d7c303..ab550761b1 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field.cc @@ -113,7 +113,7 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor, : ("= " + ImmutableDefaultValue(descriptor, name_resolver)); (*variables)["capitalized_type"] = GetCapitalizedType(descriptor, /* immutable = */ true); - (*variables)["tag"] = + (*variables)["tag"] = StrCat(static_cast<int32_t>(WireFormat::MakeTag(descriptor))); (*variables)["tag_size"] = StrCat( WireFormat::TagSize(descriptor->number(), GetType(descriptor))); @@ -232,7 +232,7 @@ void ImmutablePrimitiveFieldGenerator::GenerateMembers( "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return $get_has_field_bit_message$;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); } WriteFieldAccessorDocComment(printer, descriptor_, GETTER); @@ -241,7 +241,7 @@ void ImmutablePrimitiveFieldGenerator::GenerateMembers( "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n" " return $name$_;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); } void ImmutablePrimitiveFieldGenerator::GenerateBuilderMembers( @@ -256,7 +256,7 @@ void ImmutablePrimitiveFieldGenerator::GenerateBuilderMembers( "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return $get_has_field_bit_builder$;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); } WriteFieldAccessorDocComment(printer, descriptor_, GETTER); @@ -265,7 +265,7 @@ void ImmutablePrimitiveFieldGenerator::GenerateBuilderMembers( "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n" " return $name$_;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, SETTER, /* builder */ true); @@ -278,7 +278,7 @@ void ImmutablePrimitiveFieldGenerator::GenerateBuilderMembers( " $on_changed$\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, CLEARER, /* builder */ true); @@ -286,7 +286,7 @@ void ImmutablePrimitiveFieldGenerator::GenerateBuilderMembers( variables_, "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n" " $clear_has_field_bit_builder$\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); JavaType type = GetJavaType(descriptor_); if (type == JAVATYPE_STRING || type == JAVATYPE_BYTES) { // The default value is not a simple literal so we want to avoid executing @@ -549,7 +549,7 @@ void ImmutablePrimitiveOneofFieldGenerator::GenerateMembers( " }\n" " return $default$;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); } void ImmutablePrimitiveOneofFieldGenerator::GenerateBuilderMembers( @@ -560,7 +560,7 @@ void ImmutablePrimitiveOneofFieldGenerator::GenerateBuilderMembers( "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return $has_oneof_case_message$;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, GETTER); printer->Print(variables_, @@ -570,7 +570,7 @@ void ImmutablePrimitiveOneofFieldGenerator::GenerateBuilderMembers( " }\n" " return $default$;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, SETTER, /* builder */ true); @@ -583,7 +583,7 @@ void ImmutablePrimitiveOneofFieldGenerator::GenerateBuilderMembers( " $on_changed$\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, CLEARER, /* builder */ true); @@ -626,15 +626,15 @@ void ImmutablePrimitiveOneofFieldGenerator::GenerateSerializationCode( printer->Print(variables_, "if ($has_oneof_case_message$) {\n" " output.write$capitalized_type$(\n"); - // $type$ and $boxed_type$ is the same for bytes fields so we don't need to - // do redundant casts. - if (GetJavaType(descriptor_) == JAVATYPE_BYTES) { + // $type$ and $boxed_type$ is the same for bytes fields so we don't need to + // do redundant casts. + if (GetJavaType(descriptor_) == JAVATYPE_BYTES) { printer->Print(variables_, " $number$, ($type$) $oneof_name$_);\n"); - } else { + } else { printer->Print( variables_, " $number$, ($type$)(($boxed_type$) $oneof_name$_));\n"); - } + } printer->Print("}\n"); } @@ -644,15 +644,15 @@ void ImmutablePrimitiveOneofFieldGenerator::GenerateSerializedSizeCode( "if ($has_oneof_case_message$) {\n" " size += com.google.protobuf.CodedOutputStream\n" " .compute$capitalized_type$Size(\n"); - // $type$ and $boxed_type$ is the same for bytes fields so we don't need to - // do redundant casts. - if (GetJavaType(descriptor_) == JAVATYPE_BYTES) { + // $type$ and $boxed_type$ is the same for bytes fields so we don't need to + // do redundant casts. + if (GetJavaType(descriptor_) == JAVATYPE_BYTES) { printer->Print(variables_, " $number$, ($type$) $oneof_name$_);\n"); - } else { + } else { printer->Print( variables_, " $number$, ($type$)(($boxed_type$) $oneof_name$_));\n"); - } + } printer->Print("}\n"); } @@ -705,21 +705,21 @@ void RepeatedImmutablePrimitiveFieldGenerator::GenerateMembers( " ${$get$capitalized_name$List$}$() {\n" " return $name$_;\n" // note: unmodifiable list "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, LIST_COUNT); printer->Print( variables_, "$deprecation$public int ${$get$capitalized_name$Count$}$() {\n" " return $name$_.size();\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER); printer->Print( variables_, "$deprecation$public $type$ ${$get$capitalized_name$$}$(int index) {\n" " return $repeated_get$(index);\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); if (descriptor_->is_packed()) { printer->Print(variables_, @@ -761,21 +761,21 @@ void RepeatedImmutablePrimitiveFieldGenerator::GenerateBuilderMembers( " return $get_mutable_bit_builder$ ?\n" " java.util.Collections.unmodifiableList($name$_) : $name$_;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, LIST_COUNT); printer->Print( variables_, "$deprecation$public int ${$get$capitalized_name$Count$}$() {\n" " return $name$_.size();\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER); printer->Print( variables_, "$deprecation$public $type$ ${$get$capitalized_name$$}$(int index) {\n" " return $repeated_get$(index);\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_SETTER, /* builder */ true); printer->Print(variables_, @@ -787,7 +787,7 @@ void RepeatedImmutablePrimitiveFieldGenerator::GenerateBuilderMembers( " $on_changed$\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER, /* builder */ true); printer->Print(variables_, @@ -799,7 +799,7 @@ void RepeatedImmutablePrimitiveFieldGenerator::GenerateBuilderMembers( " $on_changed$\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER, /* builder */ true); printer->Print(variables_, @@ -811,7 +811,7 @@ void RepeatedImmutablePrimitiveFieldGenerator::GenerateBuilderMembers( " $on_changed$\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, CLEARER, /* builder */ true); printer->Print( @@ -822,7 +822,7 @@ void RepeatedImmutablePrimitiveFieldGenerator::GenerateBuilderMembers( " $on_changed$\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); } void RepeatedImmutablePrimitiveFieldGenerator::GenerateKotlinDslMembers( diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field_lite.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field_lite.cc index 1f31a34992..35f78fce9e 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field_lite.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field_lite.cc @@ -79,11 +79,11 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor, (*variables)["default"] = ImmutableDefaultValue(descriptor, name_resolver); (*variables)["capitalized_type"] = GetCapitalizedType(descriptor, /* immutable = */ true); - (*variables)["tag"] = + (*variables)["tag"] = StrCat(static_cast<int32_t>(WireFormat::MakeTag(descriptor))); (*variables)["tag_size"] = StrCat( WireFormat::TagSize(descriptor->number(), GetType(descriptor))); - (*variables)["required"] = descriptor->is_required() ? "true" : "false"; + (*variables)["required"] = descriptor->is_required() ? "true" : "false"; TProtoStringType capitalized_type = UnderscoresToCamelCase( PrimitiveTypeName(javaType), true /* cap_next_letter */); @@ -229,7 +229,7 @@ void ImmutablePrimitiveFieldLiteGenerator::GenerateMembers( "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return $get_has_field_bit_message$;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); } WriteFieldAccessorDocComment(printer, descriptor_, GETTER); @@ -238,7 +238,7 @@ void ImmutablePrimitiveFieldLiteGenerator::GenerateMembers( "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n" " return $name$_;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, SETTER); printer->Print(variables_, @@ -275,7 +275,7 @@ void ImmutablePrimitiveFieldLiteGenerator::GenerateBuilderMembers( "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return instance.has$capitalized_name$();\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); } WriteFieldAccessorDocComment(printer, descriptor_, GETTER); @@ -284,7 +284,7 @@ void ImmutablePrimitiveFieldLiteGenerator::GenerateBuilderMembers( "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n" " return instance.get$capitalized_name$();\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, SETTER, /* builder */ true); @@ -295,7 +295,7 @@ void ImmutablePrimitiveFieldLiteGenerator::GenerateBuilderMembers( " instance.set$capitalized_name$(value);\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, CLEARER, /* builder */ true); @@ -306,7 +306,7 @@ void ImmutablePrimitiveFieldLiteGenerator::GenerateBuilderMembers( " instance.clear$capitalized_name$();\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); } void ImmutablePrimitiveFieldLiteGenerator::GenerateKotlinDslMembers( @@ -398,7 +398,7 @@ void ImmutablePrimitiveOneofFieldLiteGenerator::GenerateMembers( " }\n" " return $default$;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, SETTER); printer->Print(variables_, @@ -435,7 +435,7 @@ void ImmutablePrimitiveOneofFieldLiteGenerator::GenerateBuilderMembers( "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return instance.has$capitalized_name$();\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, GETTER); printer->Print(variables_, @@ -443,7 +443,7 @@ void ImmutablePrimitiveOneofFieldLiteGenerator::GenerateBuilderMembers( "$deprecation$public $type$ ${$get$capitalized_name$$}$() {\n" " return instance.get$capitalized_name$();\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, SETTER, /* builder */ true); @@ -454,7 +454,7 @@ void ImmutablePrimitiveOneofFieldLiteGenerator::GenerateBuilderMembers( " instance.set$capitalized_name$(value);\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, CLEARER, /* builder */ true); @@ -514,7 +514,7 @@ void RepeatedImmutablePrimitiveFieldLiteGenerator::GenerateMembers( " ${$get$capitalized_name$List$}$() {\n" " return $name$_;\n" // note: unmodifiable list "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, LIST_COUNT); printer->Print( variables_, @@ -522,7 +522,7 @@ void RepeatedImmutablePrimitiveFieldLiteGenerator::GenerateMembers( "$deprecation$public int ${$get$capitalized_name$Count$}$() {\n" " return $name$_.size();\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER); printer->Print( variables_, @@ -530,7 +530,7 @@ void RepeatedImmutablePrimitiveFieldLiteGenerator::GenerateMembers( "$deprecation$public $type$ ${$get$capitalized_name$$}$(int index) {\n" " return $repeated_get$(index);\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); if (!EnableExperimentalRuntimeForLite() && descriptor_->is_packed() && context_->HasGeneratedMethods(descriptor_->containing_type())) { @@ -589,7 +589,7 @@ void RepeatedImmutablePrimitiveFieldLiteGenerator::GenerateBuilderMembers( " return java.util.Collections.unmodifiableList(\n" " instance.get$capitalized_name$List());\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, LIST_COUNT); printer->Print( variables_, @@ -597,7 +597,7 @@ void RepeatedImmutablePrimitiveFieldLiteGenerator::GenerateBuilderMembers( "$deprecation$public int ${$get$capitalized_name$Count$}$() {\n" " return instance.get$capitalized_name$Count();\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER); printer->Print( variables_, @@ -605,7 +605,7 @@ void RepeatedImmutablePrimitiveFieldLiteGenerator::GenerateBuilderMembers( "$deprecation$public $type$ ${$get$capitalized_name$$}$(int index) {\n" " return instance.get$capitalized_name$(index);\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, SETTER, /* builder */ true); printer->Print(variables_, @@ -615,7 +615,7 @@ void RepeatedImmutablePrimitiveFieldLiteGenerator::GenerateBuilderMembers( " instance.set$capitalized_name$(index, value);\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER, /* builder */ true); printer->Print(variables_, @@ -625,7 +625,7 @@ void RepeatedImmutablePrimitiveFieldLiteGenerator::GenerateBuilderMembers( " instance.add$capitalized_name$(value);\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER, /* builder */ true); printer->Print(variables_, @@ -635,7 +635,7 @@ void RepeatedImmutablePrimitiveFieldLiteGenerator::GenerateBuilderMembers( " instance.addAll$capitalized_name$(values);\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, CLEARER, /* builder */ true); printer->Print( @@ -645,7 +645,7 @@ void RepeatedImmutablePrimitiveFieldLiteGenerator::GenerateBuilderMembers( " instance.clear$capitalized_name$();\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); } void RepeatedImmutablePrimitiveFieldLiteGenerator::GenerateKotlinDslMembers( diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field_lite.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field_lite.h index 2d4721210b..1359c358df 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field_lite.h +++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_primitive_field_lite.h @@ -76,7 +76,7 @@ class ImmutablePrimitiveFieldLiteGenerator void GenerateKotlinDslMembers(io::Printer* printer) const override; TProtoStringType GetBoxedType() const override; - + protected: const FieldDescriptor* descriptor_; std::map<TProtoStringType, TProtoStringType> variables_; @@ -100,7 +100,7 @@ class ImmutablePrimitiveOneofFieldLiteGenerator void GenerateFieldInfo(io::Printer* printer, std::vector<uint16_t>* output) const; - + private: GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutablePrimitiveOneofFieldLiteGenerator); }; @@ -123,7 +123,7 @@ class RepeatedImmutablePrimitiveFieldLiteGenerator void GenerateKotlinDslMembers(io::Printer* printer) const override; TProtoStringType GetBoxedType() const override; - + private: const FieldDescriptor* descriptor_; std::map<TProtoStringType, TProtoStringType> variables_; diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_service.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_service.cc index 5a5e5e1273..05748f5847 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_service.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_service.cc @@ -185,9 +185,9 @@ void ImmutableServiceGenerator::GenerateAbstractMethods(io::Printer* printer) { TProtoStringType ImmutableServiceGenerator::GetOutput( const MethodDescriptor* method) { - return name_resolver_->GetImmutableClassName(method->output_type()); -} - + return name_resolver_->GetImmutableClassName(method->output_type()); +} + void ImmutableServiceGenerator::GenerateCallMethod(io::Printer* printer) { printer->Print( "\n" @@ -212,7 +212,7 @@ void ImmutableServiceGenerator::GenerateCallMethod(io::Printer* printer) { vars["index"] = StrCat(i); vars["method"] = UnderscoresToCamelCase(method); vars["input"] = name_resolver_->GetImmutableClassName(method->input_type()); - vars["output"] = GetOutput(method); + vars["output"] = GetOutput(method); printer->Print( vars, "case $index$:\n" @@ -259,7 +259,7 @@ void ImmutableServiceGenerator::GenerateCallBlockingMethod( vars["index"] = StrCat(i); vars["method"] = UnderscoresToCamelCase(method); vars["input"] = name_resolver_->GetImmutableClassName(method->input_type()); - vars["output"] = GetOutput(method); + vars["output"] = GetOutput(method); printer->Print(vars, "case $index$:\n" " return impl.$method$(controller, ($input$)request);\n"); @@ -357,7 +357,7 @@ void ImmutableServiceGenerator::GenerateStub(io::Printer* printer) { std::map<TProtoStringType, TProtoStringType> vars; vars["index"] = StrCat(i); - vars["output"] = GetOutput(method); + vars["output"] = GetOutput(method); printer->Print(vars, "channel.callMethod(\n" " getDescriptor().getMethods().get($index$),\n" @@ -421,7 +421,7 @@ void ImmutableServiceGenerator::GenerateBlockingStub(io::Printer* printer) { std::map<TProtoStringType, TProtoStringType> vars; vars["index"] = StrCat(i); - vars["output"] = GetOutput(method); + vars["output"] = GetOutput(method); printer->Print(vars, "return ($output$) channel.callBlockingMethod(\n" " getDescriptor().getMethods().get($index$),\n" @@ -445,7 +445,7 @@ void ImmutableServiceGenerator::GenerateMethodSignature( std::map<TProtoStringType, TProtoStringType> vars; vars["name"] = UnderscoresToCamelCase(method); vars["input"] = name_resolver_->GetImmutableClassName(method->input_type()); - vars["output"] = GetOutput(method); + vars["output"] = GetOutput(method); vars["abstract"] = (is_abstract == IS_ABSTRACT) ? "abstract" : ""; printer->Print(vars, "public $abstract$ void $name$(\n" @@ -459,7 +459,7 @@ void ImmutableServiceGenerator::GenerateBlockingMethodSignature( std::map<TProtoStringType, TProtoStringType> vars; vars["method"] = UnderscoresToCamelCase(method); vars["input"] = name_resolver_->GetImmutableClassName(method->input_type()); - vars["output"] = GetOutput(method); + vars["output"] = GetOutput(method); printer->Print(vars, "\n" "public $output$ $method$(\n" diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_service.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_service.h index f8de994bea..e3d52a40ca 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_service.h +++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_service.h @@ -123,9 +123,9 @@ class ImmutableServiceGenerator : public ServiceGenerator { void GenerateBlockingMethodSignature(io::Printer* printer, const MethodDescriptor* method); - // Return the output type of the method. + // Return the output type of the method. TProtoStringType GetOutput(const MethodDescriptor* method); - + Context* context_; ClassNameResolver* name_resolver_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableServiceGenerator); diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_shared_code_generator.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_shared_code_generator.cc index 3a03024daa..a0d5e2b45f 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_shared_code_generator.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_shared_code_generator.cc @@ -167,12 +167,12 @@ void SharedCodeGenerator::GenerateDescriptors(io::Printer* printer) { TProtoStringType classname = name_resolver_->GetDescriptorClassName(file_->dependency(i)); TProtoStringType full_name; - if (package.empty()) { - full_name = classname; - } else { - full_name = package + "." + classname; - } - dependencies.push_back(std::make_pair(filename, full_name)); + if (package.empty()) { + full_name = classname; + } else { + full_name = package + "." + classname; + } + dependencies.push_back(std::make_pair(filename, full_name)); } // ----------------------------------------------------------------- diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_shared_code_generator.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_shared_code_generator.h index 6023bf2a55..93fe6d7996 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_shared_code_generator.h +++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_shared_code_generator.h @@ -69,7 +69,7 @@ class SharedCodeGenerator { SharedCodeGenerator(const FileDescriptor* file, const Options& options); ~SharedCodeGenerator(); - void Generate(GeneratorContext* generator_context, + void Generate(GeneratorContext* generator_context, std::vector<TProtoStringType>* file_list, std::vector<TProtoStringType>* annotation_file_list); diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field.cc index a919855889..e0019a5ffe 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field.cc @@ -72,7 +72,7 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor, (*variables)["default_init"] = "= " + ImmutableDefaultValue(descriptor, name_resolver); (*variables)["capitalized_type"] = "String"; - (*variables)["tag"] = + (*variables)["tag"] = StrCat(static_cast<int32_t>(WireFormat::MakeTag(descriptor))); (*variables)["tag_size"] = StrCat( WireFormat::TagSize(descriptor->number(), GetType(descriptor))); @@ -222,7 +222,7 @@ void ImmutableStringFieldGenerator::GenerateMembers( "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return $get_has_field_bit_message$;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); } WriteFieldAccessorDocComment(printer, descriptor_, GETTER); @@ -237,7 +237,7 @@ void ImmutableStringFieldGenerator::GenerateMembers( " com.google.protobuf.ByteString bs = \n" " (com.google.protobuf.ByteString) ref;\n" " java.lang.String s = bs.toStringUtf8();\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); if (CheckUtf8(descriptor_)) { printer->Print(variables_, " $name$_ = s;\n"); } else { @@ -266,7 +266,7 @@ void ImmutableStringFieldGenerator::GenerateMembers( " return (com.google.protobuf.ByteString) ref;\n" " }\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); } void ImmutableStringFieldGenerator::GenerateBuilderMembers( @@ -280,7 +280,7 @@ void ImmutableStringFieldGenerator::GenerateBuilderMembers( "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return $get_has_field_bit_builder$;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); } WriteFieldAccessorDocComment(printer, descriptor_, GETTER); @@ -292,7 +292,7 @@ void ImmutableStringFieldGenerator::GenerateBuilderMembers( " com.google.protobuf.ByteString bs =\n" " (com.google.protobuf.ByteString) ref;\n" " java.lang.String s = bs.toStringUtf8();\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); if (CheckUtf8(descriptor_)) { printer->Print(variables_, " $name$_ = s;\n"); } else { @@ -323,7 +323,7 @@ void ImmutableStringFieldGenerator::GenerateBuilderMembers( " return (com.google.protobuf.ByteString) ref;\n" " }\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, SETTER, /* builder */ true); @@ -336,14 +336,14 @@ void ImmutableStringFieldGenerator::GenerateBuilderMembers( " $on_changed$\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, CLEARER, /* builder */ true); printer->Print( variables_, "$deprecation$public Builder ${$clear$capitalized_name$$}$() {\n" " $clear_has_field_bit_builder$\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); // The default value is not a simple literal so we want to avoid executing // it multiple times. Instead, get the default out of the default instance. printer->Print(variables_, @@ -360,7 +360,7 @@ void ImmutableStringFieldGenerator::GenerateBuilderMembers( "$deprecation$public Builder ${$set$capitalized_name$Bytes$}$(\n" " com.google.protobuf.ByteString value) {\n" "$null_check$"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); if (CheckUtf8(descriptor_)) { printer->Print(variables_, " checkByteStringIsUtf8(value);\n"); } @@ -525,7 +525,7 @@ void ImmutableStringOneofFieldGenerator::GenerateMembers( "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return $has_oneof_case_message$;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, GETTER); printer->Print( @@ -541,7 +541,7 @@ void ImmutableStringOneofFieldGenerator::GenerateMembers( " com.google.protobuf.ByteString bs = \n" " (com.google.protobuf.ByteString) ref;\n" " java.lang.String s = bs.toStringUtf8();\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); if (CheckUtf8(descriptor_)) { printer->Print(variables_, " if ($has_oneof_case_message$) {\n" @@ -578,7 +578,7 @@ void ImmutableStringOneofFieldGenerator::GenerateMembers( " return (com.google.protobuf.ByteString) ref;\n" " }\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); } void ImmutableStringOneofFieldGenerator::GenerateBuilderMembers( @@ -590,7 +590,7 @@ void ImmutableStringOneofFieldGenerator::GenerateBuilderMembers( "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return $has_oneof_case_message$;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, GETTER); printer->Print( @@ -644,7 +644,7 @@ void ImmutableStringOneofFieldGenerator::GenerateBuilderMembers( " return (com.google.protobuf.ByteString) ref;\n" " }\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, SETTER, /* builder */ true); @@ -657,7 +657,7 @@ void ImmutableStringOneofFieldGenerator::GenerateBuilderMembers( " $on_changed$\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, CLEARER, /* builder */ true); printer->Print( @@ -670,7 +670,7 @@ void ImmutableStringOneofFieldGenerator::GenerateBuilderMembers( " }\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldStringBytesAccessorDocComment(printer, descriptor_, SETTER, /* builder */ true); @@ -679,7 +679,7 @@ void ImmutableStringOneofFieldGenerator::GenerateBuilderMembers( "$deprecation$public Builder ${$set$capitalized_name$Bytes$}$(\n" " com.google.protobuf.ByteString value) {\n" "$null_check$"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); if (CheckUtf8(descriptor_)) { printer->Print(variables_, " checkByteStringIsUtf8(value);\n"); } @@ -800,21 +800,21 @@ void RepeatedImmutableStringFieldGenerator::GenerateMembers( " ${$get$capitalized_name$List$}$() {\n" " return $name$_;\n" // note: unmodifiable list "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, LIST_COUNT); printer->Print( variables_, "$deprecation$public int ${$get$capitalized_name$Count$}$() {\n" " return $name$_.size();\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER); printer->Print(variables_, "$deprecation$public java.lang.String " "${$get$capitalized_name$$}$(int index) {\n" " return $name$_.get(index);\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldStringBytesAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER); printer->Print(variables_, @@ -822,7 +822,7 @@ void RepeatedImmutableStringFieldGenerator::GenerateMembers( " ${$get$capitalized_name$Bytes$}$(int index) {\n" " return $name$_.getByteString(index);\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); } void RepeatedImmutableStringFieldGenerator::GenerateBuilderMembers( @@ -859,21 +859,21 @@ void RepeatedImmutableStringFieldGenerator::GenerateBuilderMembers( " ${$get$capitalized_name$List$}$() {\n" " return $name$_.getUnmodifiableView();\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, LIST_COUNT); printer->Print( variables_, "$deprecation$public int ${$get$capitalized_name$Count$}$() {\n" " return $name$_.size();\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER); printer->Print(variables_, "$deprecation$public java.lang.String " "${$get$capitalized_name$$}$(int index) {\n" " return $name$_.get(index);\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldStringBytesAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER); printer->Print(variables_, @@ -881,7 +881,7 @@ void RepeatedImmutableStringFieldGenerator::GenerateBuilderMembers( " ${$get$capitalized_name$Bytes$}$(int index) {\n" " return $name$_.getByteString(index);\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_SETTER, /* builder */ true); printer->Print(variables_, @@ -893,7 +893,7 @@ void RepeatedImmutableStringFieldGenerator::GenerateBuilderMembers( " $on_changed$\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER, /* builder */ true); printer->Print(variables_, @@ -905,7 +905,7 @@ void RepeatedImmutableStringFieldGenerator::GenerateBuilderMembers( " $on_changed$\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER, /* builder */ true); printer->Print(variables_, @@ -917,7 +917,7 @@ void RepeatedImmutableStringFieldGenerator::GenerateBuilderMembers( " $on_changed$\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, CLEARER, /* builder */ true); printer->Print( @@ -928,7 +928,7 @@ void RepeatedImmutableStringFieldGenerator::GenerateBuilderMembers( " $on_changed$\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldStringBytesAccessorDocComment(printer, descriptor_, LIST_ADDER, /* builder */ true); @@ -937,7 +937,7 @@ void RepeatedImmutableStringFieldGenerator::GenerateBuilderMembers( "$deprecation$public Builder ${$add$capitalized_name$Bytes$}$(\n" " com.google.protobuf.ByteString value) {\n" "$null_check$"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); if (CheckUtf8(descriptor_)) { printer->Print(variables_, " checkByteStringIsUtf8(value);\n"); } diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field_lite.cc b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field_lite.cc index e7e7ddcedd..bfaedeba9a 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field_lite.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field_lite.cc @@ -72,8 +72,8 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor, (*variables)["default"] = ImmutableDefaultValue(descriptor, name_resolver); (*variables)["default_init"] = "= " + ImmutableDefaultValue(descriptor, name_resolver); - (*variables)["capitalized_type"] = "java.lang.String"; - (*variables)["tag"] = + (*variables)["capitalized_type"] = "java.lang.String"; + (*variables)["tag"] = StrCat(static_cast<int32_t>(WireFormat::MakeTag(descriptor))); (*variables)["tag_size"] = StrCat( WireFormat::TagSize(descriptor->number(), GetType(descriptor))); @@ -91,7 +91,7 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor, ? "@kotlin.Deprecated(message = \"Field " + (*variables)["name"] + " is deprecated\") " : ""; - (*variables)["required"] = descriptor->is_required() ? "true" : "false"; + (*variables)["required"] = descriptor->is_required() ? "true" : "false"; if (HasHasbit(descriptor)) { // For singular messages and builders, one bit is used for the hasField bit. @@ -192,7 +192,7 @@ void ImmutableStringFieldLiteGenerator::GenerateMembers( "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return $get_has_field_bit_message$;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); } WriteFieldAccessorDocComment(printer, descriptor_, GETTER); @@ -202,7 +202,7 @@ void ImmutableStringFieldLiteGenerator::GenerateMembers( "$deprecation$public java.lang.String ${$get$capitalized_name$$}$() {\n" " return $name$_;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldStringBytesAccessorDocComment(printer, descriptor_, GETTER); printer->Print( variables_, @@ -211,7 +211,7 @@ void ImmutableStringFieldLiteGenerator::GenerateMembers( " ${$get$capitalized_name$Bytes$}$() {\n" " return com.google.protobuf.ByteString.copyFromUtf8($name$_);\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, SETTER); printer->Print(variables_, @@ -254,7 +254,7 @@ void ImmutableStringFieldLiteGenerator::GenerateBuilderMembers( "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return instance.has$capitalized_name$();\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); } WriteFieldAccessorDocComment(printer, descriptor_, GETTER); @@ -264,7 +264,7 @@ void ImmutableStringFieldLiteGenerator::GenerateBuilderMembers( "$deprecation$public java.lang.String ${$get$capitalized_name$$}$() {\n" " return instance.get$capitalized_name$();\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldStringBytesAccessorDocComment(printer, descriptor_, GETTER); printer->Print(variables_, @@ -273,7 +273,7 @@ void ImmutableStringFieldLiteGenerator::GenerateBuilderMembers( " ${$get$capitalized_name$Bytes$}$() {\n" " return instance.get$capitalized_name$Bytes();\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, SETTER, /* builder */ true); @@ -284,7 +284,7 @@ void ImmutableStringFieldLiteGenerator::GenerateBuilderMembers( " instance.set$capitalized_name$(value);\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, CLEARER, /* builder */ true); printer->Print( @@ -294,7 +294,7 @@ void ImmutableStringFieldLiteGenerator::GenerateBuilderMembers( " instance.clear$capitalized_name$();\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldStringBytesAccessorDocComment(printer, descriptor_, SETTER, /* builder */ true); @@ -306,7 +306,7 @@ void ImmutableStringFieldLiteGenerator::GenerateBuilderMembers( " instance.set$capitalized_name$Bytes(value);\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); } void ImmutableStringFieldLiteGenerator::GenerateKotlinDslMembers( @@ -380,7 +380,7 @@ void ImmutableStringOneofFieldLiteGenerator::GenerateMembers( "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return $has_oneof_case_message$;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, GETTER); printer->Print( @@ -393,7 +393,7 @@ void ImmutableStringOneofFieldLiteGenerator::GenerateMembers( " }\n" " return ref;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldStringBytesAccessorDocComment(printer, descriptor_, GETTER); printer->Print(variables_, @@ -406,7 +406,7 @@ void ImmutableStringOneofFieldLiteGenerator::GenerateMembers( " }\n" " return com.google.protobuf.ByteString.copyFromUtf8(ref);\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, SETTER); printer->Print(variables_, @@ -416,7 +416,7 @@ void ImmutableStringOneofFieldLiteGenerator::GenerateMembers( " $set_oneof_case_message$;\n" " $oneof_name$_ = value;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, CLEARER); printer->Print(variables_, "private void ${$clear$capitalized_name$$}$() {\n" @@ -425,13 +425,13 @@ void ImmutableStringOneofFieldLiteGenerator::GenerateMembers( " $oneof_name$_ = null;\n" " }\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldStringBytesAccessorDocComment(printer, descriptor_, SETTER); printer->Print(variables_, "private void ${$set$capitalized_name$Bytes$}$(\n" " com.google.protobuf.ByteString value) {\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); if (CheckUtf8(descriptor_)) { printer->Print(variables_, " checkByteStringIsUtf8(value);\n"); } @@ -448,7 +448,7 @@ void ImmutableStringOneofFieldLiteGenerator::GenerateFieldInfo( output); WriteIntToUtf16CharSequence(descriptor_->containing_oneof()->index(), output); } - + void ImmutableStringOneofFieldLiteGenerator::GenerateBuilderMembers( io::Printer* printer) const { GOOGLE_DCHECK(HasHazzer(descriptor_)); @@ -458,7 +458,7 @@ void ImmutableStringOneofFieldLiteGenerator::GenerateBuilderMembers( "$deprecation$public boolean ${$has$capitalized_name$$}$() {\n" " return instance.has$capitalized_name$();\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, GETTER); printer->Print( @@ -467,7 +467,7 @@ void ImmutableStringOneofFieldLiteGenerator::GenerateBuilderMembers( "$deprecation$public java.lang.String ${$get$capitalized_name$$}$() {\n" " return instance.get$capitalized_name$();\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldStringBytesAccessorDocComment(printer, descriptor_, GETTER); printer->Print(variables_, @@ -476,7 +476,7 @@ void ImmutableStringOneofFieldLiteGenerator::GenerateBuilderMembers( " ${$get$capitalized_name$Bytes$}$() {\n" " return instance.get$capitalized_name$Bytes();\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, SETTER, /* builder */ true); @@ -487,7 +487,7 @@ void ImmutableStringOneofFieldLiteGenerator::GenerateBuilderMembers( " instance.set$capitalized_name$(value);\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, CLEARER, /* builder */ true); printer->Print( @@ -509,7 +509,7 @@ void ImmutableStringOneofFieldLiteGenerator::GenerateBuilderMembers( " instance.set$capitalized_name$Bytes(value);\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); } // =================================================================== @@ -564,7 +564,7 @@ void RepeatedImmutableStringFieldLiteGenerator::GenerateMembers( "${$get$capitalized_name$List$}$() {\n" " return $name$_;\n" // note: unmodifiable list "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, LIST_COUNT); printer->Print( variables_, @@ -572,7 +572,7 @@ void RepeatedImmutableStringFieldLiteGenerator::GenerateMembers( "$deprecation$public int ${$get$capitalized_name$Count$}$() {\n" " return $name$_.size();\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER); printer->Print(variables_, "@java.lang.Override\n" @@ -580,7 +580,7 @@ void RepeatedImmutableStringFieldLiteGenerator::GenerateMembers( "${$get$capitalized_name$$}$(int index) {\n" " return $name$_.get(index);\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldStringBytesAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER); printer->Print(variables_, @@ -590,7 +590,7 @@ void RepeatedImmutableStringFieldLiteGenerator::GenerateMembers( " return com.google.protobuf.ByteString.copyFromUtf8(\n" " $name$_.get(index));\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); printer->Print( variables_, @@ -657,7 +657,7 @@ void RepeatedImmutableStringFieldLiteGenerator::GenerateBuilderMembers( " return java.util.Collections.unmodifiableList(\n" " instance.get$capitalized_name$List());\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, LIST_COUNT); printer->Print( variables_, @@ -665,7 +665,7 @@ void RepeatedImmutableStringFieldLiteGenerator::GenerateBuilderMembers( "$deprecation$public int ${$get$capitalized_name$Count$}$() {\n" " return instance.get$capitalized_name$Count();\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER); printer->Print(variables_, "@java.lang.Override\n" @@ -673,7 +673,7 @@ void RepeatedImmutableStringFieldLiteGenerator::GenerateBuilderMembers( "${$get$capitalized_name$$}$(int index) {\n" " return instance.get$capitalized_name$(index);\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldStringBytesAccessorDocComment(printer, descriptor_, LIST_INDEXED_GETTER); printer->Print(variables_, @@ -682,7 +682,7 @@ void RepeatedImmutableStringFieldLiteGenerator::GenerateBuilderMembers( " ${$get$capitalized_name$Bytes$}$(int index) {\n" " return instance.get$capitalized_name$Bytes(index);\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_SETTER, /* builder */ true); printer->Print(variables_, @@ -692,7 +692,7 @@ void RepeatedImmutableStringFieldLiteGenerator::GenerateBuilderMembers( " instance.set$capitalized_name$(index, value);\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER, /* builder */ true); printer->Print(variables_, @@ -702,7 +702,7 @@ void RepeatedImmutableStringFieldLiteGenerator::GenerateBuilderMembers( " instance.add$capitalized_name$(value);\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER, /* builder */ true); printer->Print(variables_, @@ -712,7 +712,7 @@ void RepeatedImmutableStringFieldLiteGenerator::GenerateBuilderMembers( " instance.addAll$capitalized_name$(values);\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldAccessorDocComment(printer, descriptor_, CLEARER, /* builder */ true); printer->Print( @@ -722,7 +722,7 @@ void RepeatedImmutableStringFieldLiteGenerator::GenerateBuilderMembers( " instance.clear$capitalized_name$();\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); WriteFieldStringBytesAccessorDocComment(printer, descriptor_, LIST_ADDER, /* builder */ true); @@ -734,7 +734,7 @@ void RepeatedImmutableStringFieldLiteGenerator::GenerateBuilderMembers( " instance.add$capitalized_name$Bytes(value);\n" " return this;\n" "}\n"); - printer->Annotate("{", "}", descriptor_); + printer->Annotate("{", "}", descriptor_); } void RepeatedImmutableStringFieldLiteGenerator::GenerateKotlinDslMembers( @@ -852,7 +852,7 @@ void RepeatedImmutableStringFieldLiteGenerator::GenerateInitializationCode( } TProtoStringType RepeatedImmutableStringFieldLiteGenerator::GetBoxedType() const { - return "java.lang.String"; + return "java.lang.String"; } } // namespace java diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field_lite.h b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field_lite.h index f4ac150856..02cf5c1657 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field_lite.h +++ b/contrib/libs/protoc/src/google/protobuf/compiler/java/java_string_field_lite.h @@ -77,7 +77,7 @@ class ImmutableStringFieldLiteGenerator : public ImmutableFieldLiteGenerator { void GenerateKotlinDslMembers(io::Printer* printer) const override; TProtoStringType GetBoxedType() const override; - + protected: const FieldDescriptor* descriptor_; std::map<TProtoStringType, TProtoStringType> variables_; @@ -122,7 +122,7 @@ class RepeatedImmutableStringFieldLiteGenerator void GenerateKotlinDslMembers(io::Printer* printer) const override; TProtoStringType GetBoxedType() const override; - + private: const FieldDescriptor* descriptor_; std::map<TProtoStringType, TProtoStringType> variables_; diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/main.cc b/contrib/libs/protoc/src/google/protobuf/compiler/main.cc index 30ec358abb..10de997f0c 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/main.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/main.cc @@ -63,14 +63,14 @@ int ProtobufMain(int argc, char* argv[]) { // Proto2 Java java::JavaGenerator java_generator; - cli.RegisterGenerator("--java_out", "--java_opt", &java_generator, + cli.RegisterGenerator("--java_out", "--java_opt", &java_generator, "Generate Java source file."); // Proto2 Kotlin java::KotlinGenerator kt_generator; cli.RegisterGenerator("--kotlin_out", "--kotlin_opt", &kt_generator, "Generate Kotlin file."); - + // Proto2 Python python::Generator py_generator; diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/parser.cc b/contrib/libs/protoc/src/google/protobuf/compiler/parser.cc index e04c00a7d9..41d70aa255 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/parser.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/parser.cc @@ -673,7 +673,7 @@ bool Parser::Parse(io::Tokenizer* input, FileDescriptorProto* file) { input_ = NULL; source_code_info_ = NULL; - assert(file != NULL); + assert(file != NULL); source_code_info.Swap(file->mutable_source_code_info()); return !had_errors_; } @@ -810,7 +810,7 @@ bool Parser::ParseMessageDefinition( namespace { -const int kMaxRangeSentinel = -1; +const int kMaxRangeSentinel = -1; bool IsMessageSetWireFormatMessage(const DescriptorProto& message) { const MessageOptions& options = message.options(); @@ -834,27 +834,27 @@ void AdjustExtensionRangesWithMaxEndNumber(DescriptorProto* message) { ? std::numeric_limits<int32_t>::max() : FieldDescriptor::kMaxNumber + 1; for (int i = 0; i < message->extension_range_size(); ++i) { - if (message->extension_range(i).end() == kMaxRangeSentinel) { + if (message->extension_range(i).end() == kMaxRangeSentinel) { message->mutable_extension_range(i)->set_end(max_extension_number); } } } -// Modifies any reserved ranges that specified 'max' as the end of the -// reserved range, and sets them to the type-specific maximum. The actual max -// tag number can only be determined after all options have been parsed. -void AdjustReservedRangesWithMaxEndNumber(DescriptorProto* message) { - const bool is_message_set = IsMessageSetWireFormatMessage(*message); +// Modifies any reserved ranges that specified 'max' as the end of the +// reserved range, and sets them to the type-specific maximum. The actual max +// tag number can only be determined after all options have been parsed. +void AdjustReservedRangesWithMaxEndNumber(DescriptorProto* message) { + const bool is_message_set = IsMessageSetWireFormatMessage(*message); const int max_field_number = is_message_set ? std::numeric_limits<int32_t>::max() : FieldDescriptor::kMaxNumber + 1; - for (int i = 0; i < message->reserved_range_size(); ++i) { - if (message->reserved_range(i).end() == kMaxRangeSentinel) { - message->mutable_reserved_range(i)->set_end(max_field_number); - } - } -} - + for (int i = 0; i < message->reserved_range_size(); ++i) { + if (message->reserved_range(i).end() == kMaxRangeSentinel) { + message->mutable_reserved_range(i)->set_end(max_field_number); + } + } +} + } // namespace bool Parser::ParseMessageBlock(DescriptorProto* message, @@ -878,9 +878,9 @@ bool Parser::ParseMessageBlock(DescriptorProto* message, if (message->extension_range_size() > 0) { AdjustExtensionRangesWithMaxEndNumber(message); } - if (message->reserved_range_size() > 0) { - AdjustReservedRangesWithMaxEndNumber(message); - } + if (message->reserved_range_size() > 0) { + AdjustReservedRangesWithMaxEndNumber(message); + } return true; } @@ -1598,8 +1598,8 @@ bool Parser::ParseExtensions(DescriptorProto* message, // Parse the declaration. DO(Consume("extensions")); - int old_range_size = message->extension_range_size(); - + int old_range_size = message->extension_range_size(); + do { // Note that kExtensionRangeFieldNumber was already pushed by the parent. LocationRecorder location(extensions_location, @@ -1626,7 +1626,7 @@ bool Parser::ParseExtensions(DescriptorProto* message, // Set to the sentinel value - 1 since we increment the value below. // The actual value of the end of the range should be set with // AdjustExtensionRangesWithMaxEndNumber. - end = kMaxRangeSentinel - 1; + end = kMaxRangeSentinel - 1; } else { DO(ConsumeInteger(&end, "Expected integer.")); } @@ -1646,14 +1646,14 @@ bool Parser::ParseExtensions(DescriptorProto* message, range->set_end(end); } while (TryConsume(",")); - if (LookingAt("[")) { + if (LookingAt("[")) { int range_number_index = extensions_location.CurrentPathSize(); SourceCodeInfo info; - - // Parse extension range options in the first range. - ExtensionRangeOptions* options = - message->mutable_extension_range(old_range_size)->mutable_options(); - + + // Parse extension range options in the first range. + ExtensionRangeOptions* options = + message->mutable_extension_range(old_range_size)->mutable_options(); + { LocationRecorder index_location( extensions_location, 0 /* we fill this in w/ actual index below */, @@ -1661,7 +1661,7 @@ bool Parser::ParseExtensions(DescriptorProto* message, LocationRecorder location( index_location, DescriptorProto::ExtensionRange::kOptionsFieldNumber); DO(Consume("[")); - + do { DO(ParseOption(options, location, containing_file, OPTION_ASSIGNMENT)); } while (TryConsume(",")); @@ -1669,12 +1669,12 @@ bool Parser::ParseExtensions(DescriptorProto* message, DO(Consume("]")); } - // Then copy the extension range options to all of the other ranges we've - // parsed. - for (int i = old_range_size + 1; i < message->extension_range_size(); i++) { + // Then copy the extension range options to all of the other ranges we've + // parsed. + for (int i = old_range_size + 1; i < message->extension_range_size(); i++) { message->mutable_extension_range(i)->mutable_options()->CopyFrom( *options); - } + } // and copy source locations to the other ranges, too for (int i = old_range_size; i < message->extension_range_size(); i++) { for (int j = 0; j < info.location_size(); j++) { @@ -1688,14 +1688,14 @@ bool Parser::ParseExtensions(DescriptorProto* message, dest->set_path(range_number_index, i); } } - } - + } + DO(ConsumeEndOfDeclaration(";", &extensions_location)); return true; } -// This is similar to extension range parsing, except that it accepts field -// name literals. +// This is similar to extension range parsing, except that it accepts field +// name literals. bool Parser::ParseReserved(DescriptorProto* message, const LocationRecorder& message_location) { io::Tokenizer::Token start_token = input_->current(); @@ -1744,14 +1744,14 @@ bool Parser::ParseReservedNumbers(DescriptorProto* message, if (TryConsume("to")) { LocationRecorder end_location( location, DescriptorProto::ReservedRange::kEndFieldNumber); - if (TryConsume("max")) { - // Set to the sentinel value - 1 since we increment the value below. - // The actual value of the end of the range should be set with - // AdjustExtensionRangesWithMaxEndNumber. - end = kMaxRangeSentinel - 1; - } else { - DO(ConsumeInteger(&end, "Expected integer.")); - } + if (TryConsume("max")) { + // Set to the sentinel value - 1 since we increment the value below. + // The actual value of the end of the range should be set with + // AdjustExtensionRangesWithMaxEndNumber. + end = kMaxRangeSentinel - 1; + } else { + DO(ConsumeInteger(&end, "Expected integer.")); + } } else { LocationRecorder end_location( location, DescriptorProto::ReservedRange::kEndFieldNumber); diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/plugin.cc b/contrib/libs/protoc/src/google/protobuf/compiler/plugin.cc index e941cfc1fb..d05aef210a 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/plugin.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/plugin.cc @@ -62,11 +62,11 @@ using google::protobuf::io::win32::setmode; class GeneratorResponseContext : public GeneratorContext { public: - GeneratorResponseContext( + GeneratorResponseContext( const Version& compiler_version, CodeGeneratorResponse* response, - const std::vector<const FileDescriptor*>& parsed_files) - : compiler_version_(compiler_version), - response_(response), + const std::vector<const FileDescriptor*>& parsed_files) + : compiler_version_(compiler_version), + response_(response), parsed_files_(parsed_files) {} virtual ~GeneratorResponseContext() {} @@ -100,12 +100,12 @@ class GeneratorResponseContext : public GeneratorContext { *output = parsed_files_; } - void GetCompilerVersion(Version* version) const { - *version = compiler_version_; - } - + void GetCompilerVersion(Version* version) const { + *version = compiler_version_; + } + private: - Version compiler_version_; + Version compiler_version_; CodeGeneratorResponse* response_; const std::vector<const FileDescriptor*>& parsed_files_; }; @@ -137,21 +137,21 @@ bool GenerateCode(const CodeGeneratorRequest& request, GeneratorResponseContext context(request.compiler_version(), response, parsed_files); - + TProtoStringType error; bool succeeded = generator.GenerateAll(parsed_files, request.parameter(), &context, &error); response->set_supported_features(generator.GetSupportedFeatures()); - if (!succeeded && error.empty()) { + if (!succeeded && error.empty()) { error = "Code generator returned false but provided no error " "description."; } - if (!error.empty()) { - response->set_error(error); - } + if (!error.empty()) { + response->set_error(error); + } return true; } @@ -164,8 +164,8 @@ int PluginMain(int argc, char* argv[], const CodeGenerator* generator) { } #ifdef _WIN32 - setmode(STDIN_FILENO, _O_BINARY); - setmode(STDOUT_FILENO, _O_BINARY); + setmode(STDIN_FILENO, _O_BINARY); + setmode(STDOUT_FILENO, _O_BINARY); #endif CodeGeneratorRequest request; diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/plugin.pb.cc b/contrib/libs/protoc/src/google/protobuf/compiler/plugin.pb.cc index 4f17591b3b..f66f854fe9 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/plugin.pb.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/plugin.pb.cc @@ -31,7 +31,7 @@ struct VersionDefaultTypeInternal { union { Version _instance; }; -}; +}; PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT VersionDefaultTypeInternal _Version_default_instance_; constexpr CodeGeneratorRequest::CodeGeneratorRequest( ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) @@ -46,7 +46,7 @@ struct CodeGeneratorRequestDefaultTypeInternal { union { CodeGeneratorRequest _instance; }; -}; +}; PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT CodeGeneratorRequestDefaultTypeInternal _CodeGeneratorRequest_default_instance_; constexpr CodeGeneratorResponse_File::CodeGeneratorResponse_File( ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) @@ -61,7 +61,7 @@ struct CodeGeneratorResponse_FileDefaultTypeInternal { union { CodeGeneratorResponse_File _instance; }; -}; +}; PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT CodeGeneratorResponse_FileDefaultTypeInternal _CodeGeneratorResponse_File_default_instance_; constexpr CodeGeneratorResponse::CodeGeneratorResponse( ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) @@ -82,73 +82,73 @@ PROTOBUF_NAMESPACE_CLOSE static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_google_2fprotobuf_2fcompiler_2fplugin_2eproto[4]; static const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* file_level_enum_descriptors_google_2fprotobuf_2fcompiler_2fplugin_2eproto[1]; static constexpr ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2fcompiler_2fplugin_2eproto = nullptr; - + const ::PROTOBUF_NAMESPACE_ID::uint32 TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { PROTOBUF_FIELD_OFFSET(PROTOBUF_NAMESPACE_ID::compiler::Version, _has_bits_), PROTOBUF_FIELD_OFFSET(PROTOBUF_NAMESPACE_ID::compiler::Version, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ PROTOBUF_FIELD_OFFSET(PROTOBUF_NAMESPACE_ID::compiler::Version, major_), PROTOBUF_FIELD_OFFSET(PROTOBUF_NAMESPACE_ID::compiler::Version, minor_), PROTOBUF_FIELD_OFFSET(PROTOBUF_NAMESPACE_ID::compiler::Version, patch_), PROTOBUF_FIELD_OFFSET(PROTOBUF_NAMESPACE_ID::compiler::Version, suffix_), - 1, - 2, - 3, - 0, + 1, + 2, + 3, + 0, PROTOBUF_FIELD_OFFSET(PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest, _has_bits_), PROTOBUF_FIELD_OFFSET(PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ PROTOBUF_FIELD_OFFSET(PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest, file_to_generate_), PROTOBUF_FIELD_OFFSET(PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest, parameter_), PROTOBUF_FIELD_OFFSET(PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest, proto_file_), PROTOBUF_FIELD_OFFSET(PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest, compiler_version_), - ~0u, - 0, - ~0u, - 1, + ~0u, + 0, + ~0u, + 1, PROTOBUF_FIELD_OFFSET(PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File, _has_bits_), PROTOBUF_FIELD_OFFSET(PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ PROTOBUF_FIELD_OFFSET(PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File, name_), PROTOBUF_FIELD_OFFSET(PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File, insertion_point_), PROTOBUF_FIELD_OFFSET(PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File, content_), PROTOBUF_FIELD_OFFSET(PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File, generated_code_info_), - 0, - 1, - 2, + 0, + 1, + 2, 3, PROTOBUF_FIELD_OFFSET(PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse, _has_bits_), PROTOBUF_FIELD_OFFSET(PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ PROTOBUF_FIELD_OFFSET(PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse, error_), PROTOBUF_FIELD_OFFSET(PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse, supported_features_), PROTOBUF_FIELD_OFFSET(PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse, file_), - 0, + 0, 1, - ~0u, -}; + ~0u, +}; static const ::PROTOBUF_NAMESPACE_ID::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { { 0, 9, sizeof(PROTOBUF_NAMESPACE_ID::compiler::Version)}, { 13, 22, sizeof(PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest)}, { 26, 35, sizeof(PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File)}, { 39, 47, sizeof(PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse)}, -}; +}; static ::PROTOBUF_NAMESPACE_ID::Message const * const file_default_instances[] = { reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&PROTOBUF_NAMESPACE_ID::compiler::_Version_default_instance_), reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&PROTOBUF_NAMESPACE_ID::compiler::_CodeGeneratorRequest_default_instance_), reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&PROTOBUF_NAMESPACE_ID::compiler::_CodeGeneratorResponse_File_default_instance_), reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&PROTOBUF_NAMESPACE_ID::compiler::_CodeGeneratorResponse_default_instance_), -}; - +}; + const char descriptor_table_protodef_google_2fprotobuf_2fcompiler_2fplugin_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = "\n%google/protobuf/compiler/plugin.proto\022" "\030google.protobuf.compiler\032 google/protob" @@ -183,8 +183,8 @@ const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google }; PROTOBUF_ATTRIBUTE_WEAK const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable* descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_getter() { return &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto; -} - +} + // Force running AddDescriptors() at dynamic initialization time. PROTOBUF_ATTRIBUTE_INIT_PRIORITY static ::PROTOBUF_NAMESPACE_ID::internal::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2fcompiler_2fplugin_2eproto(&descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto); PROTOBUF_NAMESPACE_OPEN @@ -212,7 +212,7 @@ constexpr int CodeGeneratorResponse::Feature_ARRAYSIZE; #endif // (__cplusplus < 201703) && (!defined(_MSC_VER) || _MSC_VER >= 1900) // =================================================================== - + class Version::_Internal { public: using HasBits = decltype(std::declval<Version>()._has_bits_); @@ -233,13 +233,13 @@ class Version::_Internal { Version::Version(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { - SharedCtor(); + SharedCtor(); if (!is_message_owned) { RegisterArenaDtor(arena); } // @@protoc_insertion_point(arena_constructor:google.protobuf.compiler.Version) -} -Version::Version(const Version& from) +} +Version::Version(const Version& from) : ::PROTOBUF_NAMESPACE_ID::Message(), _has_bits_(from._has_bits_) { _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); @@ -247,62 +247,62 @@ Version::Version(const Version& from) if (from._internal_has_suffix()) { suffix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_suffix(), GetArenaForAllocation()); - } - ::memcpy(&major_, &from.major_, - static_cast<size_t>(reinterpret_cast<char*>(&patch_) - - reinterpret_cast<char*>(&major_)) + sizeof(patch_)); - // @@protoc_insertion_point(copy_constructor:google.protobuf.compiler.Version) -} - -void Version::SharedCtor() { + } + ::memcpy(&major_, &from.major_, + static_cast<size_t>(reinterpret_cast<char*>(&patch_) - + reinterpret_cast<char*>(&major_)) + sizeof(patch_)); + // @@protoc_insertion_point(copy_constructor:google.protobuf.compiler.Version) +} + +void Version::SharedCtor() { suffix_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); ::memset(reinterpret_cast<char*>(this) + static_cast<size_t>( reinterpret_cast<char*>(&major_) - reinterpret_cast<char*>(this)), 0, static_cast<size_t>(reinterpret_cast<char*>(&patch_) - reinterpret_cast<char*>(&major_)) + sizeof(patch_)); -} - -Version::~Version() { - // @@protoc_insertion_point(destructor:google.protobuf.compiler.Version) +} + +Version::~Version() { + // @@protoc_insertion_point(destructor:google.protobuf.compiler.Version) if (GetArenaForAllocation() != nullptr) return; - SharedDtor(); + SharedDtor(); _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); -} - +} + inline void Version::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); suffix_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); -} - +} + void Version::ArenaDtor(void* object) { Version* _this = reinterpret_cast< Version* >(object); (void)_this; -} +} void Version::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { -} +} void Version::SetCachedSize(int size) const { _cached_size_.Set(size); -} - -void Version::Clear() { -// @@protoc_insertion_point(message_clear_start:google.protobuf.compiler.Version) +} + +void Version::Clear() { +// @@protoc_insertion_point(message_clear_start:google.protobuf.compiler.Version) ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + cached_has_bits = _has_bits_[0]; if (cached_has_bits & 0x00000001u) { suffix_.ClearNonDefaultToEmpty(); - } + } if (cached_has_bits & 0x0000000eu) { - ::memset(&major_, 0, static_cast<size_t>( - reinterpret_cast<char*>(&patch_) - - reinterpret_cast<char*>(&major_)) + sizeof(patch_)); - } - _has_bits_.Clear(); + ::memset(&major_, 0, static_cast<size_t>( + reinterpret_cast<char*>(&patch_) - + reinterpret_cast<char*>(&major_)) + sizeof(patch_)); + } + _has_bits_.Clear(); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); -} - +} + const char* Version::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { #define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure _Internal::HasBits has_bits{}; @@ -310,7 +310,7 @@ const char* Version::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::in ::PROTOBUF_NAMESPACE_ID::uint32 tag; ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); switch (tag >> 3) { - // optional int32 major = 1; + // optional int32 major = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 8)) { _Internal::set_has_major(&has_bits); @@ -318,7 +318,7 @@ const char* Version::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::in CHK_(ptr); } else goto handle_unusual; continue; - // optional int32 minor = 2; + // optional int32 minor = 2; case 2: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 16)) { _Internal::set_has_minor(&has_bits); @@ -326,7 +326,7 @@ const char* Version::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::in CHK_(ptr); } else goto handle_unusual; continue; - // optional int32 patch = 3; + // optional int32 patch = 3; case 3: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 24)) { _Internal::set_has_patch(&has_bits); @@ -334,7 +334,7 @@ const char* Version::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::in CHK_(ptr); } else goto handle_unusual; continue; - // optional string suffix = 4; + // optional string suffix = 4; case 4: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 34)) { auto str = _internal_mutable_suffix(); @@ -345,121 +345,121 @@ const char* Version::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::in CHK_(ptr); } else goto handle_unusual; continue; - default: { - handle_unusual: + default: { + handle_unusual: if ((tag == 0) || ((tag & 7) == 4)) { CHK_(ptr); ctx->SetLastTag(tag); - goto success; - } + goto success; + } ptr = UnknownFieldParse(tag, _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), ptr, ctx); CHK_(ptr != nullptr); continue; - } + } } // switch } // while -success: +success: _has_bits_.Or(has_bits); return ptr; -failure: +failure: ptr = nullptr; goto success; #undef CHK_ -} - +} + ::PROTOBUF_NAMESPACE_ID::uint8* Version::_InternalSerialize( ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { - // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.compiler.Version) + // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.compiler.Version) ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - (void) cached_has_bits; - - cached_has_bits = _has_bits_[0]; - // optional int32 major = 1; - if (cached_has_bits & 0x00000002u) { + (void) cached_has_bits; + + cached_has_bits = _has_bits_[0]; + // optional int32 major = 1; + if (cached_has_bits & 0x00000002u) { target = stream->EnsureSpace(target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(1, this->_internal_major(), target); - } - - // optional int32 minor = 2; - if (cached_has_bits & 0x00000004u) { + } + + // optional int32 minor = 2; + if (cached_has_bits & 0x00000004u) { target = stream->EnsureSpace(target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(2, this->_internal_minor(), target); - } - - // optional int32 patch = 3; - if (cached_has_bits & 0x00000008u) { + } + + // optional int32 patch = 3; + if (cached_has_bits & 0x00000008u) { target = stream->EnsureSpace(target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(3, this->_internal_patch(), target); - } - - // optional string suffix = 4; - if (cached_has_bits & 0x00000001u) { + } + + // optional string suffix = 4; + if (cached_has_bits & 0x00000001u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( this->_internal_suffix().data(), static_cast<int>(this->_internal_suffix().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, - "google.protobuf.compiler.Version.suffix"); + "google.protobuf.compiler.Version.suffix"); target = stream->WriteStringMaybeAliased( 4, this->_internal_suffix(), target); - } - + } + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); - } - // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.compiler.Version) - return target; -} - -size_t Version::ByteSizeLong() const { -// @@protoc_insertion_point(message_byte_size_start:google.protobuf.compiler.Version) - size_t total_size = 0; - + } + // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.compiler.Version) + return target; +} + +size_t Version::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:google.protobuf.compiler.Version) + size_t total_size = 0; + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; cached_has_bits = _has_bits_[0]; if (cached_has_bits & 0x0000000fu) { - // optional string suffix = 4; + // optional string suffix = 4; if (cached_has_bits & 0x00000001u) { - total_size += 1 + + total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( this->_internal_suffix()); - } - - // optional int32 major = 1; + } + + // optional int32 major = 1; if (cached_has_bits & 0x00000002u) { - total_size += 1 + + total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size( this->_internal_major()); - } - - // optional int32 minor = 2; + } + + // optional int32 minor = 2; if (cached_has_bits & 0x00000004u) { - total_size += 1 + + total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size( this->_internal_minor()); - } - - // optional int32 patch = 3; + } + + // optional int32 patch = 3; if (cached_has_bits & 0x00000008u) { - total_size += 1 + + total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size( this->_internal_patch()); - } - - } + } + + } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( _internal_metadata_, total_size, &_cached_size_); } int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); SetCachedSize(cached_size); - return total_size; -} - + return total_size; +} + const ::PROTOBUF_NAMESPACE_ID::Message::ClassData Version::_class_data_ = { ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSizeCheck, Version::MergeImpl @@ -470,49 +470,49 @@ void Version::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message*to, const ::PROTOBUF_NAMESPACE_ID::Message&from) { static_cast<Version *>(to)->MergeFrom( static_cast<const Version &>(from)); -} - +} -void Version::MergeFrom(const Version& from) { -// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.Version) - GOOGLE_DCHECK_NE(&from, this); + +void Version::MergeFrom(const Version& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.Version) + GOOGLE_DCHECK_NE(&from, this); ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - (void) cached_has_bits; - - cached_has_bits = from._has_bits_[0]; + (void) cached_has_bits; + + cached_has_bits = from._has_bits_[0]; if (cached_has_bits & 0x0000000fu) { - if (cached_has_bits & 0x00000001u) { + if (cached_has_bits & 0x00000001u) { _internal_set_suffix(from._internal_suffix()); - } - if (cached_has_bits & 0x00000002u) { - major_ = from.major_; - } - if (cached_has_bits & 0x00000004u) { - minor_ = from.minor_; - } - if (cached_has_bits & 0x00000008u) { - patch_ = from.patch_; - } - _has_bits_[0] |= cached_has_bits; - } + } + if (cached_has_bits & 0x00000002u) { + major_ = from.major_; + } + if (cached_has_bits & 0x00000004u) { + minor_ = from.minor_; + } + if (cached_has_bits & 0x00000008u) { + patch_ = from.patch_; + } + _has_bits_[0] |= cached_has_bits; + } _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); -} - -void Version::CopyFrom(const Version& from) { -// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.compiler.Version) - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool Version::IsInitialized() const { - return true; -} - -void Version::InternalSwap(Version* other) { - using std::swap; +} + +void Version::CopyFrom(const Version& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.compiler.Version) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool Version::IsInitialized() const { + return true; +} + +void Version::InternalSwap(Version* other) { + using std::swap; _internal_metadata_.InternalSwap(&other->_internal_metadata_); - swap(_has_bits_[0], other->_has_bits_[0]); + swap(_has_bits_[0], other->_has_bits_[0]); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), &suffix_, GetArenaForAllocation(), @@ -524,16 +524,16 @@ void Version::InternalSwap(Version* other) { - PROTOBUF_FIELD_OFFSET(Version, major_)>( reinterpret_cast<char*>(&major_), reinterpret_cast<char*>(&other->major_)); -} - +} + ::PROTOBUF_NAMESPACE_ID::Metadata Version::GetMetadata() const { return ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors( &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_getter, &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once, file_level_metadata_google_2fprotobuf_2fcompiler_2fplugin_2eproto[0]); -} - +} + // =================================================================== - + class CodeGeneratorRequest::_Internal { public: using HasBits = decltype(std::declval<CodeGeneratorRequest>()._has_bits_); @@ -545,14 +545,14 @@ class CodeGeneratorRequest::_Internal { (*has_bits)[0] |= 2u; } }; - + const PROTOBUF_NAMESPACE_ID::compiler::Version& CodeGeneratorRequest::_Internal::compiler_version(const CodeGeneratorRequest* msg) { return *msg->compiler_version_; -} +} void CodeGeneratorRequest::clear_proto_file() { proto_file_.Clear(); -} +} CodeGeneratorRequest::CodeGeneratorRequest(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned), @@ -566,20 +566,20 @@ CodeGeneratorRequest::CodeGeneratorRequest(::PROTOBUF_NAMESPACE_ID::Arena* arena } CodeGeneratorRequest::CodeGeneratorRequest(const CodeGeneratorRequest& from) : ::PROTOBUF_NAMESPACE_ID::Message(), - _has_bits_(from._has_bits_), - file_to_generate_(from.file_to_generate_), - proto_file_(from.proto_file_) { + _has_bits_(from._has_bits_), + file_to_generate_(from.file_to_generate_), + proto_file_(from.proto_file_) { _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); parameter_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_parameter()) { parameter_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_parameter(), GetArenaForAllocation()); - } + } if (from._internal_has_compiler_version()) { compiler_version_ = new PROTOBUF_NAMESPACE_ID::compiler::Version(*from.compiler_version_); - } else { + } else { compiler_version_ = nullptr; - } + } // @@protoc_insertion_point(copy_constructor:google.protobuf.compiler.CodeGeneratorRequest) } @@ -598,7 +598,7 @@ CodeGeneratorRequest::~CodeGeneratorRequest() { inline void CodeGeneratorRequest::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); parameter_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - if (this != internal_default_instance()) delete compiler_version_; + if (this != internal_default_instance()) delete compiler_version_; } void CodeGeneratorRequest::ArenaDtor(void* object) { @@ -614,22 +614,22 @@ void CodeGeneratorRequest::SetCachedSize(int size) const { void CodeGeneratorRequest::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.compiler.CodeGeneratorRequest) ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + file_to_generate_.Clear(); proto_file_.Clear(); - cached_has_bits = _has_bits_[0]; + cached_has_bits = _has_bits_[0]; if (cached_has_bits & 0x00000003u) { - if (cached_has_bits & 0x00000001u) { + if (cached_has_bits & 0x00000001u) { parameter_.ClearNonDefaultToEmpty(); - } - if (cached_has_bits & 0x00000002u) { + } + if (cached_has_bits & 0x00000002u) { GOOGLE_DCHECK(compiler_version_ != nullptr); compiler_version_->Clear(); - } - } - _has_bits_.Clear(); + } + } + _has_bits_.Clear(); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } @@ -667,7 +667,7 @@ const char* CodeGeneratorRequest::_InternalParse(const char* ptr, ::PROTOBUF_NAM CHK_(ptr); } else goto handle_unusual; continue; - // optional .google.protobuf.compiler.Version compiler_version = 3; + // optional .google.protobuf.compiler.Version compiler_version = 3; case 3: if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 26)) { ptr = ctx->ParseMessage(_internal_mutable_compiler_version(), ptr); @@ -714,8 +714,8 @@ failure: ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.compiler.CodeGeneratorRequest) ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - (void) cached_has_bits; - + (void) cached_has_bits; + // repeated string file_to_generate = 1; for (int i = 0, n = this->_internal_file_to_generate_size(); i < n; i++) { const auto& s = this->_internal_file_to_generate(i); @@ -726,9 +726,9 @@ failure: target = stream->WriteString(1, s, target); } - cached_has_bits = _has_bits_[0]; + cached_has_bits = _has_bits_[0]; // optional string parameter = 2; - if (cached_has_bits & 0x00000001u) { + if (cached_has_bits & 0x00000001u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( this->_internal_parameter().data(), static_cast<int>(this->_internal_parameter().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, @@ -737,16 +737,16 @@ failure: 2, this->_internal_parameter(), target); } - // optional .google.protobuf.compiler.Version compiler_version = 3; - if (cached_has_bits & 0x00000002u) { + // optional .google.protobuf.compiler.Version compiler_version = 3; + if (cached_has_bits & 0x00000002u) { target = stream->EnsureSpace(target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessage( 3, _Internal::compiler_version(this), target, stream); - } - + } + // repeated .google.protobuf.FileDescriptorProto proto_file = 15; - for (unsigned int i = 0, + for (unsigned int i = 0, n = static_cast<unsigned int>(this->_internal_proto_file_size()); i < n; i++) { target = stream->EnsureSpace(target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: @@ -761,16 +761,16 @@ failure: return target; } -size_t CodeGeneratorRequest::ByteSizeLong() const { +size_t CodeGeneratorRequest::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.compiler.CodeGeneratorRequest) - size_t total_size = 0; + size_t total_size = 0; ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; // repeated string file_to_generate = 1; - total_size += 1 * + total_size += 1 * ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(file_to_generate_.size()); for (int i = 0, n = file_to_generate_.size(); i < n; i++) { total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( @@ -786,20 +786,20 @@ size_t CodeGeneratorRequest::ByteSizeLong() const { cached_has_bits = _has_bits_[0]; if (cached_has_bits & 0x00000003u) { - // optional string parameter = 2; + // optional string parameter = 2; if (cached_has_bits & 0x00000001u) { - total_size += 1 + + total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( this->_internal_parameter()); - } - - // optional .google.protobuf.compiler.Version compiler_version = 3; + } + + // optional .google.protobuf.compiler.Version compiler_version = 3; if (cached_has_bits & 0x00000002u) { - total_size += 1 + + total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( *compiler_version_); - } - + } + } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( @@ -825,20 +825,20 @@ void CodeGeneratorRequest::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message*to, void CodeGeneratorRequest::MergeFrom(const CodeGeneratorRequest& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.CodeGeneratorRequest) - GOOGLE_DCHECK_NE(&from, this); + GOOGLE_DCHECK_NE(&from, this); ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - (void) cached_has_bits; - - file_to_generate_.MergeFrom(from.file_to_generate_); + (void) cached_has_bits; + + file_to_generate_.MergeFrom(from.file_to_generate_); proto_file_.MergeFrom(from.proto_file_); - cached_has_bits = from._has_bits_[0]; + cached_has_bits = from._has_bits_[0]; if (cached_has_bits & 0x00000003u) { - if (cached_has_bits & 0x00000001u) { + if (cached_has_bits & 0x00000001u) { _internal_set_parameter(from._internal_parameter()); } - if (cached_has_bits & 0x00000002u) { + if (cached_has_bits & 0x00000002u) { _internal_mutable_compiler_version()->PROTOBUF_NAMESPACE_ID::compiler::Version::MergeFrom(from._internal_compiler_version()); - } + } } _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } @@ -847,7 +847,7 @@ void CodeGeneratorRequest::CopyFrom(const CodeGeneratorRequest& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.compiler.CodeGeneratorRequest) if (&from == this) return; Clear(); - MergeFrom(from); + MergeFrom(from); } bool CodeGeneratorRequest::IsInitialized() const { @@ -856,17 +856,17 @@ bool CodeGeneratorRequest::IsInitialized() const { } void CodeGeneratorRequest::InternalSwap(CodeGeneratorRequest* other) { - using std::swap; + using std::swap; _internal_metadata_.InternalSwap(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); - file_to_generate_.InternalSwap(&other->file_to_generate_); - proto_file_.InternalSwap(&other->proto_file_); + file_to_generate_.InternalSwap(&other->file_to_generate_); + proto_file_.InternalSwap(&other->proto_file_); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ¶meter_, GetArenaForAllocation(), &other->parameter_, other->GetArenaForAllocation() ); - swap(compiler_version_, other->compiler_version_); + swap(compiler_version_, other->compiler_version_); } ::PROTOBUF_NAMESPACE_ID::Metadata CodeGeneratorRequest::GetMetadata() const { @@ -920,17 +920,17 @@ CodeGeneratorResponse_File::CodeGeneratorResponse_File(const CodeGeneratorRespon if (from._internal_has_name()) { name_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_name(), GetArenaForAllocation()); - } + } insertion_point_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_insertion_point()) { insertion_point_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_insertion_point(), GetArenaForAllocation()); - } + } content_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_content()) { content_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_content(), GetArenaForAllocation()); - } + } if (from._internal_has_generated_code_info()) { generated_code_info_ = new PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo(*from.generated_code_info_); } else { @@ -974,18 +974,18 @@ void CodeGeneratorResponse_File::SetCachedSize(int size) const { void CodeGeneratorResponse_File::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.compiler.CodeGeneratorResponse.File) ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - cached_has_bits = _has_bits_[0]; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + cached_has_bits = _has_bits_[0]; if (cached_has_bits & 0x0000000fu) { - if (cached_has_bits & 0x00000001u) { + if (cached_has_bits & 0x00000001u) { name_.ClearNonDefaultToEmpty(); } - if (cached_has_bits & 0x00000002u) { + if (cached_has_bits & 0x00000002u) { insertion_point_.ClearNonDefaultToEmpty(); } - if (cached_has_bits & 0x00000004u) { + if (cached_has_bits & 0x00000004u) { content_.ClearNonDefaultToEmpty(); } if (cached_has_bits & 0x00000008u) { @@ -993,7 +993,7 @@ void CodeGeneratorResponse_File::Clear() { generated_code_info_->Clear(); } } - _has_bits_.Clear(); + _has_bits_.Clear(); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } @@ -1072,11 +1072,11 @@ failure: ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.compiler.CodeGeneratorResponse.File) ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - (void) cached_has_bits; - - cached_has_bits = _has_bits_[0]; + (void) cached_has_bits; + + cached_has_bits = _has_bits_[0]; // optional string name = 1; - if (cached_has_bits & 0x00000001u) { + if (cached_has_bits & 0x00000001u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( this->_internal_name().data(), static_cast<int>(this->_internal_name().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, @@ -1086,7 +1086,7 @@ failure: } // optional string insertion_point = 2; - if (cached_has_bits & 0x00000002u) { + if (cached_has_bits & 0x00000002u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( this->_internal_insertion_point().data(), static_cast<int>(this->_internal_insertion_point().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, @@ -1096,7 +1096,7 @@ failure: } // optional string content = 15; - if (cached_has_bits & 0x00000004u) { + if (cached_has_bits & 0x00000004u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( this->_internal_content().data(), static_cast<int>(this->_internal_content().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, @@ -1121,9 +1121,9 @@ failure: return target; } -size_t CodeGeneratorResponse_File::ByteSizeLong() const { +size_t CodeGeneratorResponse_File::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.compiler.CodeGeneratorResponse.File) - size_t total_size = 0; + size_t total_size = 0; ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused @@ -1184,19 +1184,19 @@ void CodeGeneratorResponse_File::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message*to, void CodeGeneratorResponse_File::MergeFrom(const CodeGeneratorResponse_File& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.CodeGeneratorResponse.File) - GOOGLE_DCHECK_NE(&from, this); + GOOGLE_DCHECK_NE(&from, this); ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - (void) cached_has_bits; - - cached_has_bits = from._has_bits_[0]; + (void) cached_has_bits; + + cached_has_bits = from._has_bits_[0]; if (cached_has_bits & 0x0000000fu) { - if (cached_has_bits & 0x00000001u) { + if (cached_has_bits & 0x00000001u) { _internal_set_name(from._internal_name()); } - if (cached_has_bits & 0x00000002u) { + if (cached_has_bits & 0x00000002u) { _internal_set_insertion_point(from._internal_insertion_point()); } - if (cached_has_bits & 0x00000004u) { + if (cached_has_bits & 0x00000004u) { _internal_set_content(from._internal_content()); } if (cached_has_bits & 0x00000008u) { @@ -1210,7 +1210,7 @@ void CodeGeneratorResponse_File::CopyFrom(const CodeGeneratorResponse_File& from // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.compiler.CodeGeneratorResponse.File) if (&from == this) return; Clear(); - MergeFrom(from); + MergeFrom(from); } bool CodeGeneratorResponse_File::IsInitialized() const { @@ -1218,9 +1218,9 @@ bool CodeGeneratorResponse_File::IsInitialized() const { } void CodeGeneratorResponse_File::InternalSwap(CodeGeneratorResponse_File* other) { - using std::swap; + using std::swap; _internal_metadata_.InternalSwap(&other->_internal_metadata_); - swap(_has_bits_[0], other->_has_bits_[0]); + swap(_has_bits_[0], other->_has_bits_[0]); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), &name_, GetArenaForAllocation(), @@ -1252,12 +1252,12 @@ class CodeGeneratorResponse::_Internal { using HasBits = decltype(std::declval<CodeGeneratorResponse>()._has_bits_); static void set_has_error(HasBits* has_bits) { (*has_bits)[0] |= 1u; - } + } static void set_has_supported_features(HasBits* has_bits) { (*has_bits)[0] |= 2u; - } + } }; - + CodeGeneratorResponse::CodeGeneratorResponse(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned), @@ -1270,14 +1270,14 @@ CodeGeneratorResponse::CodeGeneratorResponse(::PROTOBUF_NAMESPACE_ID::Arena* are } CodeGeneratorResponse::CodeGeneratorResponse(const CodeGeneratorResponse& from) : ::PROTOBUF_NAMESPACE_ID::Message(), - _has_bits_(from._has_bits_), - file_(from.file_) { + _has_bits_(from._has_bits_), + file_(from.file_) { _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); error_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); if (from._internal_has_error()) { error_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_error(), GetArenaForAllocation()); - } + } supported_features_ = from.supported_features_; // @@protoc_insertion_point(copy_constructor:google.protobuf.compiler.CodeGeneratorResponse) } @@ -1312,16 +1312,16 @@ void CodeGeneratorResponse::SetCachedSize(int size) const { void CodeGeneratorResponse::Clear() { // @@protoc_insertion_point(message_clear_start:google.protobuf.compiler.CodeGeneratorResponse) ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - // Prevent compiler warnings about cached_has_bits being unused - (void) cached_has_bits; - - file_.Clear(); + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + file_.Clear(); cached_has_bits = _has_bits_[0]; if (cached_has_bits & 0x00000001u) { error_.ClearNonDefaultToEmpty(); } supported_features_ = uint64_t{0u}; - _has_bits_.Clear(); + _has_bits_.Clear(); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } @@ -1391,11 +1391,11 @@ failure: ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.compiler.CodeGeneratorResponse) ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - (void) cached_has_bits; - - cached_has_bits = _has_bits_[0]; + (void) cached_has_bits; + + cached_has_bits = _has_bits_[0]; // optional string error = 1; - if (cached_has_bits & 0x00000001u) { + if (cached_has_bits & 0x00000001u) { ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField( this->_internal_error().data(), static_cast<int>(this->_internal_error().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE, @@ -1411,7 +1411,7 @@ failure: } // repeated .google.protobuf.compiler.CodeGeneratorResponse.File file = 15; - for (unsigned int i = 0, + for (unsigned int i = 0, n = static_cast<unsigned int>(this->_internal_file_size()); i < n; i++) { target = stream->EnsureSpace(target); target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: @@ -1426,9 +1426,9 @@ failure: return target; } -size_t CodeGeneratorResponse::ByteSizeLong() const { +size_t CodeGeneratorResponse::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.protobuf.compiler.CodeGeneratorResponse) - size_t total_size = 0; + size_t total_size = 0; ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused @@ -1437,7 +1437,7 @@ size_t CodeGeneratorResponse::ByteSizeLong() const { // repeated .google.protobuf.compiler.CodeGeneratorResponse.File file = 15; total_size += 1UL * this->_internal_file_size(); for (const auto& msg : this->file_) { - total_size += + total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg); } @@ -1448,7 +1448,7 @@ size_t CodeGeneratorResponse::ByteSizeLong() const { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( this->_internal_error()); - } + } // optional uint64 supported_features = 2; if (cached_has_bits & 0x00000002u) { @@ -1482,10 +1482,10 @@ void CodeGeneratorResponse::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message*to, void CodeGeneratorResponse::MergeFrom(const CodeGeneratorResponse& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.CodeGeneratorResponse) - GOOGLE_DCHECK_NE(&from, this); + GOOGLE_DCHECK_NE(&from, this); ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; - (void) cached_has_bits; - + (void) cached_has_bits; + file_.MergeFrom(from.file_); cached_has_bits = from._has_bits_[0]; if (cached_has_bits & 0x00000003u) { @@ -1504,7 +1504,7 @@ void CodeGeneratorResponse::CopyFrom(const CodeGeneratorResponse& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.compiler.CodeGeneratorResponse) if (&from == this) return; Clear(); - MergeFrom(from); + MergeFrom(from); } bool CodeGeneratorResponse::IsInitialized() const { @@ -1512,10 +1512,10 @@ bool CodeGeneratorResponse::IsInitialized() const { } void CodeGeneratorResponse::InternalSwap(CodeGeneratorResponse* other) { - using std::swap; + using std::swap; _internal_metadata_.InternalSwap(&other->_internal_metadata_); swap(_has_bits_[0], other->_has_bits_[0]); - file_.InternalSwap(&other->file_); + file_.InternalSwap(&other->file_); ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), &error_, GetArenaForAllocation(), diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/plugin.pb.h b/contrib/libs/protoc/src/google/protobuf/compiler/plugin.pb.h index 8c20fd7cad..6da6c31dad 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/plugin.pb.h +++ b/contrib/libs/protoc/src/google/protobuf/compiler/plugin.pb.h @@ -36,12 +36,12 @@ // @@protoc_insertion_point(includes) #include <google/protobuf/port_def.inc> #define PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fcompiler_2fplugin_2eproto PROTOC_EXPORT -#ifdef major -#undef major -#endif -#ifdef minor -#undef minor -#endif +#ifdef major +#undef major +#endif +#ifdef minor +#undef minor +#endif PROTOBUF_NAMESPACE_OPEN namespace internal { class AnyMetadata; @@ -62,20 +62,20 @@ struct PROTOC_EXPORT TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto { }; PROTOC_EXPORT extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto; PROTOBUF_NAMESPACE_OPEN -namespace compiler { -class CodeGeneratorRequest; +namespace compiler { +class CodeGeneratorRequest; struct CodeGeneratorRequestDefaultTypeInternal; PROTOC_EXPORT extern CodeGeneratorRequestDefaultTypeInternal _CodeGeneratorRequest_default_instance_; -class CodeGeneratorResponse; +class CodeGeneratorResponse; struct CodeGeneratorResponseDefaultTypeInternal; PROTOC_EXPORT extern CodeGeneratorResponseDefaultTypeInternal _CodeGeneratorResponse_default_instance_; -class CodeGeneratorResponse_File; +class CodeGeneratorResponse_File; struct CodeGeneratorResponse_FileDefaultTypeInternal; PROTOC_EXPORT extern CodeGeneratorResponse_FileDefaultTypeInternal _CodeGeneratorResponse_File_default_instance_; -class Version; +class Version; struct VersionDefaultTypeInternal; PROTOC_EXPORT extern VersionDefaultTypeInternal _Version_default_instance_; -} // namespace compiler +} // namespace compiler PROTOBUF_NAMESPACE_CLOSE PROTOBUF_NAMESPACE_OPEN template<> PROTOC_EXPORT PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest* Arena::CreateMaybeMessage<PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest>(Arena*); @@ -89,7 +89,7 @@ namespace compiler { enum CodeGeneratorResponse_Feature : int { CodeGeneratorResponse_Feature_FEATURE_NONE = 0, CodeGeneratorResponse_Feature_FEATURE_PROTO3_OPTIONAL = 1 -}; +}; PROTOC_EXPORT bool CodeGeneratorResponse_Feature_IsValid(int value); constexpr CodeGeneratorResponse_Feature CodeGeneratorResponse_Feature_Feature_MIN = CodeGeneratorResponse_Feature_FEATURE_NONE; constexpr CodeGeneratorResponse_Feature CodeGeneratorResponse_Feature_Feature_MAX = CodeGeneratorResponse_Feature_FEATURE_PROTO3_OPTIONAL; @@ -113,38 +113,38 @@ inline bool CodeGeneratorResponse_Feature_Parse( class PROTOC_EXPORT Version final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.Version) */ { - public: + public: inline Version() : Version(nullptr) {} ~Version() override; explicit constexpr Version(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); - - Version(const Version& from); + + Version(const Version& from); Version(Version&& from) noexcept : Version() { *this = ::std::move(from); } - - inline Version& operator=(const Version& from) { - CopyFrom(from); - return *this; - } - inline Version& operator=(Version&& from) noexcept { + + inline Version& operator=(const Version& from) { + CopyFrom(from); + return *this; + } + inline Version& operator=(Version&& from) noexcept { if (this == &from) return *this; if (GetOwningArena() == from.GetOwningArena()) { InternalSwap(&from); - } else { - CopyFrom(from); - } - return *this; - } + } else { + CopyFrom(from); + } + return *this; + } inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); - } + } inline ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet* mutable_unknown_fields() { return _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); - } - + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { return GetDescriptor(); } @@ -157,16 +157,16 @@ class PROTOC_EXPORT Version final : static const Version& default_instance() { return *internal_default_instance(); } - static inline const Version* internal_default_instance() { - return reinterpret_cast<const Version*>( - &_Version_default_instance_); - } + static inline const Version* internal_default_instance() { + return reinterpret_cast<const Version*>( + &_Version_default_instance_); + } static constexpr int kIndexInFileMessages = - 0; - - friend void swap(Version& a, Version& b) { - a.Swap(&b); - } + 0; + + friend void swap(Version& a, Version& b) { + a.Swap(&b); + } inline void Swap(Version* other) { if (other == this) return; if (GetOwningArena() == other->GetOwningArena()) { @@ -180,37 +180,37 @@ class PROTOC_EXPORT Version final : GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); InternalSwap(other); } - - // implements Message ---------------------------------------------- - + + // implements Message ---------------------------------------------- + inline Version* New() const final { return new Version(); } - + Version* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { return CreateMaybeMessage<Version>(arena); } using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; - void CopyFrom(const Version& from); + void CopyFrom(const Version& from); using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; - void MergeFrom(const Version& from); + void MergeFrom(const Version& from); private: static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message*to, const ::PROTOBUF_NAMESPACE_ID::Message&from); public: PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; bool IsInitialized() const final; - + size_t ByteSizeLong() const final; const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; ::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize( ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; int GetCachedSize() const final { return _cached_size_.Get(); } - private: - void SharedCtor(); - void SharedDtor(); + private: + void SharedCtor(); + void SharedDtor(); void SetCachedSize(int size) const final; - void InternalSwap(Version* other); + void InternalSwap(Version* other); friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { return "google.protobuf.compiler.Version"; @@ -218,7 +218,7 @@ class PROTOC_EXPORT Version final : protected: explicit Version(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned = false); - private: + private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); public: @@ -228,77 +228,77 @@ class PROTOC_EXPORT Version final : ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + enum : int { kSuffixFieldNumber = 4, kMajorFieldNumber = 1, kMinorFieldNumber = 2, kPatchFieldNumber = 3, }; - // optional string suffix = 4; - bool has_suffix() const; + // optional string suffix = 4; + bool has_suffix() const; private: bool _internal_has_suffix() const; public: - void clear_suffix(); - const TProtoStringType& suffix() const; + void clear_suffix(); + const TProtoStringType& suffix() const; template <typename ArgT0 = const TProtoStringType&, typename... ArgT> void set_suffix(ArgT0&& arg0, ArgT... args); - TProtoStringType* mutable_suffix(); + TProtoStringType* mutable_suffix(); PROTOBUF_MUST_USE_RESULT TProtoStringType* release_suffix(); - void set_allocated_suffix(TProtoStringType* suffix); + void set_allocated_suffix(TProtoStringType* suffix); private: const TProtoStringType& _internal_suffix() const; inline PROTOBUF_ALWAYS_INLINE void _internal_set_suffix(const TProtoStringType& value); TProtoStringType* _internal_mutable_suffix(); public: - - // optional int32 major = 1; - bool has_major() const; + + // optional int32 major = 1; + bool has_major() const; private: bool _internal_has_major() const; public: - void clear_major(); + void clear_major(); ::PROTOBUF_NAMESPACE_ID::int32 major() const; void set_major(::PROTOBUF_NAMESPACE_ID::int32 value); private: ::PROTOBUF_NAMESPACE_ID::int32 _internal_major() const; void _internal_set_major(::PROTOBUF_NAMESPACE_ID::int32 value); public: - - // optional int32 minor = 2; - bool has_minor() const; + + // optional int32 minor = 2; + bool has_minor() const; private: bool _internal_has_minor() const; public: - void clear_minor(); + void clear_minor(); ::PROTOBUF_NAMESPACE_ID::int32 minor() const; void set_minor(::PROTOBUF_NAMESPACE_ID::int32 value); private: ::PROTOBUF_NAMESPACE_ID::int32 _internal_minor() const; void _internal_set_minor(::PROTOBUF_NAMESPACE_ID::int32 value); public: - - // optional int32 patch = 3; - bool has_patch() const; + + // optional int32 patch = 3; + bool has_patch() const; private: bool _internal_has_patch() const; public: - void clear_patch(); + void clear_patch(); ::PROTOBUF_NAMESPACE_ID::int32 patch() const; void set_patch(::PROTOBUF_NAMESPACE_ID::int32 value); private: ::PROTOBUF_NAMESPACE_ID::int32 _internal_patch() const; void _internal_set_patch(::PROTOBUF_NAMESPACE_ID::int32 value); public: - - // @@protoc_insertion_point(class_scope:google.protobuf.compiler.Version) - private: + + // @@protoc_insertion_point(class_scope:google.protobuf.compiler.Version) + private: class _Internal; - + template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; @@ -309,9 +309,9 @@ class PROTOC_EXPORT Version final : ::PROTOBUF_NAMESPACE_ID::int32 minor_; ::PROTOBUF_NAMESPACE_ID::int32 patch_; friend struct ::TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto; -}; -// ------------------------------------------------------------------- - +}; +// ------------------------------------------------------------------- + class PROTOC_EXPORT CodeGeneratorRequest final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.CodeGeneratorRequest) */ { public: @@ -329,15 +329,15 @@ class PROTOC_EXPORT CodeGeneratorRequest final : CopyFrom(from); return *this; } - inline CodeGeneratorRequest& operator=(CodeGeneratorRequest&& from) noexcept { + inline CodeGeneratorRequest& operator=(CodeGeneratorRequest&& from) noexcept { if (this == &from) return *this; if (GetOwningArena() == from.GetOwningArena()) { InternalSwap(&from); - } else { - CopyFrom(from); - } - return *this; - } + } else { + CopyFrom(from); + } + return *this; + } inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); @@ -358,16 +358,16 @@ class PROTOC_EXPORT CodeGeneratorRequest final : static const CodeGeneratorRequest& default_instance() { return *internal_default_instance(); } - static inline const CodeGeneratorRequest* internal_default_instance() { - return reinterpret_cast<const CodeGeneratorRequest*>( - &_CodeGeneratorRequest_default_instance_); - } + static inline const CodeGeneratorRequest* internal_default_instance() { + return reinterpret_cast<const CodeGeneratorRequest*>( + &_CodeGeneratorRequest_default_instance_); + } static constexpr int kIndexInFileMessages = - 1; - - friend void swap(CodeGeneratorRequest& a, CodeGeneratorRequest& b) { - a.Swap(&b); - } + 1; + + friend void swap(CodeGeneratorRequest& a, CodeGeneratorRequest& b) { + a.Swap(&b); + } inline void Swap(CodeGeneratorRequest* other) { if (other == this) return; if (GetOwningArena() == other->GetOwningArena()) { @@ -448,12 +448,12 @@ class PROTOC_EXPORT CodeGeneratorRequest final : const TProtoStringType& file_to_generate(int index) const; TProtoStringType* mutable_file_to_generate(int index); void set_file_to_generate(int index, const TProtoStringType& value); - void set_file_to_generate(int index, TProtoStringType&& value); + void set_file_to_generate(int index, TProtoStringType&& value); void set_file_to_generate(int index, const char* value); void set_file_to_generate(int index, const char* value, size_t size); TProtoStringType* add_file_to_generate(); void add_file_to_generate(const TProtoStringType& value); - void add_file_to_generate(TProtoStringType&& value); + void add_file_to_generate(TProtoStringType&& value); void add_file_to_generate(const char* value); void add_file_to_generate(const char* value, size_t size); const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField<TProtoStringType>& file_to_generate() const; @@ -463,15 +463,15 @@ class PROTOC_EXPORT CodeGeneratorRequest final : TProtoStringType* _internal_add_file_to_generate(); public: - // repeated .google.protobuf.FileDescriptorProto proto_file = 15; - int proto_file_size() const; + // repeated .google.protobuf.FileDescriptorProto proto_file = 15; + int proto_file_size() const; private: int _internal_proto_file_size() const; public: - void clear_proto_file(); + void clear_proto_file(); PROTOBUF_NAMESPACE_ID::FileDescriptorProto* mutable_proto_file(int index); ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< PROTOBUF_NAMESPACE_ID::FileDescriptorProto >* - mutable_proto_file(); + mutable_proto_file(); private: const PROTOBUF_NAMESPACE_ID::FileDescriptorProto& _internal_proto_file(int index) const; PROTOBUF_NAMESPACE_ID::FileDescriptorProto* _internal_add_proto_file(); @@ -479,8 +479,8 @@ class PROTOC_EXPORT CodeGeneratorRequest final : const PROTOBUF_NAMESPACE_ID::FileDescriptorProto& proto_file(int index) const; PROTOBUF_NAMESPACE_ID::FileDescriptorProto* add_proto_file(); const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< PROTOBUF_NAMESPACE_ID::FileDescriptorProto >& - proto_file() const; - + proto_file() const; + // optional string parameter = 2; bool has_parameter() const; private: @@ -499,12 +499,12 @@ class PROTOC_EXPORT CodeGeneratorRequest final : TProtoStringType* _internal_mutable_parameter(); public: - // optional .google.protobuf.compiler.Version compiler_version = 3; - bool has_compiler_version() const; + // optional .google.protobuf.compiler.Version compiler_version = 3; + bool has_compiler_version() const; private: bool _internal_has_compiler_version() const; public: - void clear_compiler_version(); + void clear_compiler_version(); const PROTOBUF_NAMESPACE_ID::compiler::Version& compiler_version() const; PROTOBUF_MUST_USE_RESULT PROTOBUF_NAMESPACE_ID::compiler::Version* release_compiler_version(); PROTOBUF_NAMESPACE_ID::compiler::Version* mutable_compiler_version(); @@ -551,15 +551,15 @@ class PROTOC_EXPORT CodeGeneratorResponse_File final : CopyFrom(from); return *this; } - inline CodeGeneratorResponse_File& operator=(CodeGeneratorResponse_File&& from) noexcept { + inline CodeGeneratorResponse_File& operator=(CodeGeneratorResponse_File&& from) noexcept { if (this == &from) return *this; if (GetOwningArena() == from.GetOwningArena()) { InternalSwap(&from); - } else { - CopyFrom(from); - } - return *this; - } + } else { + CopyFrom(from); + } + return *this; + } inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); @@ -580,16 +580,16 @@ class PROTOC_EXPORT CodeGeneratorResponse_File final : static const CodeGeneratorResponse_File& default_instance() { return *internal_default_instance(); } - static inline const CodeGeneratorResponse_File* internal_default_instance() { - return reinterpret_cast<const CodeGeneratorResponse_File*>( - &_CodeGeneratorResponse_File_default_instance_); - } + static inline const CodeGeneratorResponse_File* internal_default_instance() { + return reinterpret_cast<const CodeGeneratorResponse_File*>( + &_CodeGeneratorResponse_File_default_instance_); + } static constexpr int kIndexInFileMessages = - 2; - - friend void swap(CodeGeneratorResponse_File& a, CodeGeneratorResponse_File& b) { - a.Swap(&b); - } + 2; + + friend void swap(CodeGeneratorResponse_File& a, CodeGeneratorResponse_File& b) { + a.Swap(&b); + } inline void Swap(CodeGeneratorResponse_File* other) { if (other == this) return; if (GetOwningArena() == other->GetOwningArena()) { @@ -767,15 +767,15 @@ class PROTOC_EXPORT CodeGeneratorResponse final : CopyFrom(from); return *this; } - inline CodeGeneratorResponse& operator=(CodeGeneratorResponse&& from) noexcept { + inline CodeGeneratorResponse& operator=(CodeGeneratorResponse&& from) noexcept { if (this == &from) return *this; if (GetOwningArena() == from.GetOwningArena()) { InternalSwap(&from); - } else { - CopyFrom(from); - } - return *this; - } + } else { + CopyFrom(from); + } + return *this; + } inline const ::PROTOBUF_NAMESPACE_ID::UnknownFieldSet& unknown_fields() const { return _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance); @@ -796,16 +796,16 @@ class PROTOC_EXPORT CodeGeneratorResponse final : static const CodeGeneratorResponse& default_instance() { return *internal_default_instance(); } - static inline const CodeGeneratorResponse* internal_default_instance() { - return reinterpret_cast<const CodeGeneratorResponse*>( - &_CodeGeneratorResponse_default_instance_); - } + static inline const CodeGeneratorResponse* internal_default_instance() { + return reinterpret_cast<const CodeGeneratorResponse*>( + &_CodeGeneratorResponse_default_instance_); + } static constexpr int kIndexInFileMessages = - 3; - - friend void swap(CodeGeneratorResponse& a, CodeGeneratorResponse& b) { - a.Swap(&b); - } + 3; + + friend void swap(CodeGeneratorResponse& a, CodeGeneratorResponse& b) { + a.Swap(&b); + } inline void Swap(CodeGeneratorResponse* other) { if (other == this) return; if (GetOwningArena() == other->GetOwningArena()) { @@ -908,15 +908,15 @@ class PROTOC_EXPORT CodeGeneratorResponse final : kErrorFieldNumber = 1, kSupportedFeaturesFieldNumber = 2, }; - // repeated .google.protobuf.compiler.CodeGeneratorResponse.File file = 15; - int file_size() const; + // repeated .google.protobuf.compiler.CodeGeneratorResponse.File file = 15; + int file_size() const; private: int _internal_file_size() const; public: - void clear_file(); + void clear_file(); PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File* mutable_file(int index); ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File >* - mutable_file(); + mutable_file(); private: const PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File& _internal_file(int index) const; PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File* _internal_add_file(); @@ -924,8 +924,8 @@ class PROTOC_EXPORT CodeGeneratorResponse final : const PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File& file(int index) const; PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File* add_file(); const ::PROTOBUF_NAMESPACE_ID::RepeatedPtrField< PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File >& - file() const; - + file() const; + // optional string error = 1; bool has_error() const; private: @@ -976,119 +976,119 @@ class PROTOC_EXPORT CodeGeneratorResponse final : // =================================================================== -#ifdef __GNUC__ - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wstrict-aliasing" -#endif // __GNUC__ -// Version - -// optional int32 major = 1; +#ifdef __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif // __GNUC__ +// Version + +// optional int32 major = 1; inline bool Version::_internal_has_major() const { bool value = (_has_bits_[0] & 0x00000002u) != 0; return value; } -inline bool Version::has_major() const { +inline bool Version::has_major() const { return _internal_has_major(); -} -inline void Version::clear_major() { - major_ = 0; +} +inline void Version::clear_major() { + major_ = 0; _has_bits_[0] &= ~0x00000002u; -} +} inline ::PROTOBUF_NAMESPACE_ID::int32 Version::_internal_major() const { - return major_; -} + return major_; +} inline ::PROTOBUF_NAMESPACE_ID::int32 Version::major() const { // @@protoc_insertion_point(field_get:google.protobuf.compiler.Version.major) return _internal_major(); } inline void Version::_internal_set_major(::PROTOBUF_NAMESPACE_ID::int32 value) { _has_bits_[0] |= 0x00000002u; - major_ = value; + major_ = value; } inline void Version::set_major(::PROTOBUF_NAMESPACE_ID::int32 value) { _internal_set_major(value); - // @@protoc_insertion_point(field_set:google.protobuf.compiler.Version.major) -} - -// optional int32 minor = 2; + // @@protoc_insertion_point(field_set:google.protobuf.compiler.Version.major) +} + +// optional int32 minor = 2; inline bool Version::_internal_has_minor() const { bool value = (_has_bits_[0] & 0x00000004u) != 0; return value; } -inline bool Version::has_minor() const { +inline bool Version::has_minor() const { return _internal_has_minor(); -} -inline void Version::clear_minor() { - minor_ = 0; +} +inline void Version::clear_minor() { + minor_ = 0; _has_bits_[0] &= ~0x00000004u; -} +} inline ::PROTOBUF_NAMESPACE_ID::int32 Version::_internal_minor() const { - return minor_; -} + return minor_; +} inline ::PROTOBUF_NAMESPACE_ID::int32 Version::minor() const { // @@protoc_insertion_point(field_get:google.protobuf.compiler.Version.minor) return _internal_minor(); } inline void Version::_internal_set_minor(::PROTOBUF_NAMESPACE_ID::int32 value) { _has_bits_[0] |= 0x00000004u; - minor_ = value; + minor_ = value; } inline void Version::set_minor(::PROTOBUF_NAMESPACE_ID::int32 value) { _internal_set_minor(value); - // @@protoc_insertion_point(field_set:google.protobuf.compiler.Version.minor) -} - -// optional int32 patch = 3; + // @@protoc_insertion_point(field_set:google.protobuf.compiler.Version.minor) +} + +// optional int32 patch = 3; inline bool Version::_internal_has_patch() const { bool value = (_has_bits_[0] & 0x00000008u) != 0; return value; } -inline bool Version::has_patch() const { +inline bool Version::has_patch() const { return _internal_has_patch(); -} -inline void Version::clear_patch() { - patch_ = 0; +} +inline void Version::clear_patch() { + patch_ = 0; _has_bits_[0] &= ~0x00000008u; -} +} inline ::PROTOBUF_NAMESPACE_ID::int32 Version::_internal_patch() const { - return patch_; -} + return patch_; +} inline ::PROTOBUF_NAMESPACE_ID::int32 Version::patch() const { // @@protoc_insertion_point(field_get:google.protobuf.compiler.Version.patch) return _internal_patch(); } inline void Version::_internal_set_patch(::PROTOBUF_NAMESPACE_ID::int32 value) { _has_bits_[0] |= 0x00000008u; - patch_ = value; + patch_ = value; } inline void Version::set_patch(::PROTOBUF_NAMESPACE_ID::int32 value) { _internal_set_patch(value); - // @@protoc_insertion_point(field_set:google.protobuf.compiler.Version.patch) -} - -// optional string suffix = 4; + // @@protoc_insertion_point(field_set:google.protobuf.compiler.Version.patch) +} + +// optional string suffix = 4; inline bool Version::_internal_has_suffix() const { bool value = (_has_bits_[0] & 0x00000001u) != 0; return value; } -inline bool Version::has_suffix() const { +inline bool Version::has_suffix() const { return _internal_has_suffix(); -} +} inline void Version::clear_suffix() { suffix_.ClearToEmpty(); - _has_bits_[0] &= ~0x00000001u; -} -inline const TProtoStringType& Version::suffix() const { - // @@protoc_insertion_point(field_get:google.protobuf.compiler.Version.suffix) + _has_bits_[0] &= ~0x00000001u; +} +inline const TProtoStringType& Version::suffix() const { + // @@protoc_insertion_point(field_get:google.protobuf.compiler.Version.suffix) return _internal_suffix(); -} +} template <typename ArgT0, typename... ArgT> inline PROTOBUF_ALWAYS_INLINE void Version::set_suffix(ArgT0&& arg0, ArgT... args) { _has_bits_[0] |= 0x00000001u; suffix_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation()); - // @@protoc_insertion_point(field_set:google.protobuf.compiler.Version.suffix) -} + // @@protoc_insertion_point(field_set:google.protobuf.compiler.Version.suffix) +} inline TProtoStringType* Version::mutable_suffix() { TProtoStringType* _s = _internal_mutable_suffix(); // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.Version.suffix) @@ -1104,28 +1104,28 @@ inline void Version::_internal_set_suffix(const TProtoStringType& value) { inline TProtoStringType* Version::_internal_mutable_suffix() { _has_bits_[0] |= 0x00000001u; return suffix_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation()); -} -inline TProtoStringType* Version::release_suffix() { - // @@protoc_insertion_point(field_release:google.protobuf.compiler.Version.suffix) +} +inline TProtoStringType* Version::release_suffix() { + // @@protoc_insertion_point(field_release:google.protobuf.compiler.Version.suffix) if (!_internal_has_suffix()) { return nullptr; } _has_bits_[0] &= ~0x00000001u; return suffix_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation()); -} -inline void Version::set_allocated_suffix(TProtoStringType* suffix) { +} +inline void Version::set_allocated_suffix(TProtoStringType* suffix) { if (suffix != nullptr) { _has_bits_[0] |= 0x00000001u; - } else { + } else { _has_bits_[0] &= ~0x00000001u; - } + } suffix_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), suffix, GetArenaForAllocation()); - // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.Version.suffix) -} - -// ------------------------------------------------------------------- - + // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.Version.suffix) +} + +// ------------------------------------------------------------------- + // CodeGeneratorRequest // repeated string file_to_generate = 1; @@ -1158,10 +1158,10 @@ inline void CodeGeneratorRequest::set_file_to_generate(int index, const TProtoSt file_to_generate_.Mutable(index)->assign(value); // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) } -inline void CodeGeneratorRequest::set_file_to_generate(int index, TProtoStringType&& value) { +inline void CodeGeneratorRequest::set_file_to_generate(int index, TProtoStringType&& value) { file_to_generate_.Mutable(index)->assign(std::move(value)); - // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) -} + // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) +} inline void CodeGeneratorRequest::set_file_to_generate(int index, const char* value) { GOOGLE_DCHECK(value != nullptr); file_to_generate_.Mutable(index)->assign(value); @@ -1179,10 +1179,10 @@ inline void CodeGeneratorRequest::add_file_to_generate(const TProtoStringType& v file_to_generate_.Add()->assign(value); // @@protoc_insertion_point(field_add:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) } -inline void CodeGeneratorRequest::add_file_to_generate(TProtoStringType&& value) { - file_to_generate_.Add(std::move(value)); - // @@protoc_insertion_point(field_add:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) -} +inline void CodeGeneratorRequest::add_file_to_generate(TProtoStringType&& value) { + file_to_generate_.Add(std::move(value)); + // @@protoc_insertion_point(field_add:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate) +} inline void CodeGeneratorRequest::add_file_to_generate(const char* value) { GOOGLE_DCHECK(value != nullptr); file_to_generate_.Add()->assign(value); @@ -1213,7 +1213,7 @@ inline bool CodeGeneratorRequest::has_parameter() const { } inline void CodeGeneratorRequest::clear_parameter() { parameter_.ClearToEmpty(); - _has_bits_[0] &= ~0x00000001u; + _has_bits_[0] &= ~0x00000001u; } inline const TProtoStringType& CodeGeneratorRequest::parameter() const { // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorRequest.parameter) @@ -1298,33 +1298,33 @@ CodeGeneratorRequest::proto_file() const { return proto_file_; } -// optional .google.protobuf.compiler.Version compiler_version = 3; +// optional .google.protobuf.compiler.Version compiler_version = 3; inline bool CodeGeneratorRequest::_internal_has_compiler_version() const { bool value = (_has_bits_[0] & 0x00000002u) != 0; PROTOBUF_ASSUME(!value || compiler_version_ != nullptr); return value; } -inline bool CodeGeneratorRequest::has_compiler_version() const { +inline bool CodeGeneratorRequest::has_compiler_version() const { return _internal_has_compiler_version(); -} +} inline void CodeGeneratorRequest::clear_compiler_version() { if (compiler_version_ != nullptr) compiler_version_->Clear(); - _has_bits_[0] &= ~0x00000002u; -} + _has_bits_[0] &= ~0x00000002u; +} inline const PROTOBUF_NAMESPACE_ID::compiler::Version& CodeGeneratorRequest::_internal_compiler_version() const { const PROTOBUF_NAMESPACE_ID::compiler::Version* p = compiler_version_; return p != nullptr ? *p : reinterpret_cast<const PROTOBUF_NAMESPACE_ID::compiler::Version&>( PROTOBUF_NAMESPACE_ID::compiler::_Version_default_instance_); -} +} inline const PROTOBUF_NAMESPACE_ID::compiler::Version& CodeGeneratorRequest::compiler_version() const { - // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorRequest.compiler_version) + // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorRequest.compiler_version) return _internal_compiler_version(); -} +} inline void CodeGeneratorRequest::unsafe_arena_set_allocated_compiler_version( PROTOBUF_NAMESPACE_ID::compiler::Version* compiler_version) { if (GetArenaForAllocation() == nullptr) { delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(compiler_version_); - } + } compiler_version_ = compiler_version; if (compiler_version) { _has_bits_[0] |= 0x00000002u; @@ -1332,7 +1332,7 @@ inline void CodeGeneratorRequest::unsafe_arena_set_allocated_compiler_version( _has_bits_[0] &= ~0x00000002u; } // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.compiler.CodeGeneratorRequest.compiler_version) -} +} inline PROTOBUF_NAMESPACE_ID::compiler::Version* CodeGeneratorRequest::release_compiler_version() { _has_bits_[0] &= ~0x00000002u; PROTOBUF_NAMESPACE_ID::compiler::Version* temp = compiler_version_; @@ -1349,12 +1349,12 @@ inline PROTOBUF_NAMESPACE_ID::compiler::Version* CodeGeneratorRequest::release_c return temp; } inline PROTOBUF_NAMESPACE_ID::compiler::Version* CodeGeneratorRequest::unsafe_arena_release_compiler_version() { - // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorRequest.compiler_version) + // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorRequest.compiler_version) _has_bits_[0] &= ~0x00000002u; PROTOBUF_NAMESPACE_ID::compiler::Version* temp = compiler_version_; compiler_version_ = nullptr; - return temp; -} + return temp; +} inline PROTOBUF_NAMESPACE_ID::compiler::Version* CodeGeneratorRequest::_internal_mutable_compiler_version() { _has_bits_[0] |= 0x00000002u; if (compiler_version_ == nullptr) { @@ -1373,7 +1373,7 @@ inline void CodeGeneratorRequest::set_allocated_compiler_version(PROTOBUF_NAMESP if (message_arena == nullptr) { delete compiler_version_; } - if (compiler_version) { + if (compiler_version) { ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper<PROTOBUF_NAMESPACE_ID::compiler::Version>::GetOwningArena(compiler_version); if (message_arena != submessage_arena) { @@ -1381,13 +1381,13 @@ inline void CodeGeneratorRequest::set_allocated_compiler_version(PROTOBUF_NAMESP message_arena, compiler_version, submessage_arena); } _has_bits_[0] |= 0x00000002u; - } else { + } else { _has_bits_[0] &= ~0x00000002u; - } + } compiler_version_ = compiler_version; - // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorRequest.compiler_version) -} - + // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorRequest.compiler_version) +} + // ------------------------------------------------------------------- // CodeGeneratorResponse_File @@ -1784,16 +1784,16 @@ CodeGeneratorResponse::file() const { return file_; } -#ifdef __GNUC__ - #pragma GCC diagnostic pop -#endif // __GNUC__ +#ifdef __GNUC__ + #pragma GCC diagnostic pop +#endif // __GNUC__ +// ------------------------------------------------------------------- + // ------------------------------------------------------------------- // ------------------------------------------------------------------- -// ------------------------------------------------------------------- - // @@protoc_insertion_point(namespace_scope) } // namespace compiler diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/plugin.proto b/contrib/libs/protoc/src/google/protobuf/compiler/plugin.proto index 5e4b713cca..9242aacc5b 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/plugin.proto +++ b/contrib/libs/protoc/src/google/protobuf/compiler/plugin.proto @@ -54,16 +54,16 @@ option go_package = "google.golang.org/protobuf/types/pluginpb"; import "google/protobuf/descriptor.proto"; -// The version number of protocol compiler. -message Version { - optional int32 major = 1; - optional int32 minor = 2; - optional int32 patch = 3; - // A suffix for alpha, beta or rc release, e.g., "alpha-1", "rc2". It should - // be empty for mainline stable releases. - optional string suffix = 4; -} - +// The version number of protocol compiler. +message Version { + optional int32 major = 1; + optional int32 minor = 2; + optional int32 patch = 3; + // A suffix for alpha, beta or rc release, e.g., "alpha-1", "rc2". It should + // be empty for mainline stable releases. + optional string suffix = 4; +} + // An encoded CodeGeneratorRequest is written to the plugin's stdin. message CodeGeneratorRequest { // The .proto files that were explicitly listed on the command-line. The @@ -85,14 +85,14 @@ 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. + // + // Type names of fields and extensions in the FileDescriptorProto are always + // fully qualified. repeated FileDescriptorProto proto_file = 15; - - // The version number of protocol compiler. - optional Version compiler_version = 3; - + + // The version number of protocol compiler. + optional Version compiler_version = 3; + } // The plugin writes an encoded CodeGeneratorResponse to stdout. diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/python/python_generator.cc b/contrib/libs/protoc/src/google/protobuf/compiler/python/python_generator.cc index 046f1fa4ae..471cc46ef6 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/python/python_generator.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/python/python_generator.cc @@ -79,8 +79,8 @@ TProtoStringType FixEv(const TProtoStringType& filename) { // Returns the Python module name expected for a given .proto filename. TProtoStringType ModuleName(const TProtoStringType& filename) { TProtoStringType basename = StripProto(FixEv(filename)); - ReplaceCharacters(&basename, "-", '_'); - ReplaceCharacters(&basename, "/", '.'); + ReplaceCharacters(&basename, "-", '_'); + ReplaceCharacters(&basename, "/", '.'); return basename + "_pb2"; } @@ -464,10 +464,10 @@ void Generator::PrintFileDescriptor() const { module_alias); } printer_->Print("]"); - } + } } else { printer_->Print("serialized_pb=''\n"); - } + } // TODO(falk): Also print options and fix the message_type, enum_type, // service and extension later in the generation. @@ -598,14 +598,14 @@ void Generator::PrintMessageDescriptors() const { } } -void Generator::PrintServiceDescriptors() const { - for (int i = 0; i < file_->service_count(); ++i) { - PrintServiceDescriptor(*file_->service(i)); - AddServiceToFileDescriptor(*file_->service(i)); - printer_->Print("\n"); - } -} - +void Generator::PrintServiceDescriptors() const { + for (int i = 0; i < file_->service_count(); ++i) { + PrintServiceDescriptor(*file_->service(i)); + AddServiceToFileDescriptor(*file_->service(i)); + printer_->Print("\n"); + } +} + void Generator::PrintServices() const { for (int i = 0; i < file_->service_count(); ++i) { PrintServiceClass(*file_->service(i)); @@ -671,10 +671,10 @@ void Generator::PrintServiceDescriptor( } printer_->Outdent(); - printer_->Print("])\n"); - printer_->Print("_sym_db.RegisterServiceDescriptor($name$)\n", "name", - service_name); - printer_->Print("\n"); + printer_->Print("])\n"); + printer_->Print("_sym_db.RegisterServiceDescriptor($name$)\n", "name", + service_name); + printer_->Print("\n"); } void Generator::PrintDescriptorKeyAndModuleName( @@ -959,18 +959,18 @@ void Generator::AddMessageToFileDescriptor(const Descriptor& descriptor) const { printer_->Print(m, file_descriptor_template); } -void Generator::AddServiceToFileDescriptor( - const ServiceDescriptor& descriptor) const { +void Generator::AddServiceToFileDescriptor( + const ServiceDescriptor& descriptor) const { std::map<TProtoStringType, TProtoStringType> m; - m["descriptor_name"] = kDescriptorKey; - m["service_name"] = descriptor.name(); - m["service_descriptor_name"] = ModuleLevelServiceDescriptorName(descriptor); - const char file_descriptor_template[] = - "$descriptor_name$.services_by_name['$service_name$'] = " - "$service_descriptor_name$\n"; - printer_->Print(m, file_descriptor_template); -} - + m["descriptor_name"] = kDescriptorKey; + m["service_name"] = descriptor.name(); + m["service_descriptor_name"] = ModuleLevelServiceDescriptorName(descriptor); + const char file_descriptor_template[] = + "$descriptor_name$.services_by_name['$service_name$'] = " + "$service_descriptor_name$\n"; + printer_->Print(m, file_descriptor_template); +} + void Generator::AddEnumToFileDescriptor( const EnumDescriptor& descriptor) const { std::map<TProtoStringType, TProtoStringType> m; @@ -1079,10 +1079,10 @@ void Generator::FixForeignFieldsInDescriptors() const { AddExtensionToFileDescriptor(*file_->extension(i)); } - // TODO(jieluo): Move this register to PrintFileDescriptor() when - // FieldDescriptor.file is added in generated file. - printer_->Print("_sym_db.RegisterFileDescriptor($name$)\n", "name", - kDescriptorKey); + // TODO(jieluo): Move this register to PrintFileDescriptor() when + // FieldDescriptor.file is added in generated file. + printer_->Print("_sym_db.RegisterFileDescriptor($name$)\n", "name", + kDescriptorKey); printer_->Print("\n"); } @@ -1450,9 +1450,9 @@ void Generator::CopyPublicDependenciesAliases( for (int i = 0; i < file->public_dependency_count(); ++i) { TProtoStringType module_name = ModuleName(file->public_dependency(i)->name()); TProtoStringType module_alias = ModuleAlias(file->public_dependency(i)->name()); - // There's no module alias in the dependent file if it was generated by - // an old protoc (less than 3.0.0-alpha-1). Use module name in this - // situation. + // There's no module alias in the dependent file if it was generated by + // an old protoc (less than 3.0.0-alpha-1). Use module name in this + // situation. printer_->Print( "try:\n" " $alias$ = $copy_from$.$alias$\n" diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/python/python_generator.h b/contrib/libs/protoc/src/google/protobuf/compiler/python/python_generator.h index 7cf48bb27d..83dbce951a 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/python/python_generator.h +++ b/contrib/libs/protoc/src/google/protobuf/compiler/python/python_generator.h @@ -116,7 +116,7 @@ class PROTOC_EXPORT Generator : public CodeGenerator { void AddMessageToFileDescriptor(const Descriptor& descriptor) const; void AddEnumToFileDescriptor(const EnumDescriptor& descriptor) const; void AddExtensionToFileDescriptor(const FieldDescriptor& descriptor) const; - void AddServiceToFileDescriptor(const ServiceDescriptor& descriptor) const; + void AddServiceToFileDescriptor(const ServiceDescriptor& descriptor) const; TProtoStringType FieldReferencingExpression( const Descriptor* containing_type, const FieldDescriptor& field, const TProtoStringType& python_dict_name) const; @@ -131,12 +131,12 @@ class PROTOC_EXPORT Generator : public CodeGenerator { void FixForeignFieldsInNestedExtensions(const Descriptor& descriptor) const; void PrintServices() const; - void PrintServiceDescriptors() const; + void PrintServiceDescriptors() const; void PrintServiceDescriptor(const ServiceDescriptor& descriptor) const; void PrintServiceClass(const ServiceDescriptor& descriptor) const; void PrintServiceStub(const ServiceDescriptor& descriptor) const; void PrintDescriptorKeyAndModuleName( - const ServiceDescriptor& descriptor) const; + const ServiceDescriptor& descriptor) const; void PrintEnumValueDescriptor(const EnumValueDescriptor& descriptor) const; TProtoStringType OptionsValue(const TProtoStringType& serialized_options) const; diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/subprocess.cc b/contrib/libs/protoc/src/google/protobuf/compiler/subprocess.cc index e3a84c03a8..9a660733b3 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/subprocess.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/subprocess.cc @@ -33,7 +33,7 @@ #include <google/protobuf/compiler/subprocess.h> #include <algorithm> -#include <cstring> +#include <cstring> #include <iostream> #ifndef _WIN32 @@ -52,16 +52,16 @@ namespace google { namespace protobuf { namespace compiler { -namespace { -char* portable_strdup(const char* s) { +namespace { +char* portable_strdup(const char* s) { char* ns = (char*)malloc(strlen(s) + 1); - if (ns != NULL) { - strcpy(ns, s); - } - return ns; -} -} // namespace - + if (ns != NULL) { + strcpy(ns, s); + } + return ns; +} +} // namespace + #ifdef _WIN32 static void CloseHandleOrDie(HANDLE handle) { @@ -271,11 +271,11 @@ TProtoStringType Subprocess::Win32ErrorMessage(DWORD error_code) { char* message; // WTF? - FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, + FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, NULL, error_code, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), - (LPSTR)&message, // NOT A BUG! - 0, NULL); + (LPSTR)&message, // NOT A BUG! + 0, NULL); TProtoStringType result = message; LocalFree(message); diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/zip_writer.cc b/contrib/libs/protoc/src/google/protobuf/compiler/zip_writer.cc index 359309ea18..40bac12e40 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/zip_writer.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/zip_writer.cc @@ -43,10 +43,10 @@ namespace google { namespace protobuf { namespace compiler { -// January 1, 1980 as a DOS date. -// see https://msdn.microsoft.com/en-us/library/9kkf9tah.aspx +// January 1, 1980 as a DOS date. +// see https://msdn.microsoft.com/en-us/library/9kkf9tah.aspx static const uint16_t kDosEpoch = 1 << 5 | 1; - + static const uint32_t kCRC32Table[256] = { 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, |