Merge remote-tracking branch 'refs/remotes/upstream/main' into sync-stage # Conflicts: # src/google/protobuf/compiler/objectivec/objectivec_enum.cc # src/google/protobuf/compiler/objectivec/objectivec_extension.cc # src/google/protobuf/compiler/objectivec/objectivec_field.cc # src/google/protobuf/compiler/objectivec/objectivec_file.cc # src/google/protobuf/compiler/objectivec/objectivec_generator.cc # src/google/protobuf/compiler/objectivec/objectivec_helpers.cc # src/google/protobuf/compiler/objectivec/objectivec_message.cc # src/google/protobuf/compiler/objectivec/objectivec_oneof.cc # src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc # src/google/protobuf/compiler/plugin.pb.h # src/google/protobuf/descriptor.pb.h
diff --git a/CMakeLists.txt b/CMakeLists.txt index 76e2c4e..dead8be 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt
@@ -19,6 +19,10 @@ if(POLICY CMP0091) cmake_policy(SET CMP0091 NEW) endif() +# Honor visibility properties for all target types. +if(POLICY CMP0063) + cmake_policy(SET CMP0063 NEW) +endif() # Project project(protobuf C CXX) @@ -53,6 +57,11 @@ set(CMAKE_CXX_EXTENSIONS OFF) endif() +# For -fvisibility=hidden and -fvisibility-inlines-hidden +set(CMAKE_C_VISIBILITY_PRESET hidden) +set(CMAKE_CXX_VISIBILITY_PRESET hidden) +set(CMAKE_VISIBILITY_INLINES_HIDDEN ON) + # The Intel compiler isn't able to deal with noinline member functions of # template classes defined in headers. As such it spams the output with # warning #2196: routine is both "inline" and "noinline"
diff --git a/cmake/install.cmake b/cmake/install.cmake index 26a55be..90230c5 100644 --- a/cmake/install.cmake +++ b/cmake/install.cmake
@@ -47,7 +47,7 @@ set(protobuf_HEADERS ${libprotobuf_hdrs} ${libprotoc_hdrs} - ${wkt_protos_proto_srcs} + ${wkt_protos_files} ${descriptor_proto_proto_srcs} ${plugin_proto_proto_srcs} )
diff --git a/java/core/src/main/java/com/google/protobuf/TextFormat.java b/java/core/src/main/java/com/google/protobuf/TextFormat.java index 7fba30a..aa1cc34 100644 --- a/java/core/src/main/java/com/google/protobuf/TextFormat.java +++ b/java/core/src/main/java/com/google/protobuf/TextFormat.java
@@ -61,7 +61,6 @@ private static final String DEBUG_STRING_SILENT_MARKER = "\t "; - /** * Outputs a textual representation of the Protocol Message supplied into the parameter output. * (This representation is the new version of the classic "ProtocolPrinter" output from the @@ -739,9 +738,9 @@ // Groups must be serialized with their original capitalization. generator.print(field.getMessageType().getName()); } else { - generator.print(field.getName()); - } + generator.print(field.getName()); } + } if (field.getJavaType() == FieldDescriptor.JavaType.MESSAGE) { generator.print(" {"); @@ -1836,16 +1835,16 @@ extension = target.findExtensionByName(extensionRegistry, name); if (extension == null) { - String message = - (tokenizer.getPreviousLine() + 1) - + ":" - + (tokenizer.getPreviousColumn() + 1) - + ":\t" - + type.getFullName() - + ".[" - + name - + "]"; - unknownFields.add(new UnknownField(message, UnknownField.Type.EXTENSION)); + String message = + (tokenizer.getPreviousLine() + 1) + + ":" + + (tokenizer.getPreviousColumn() + 1) + + ":\t" + + type.getFullName() + + ".[" + + name + + "]"; + unknownFields.add(new UnknownField(message, UnknownField.Type.EXTENSION)); } else { if (extension.descriptor.getContainingType() != type) { throw tokenizer.parseExceptionPreviousToken(
diff --git a/java/core/src/test/proto/com/google/protobuf/map_for_proto2_lite_test.proto b/java/core/src/test/proto/com/google/protobuf/map_for_proto2_lite_test.proto index 4ec9688..95ab8c0 100644 --- a/java/core/src/test/proto/com/google/protobuf/map_for_proto2_lite_test.proto +++ b/java/core/src/test/proto/com/google/protobuf/map_for_proto2_lite_test.proto
@@ -125,6 +125,3 @@ // null is not a 'reserved word' per se but as a literal needs similar care map<string, SampleEnum> null = 10; } -package map_for_proto2_lite_test; -option java_package = "map_lite_test"; -option optimize_for = LITE_RUNTIME;
diff --git a/python/google/protobuf/pyext/message.cc b/python/google/protobuf/pyext/message.cc index 7990e95..ebad6b4 100644 --- a/python/google/protobuf/pyext/message.cc +++ b/python/google/protobuf/pyext/message.cc
@@ -42,7 +42,7 @@ #include <string> #include <vector> -#include "google/protobuf/stubs/strutil.h" +#include "absl/strings/match.h" #ifndef PyVarObject_HEAD_INIT #define PyVarObject_HEAD_INIT(type, size) PyObject_HEAD_INIT(type) size, @@ -70,6 +70,7 @@ #include "google/protobuf/pyext/unknown_field_set.h" #include "google/protobuf/pyext/unknown_fields.h" #include "google/protobuf/util/message_differencer.h" +#include "google/protobuf/stubs/strutil.h" #include "absl/strings/string_view.h" #include "google/protobuf/io/coded_stream.h" #include "google/protobuf/io/strtod.h" @@ -409,7 +410,7 @@ Py_ssize_t attr_size; static const char kSuffix[] = "_FIELD_NUMBER"; if (PyString_AsStringAndSize(name, &attr, &attr_size) >= 0 && - HasSuffixString(absl::string_view(attr, attr_size), kSuffix)) { + absl::EndsWith(absl::string_view(attr, attr_size), kSuffix)) { std::string field_name(attr, attr_size - sizeof(kSuffix) + 1); LowerString(&field_name);
diff --git a/python/google/protobuf/text_format.py b/python/google/protobuf/text_format.py index 2b79428..57696f0 100644 --- a/python/google/protobuf/text_format.py +++ b/python/google/protobuf/text_format.py
@@ -1013,6 +1013,8 @@ if not tokenizer.TryConsume(','): tokenizer.TryConsume(';') + + def _LogSilentMarker(self, field_name): pass def _DetectSilentMarker(self, tokenizer, field_name):
diff --git a/src/google/protobuf/any_lite.cc b/src/google/protobuf/any_lite.cc index fb812d7..a15d19f 100644 --- a/src/google/protobuf/any_lite.cc +++ b/src/google/protobuf/any_lite.cc
@@ -29,7 +29,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "google/protobuf/io/zero_copy_stream_impl_lite.h" -#include "google/protobuf/stubs/strutil.h" +#include "absl/strings/match.h" #include "absl/strings/str_cat.h" #include "google/protobuf/any.h" #include "google/protobuf/arenastring.h" @@ -72,7 +72,7 @@ absl::string_view type_url = type_url_->Get(); return type_url.size() >= type_name.size() + 1 && type_url[type_url.size() - type_name.size() - 1] == '/' && - HasSuffixString(type_url, type_name); + absl::EndsWith(type_url, type_name); } bool ParseAnyTypeUrl(absl::string_view type_url, std::string* url_prefix,
diff --git a/src/google/protobuf/arena.cc b/src/google/protobuf/arena.cc index 0eb8cc9..4b4b19e 100644 --- a/src/google/protobuf/arena.cc +++ b/src/google/protobuf/arena.cc
@@ -105,7 +105,7 @@ size_t* space_allocated_; }; -SerialArena::SerialArena(Block* b, ThreadSafeArena& parent) +SerialArena::SerialArena(ArenaBlock* b, ThreadSafeArena& parent) : parent_(parent), space_allocated_(b->size()) { set_head(b); set_ptr(b->Pointer(kBlockHeaderSize + ThreadSafeArena::kSerialArenaSize)); @@ -117,13 +117,13 @@ ThreadSafeArenaStats::RecordAllocateStats(parent.arena_stats_.MutableStats(), /*used=*/0, /*allocated=*/mem.size, /*wasted=*/0); - auto b = new (mem.ptr) Block{nullptr, mem.size}; + auto b = new (mem.ptr) ArenaBlock{nullptr, mem.size}; return new (b->Pointer(kBlockHeaderSize)) SerialArena(b, parent); } template <typename Deallocator> SerialArena::Memory SerialArena::Free(Deallocator deallocator) { - Block* b = head(); + ArenaBlock* b = head(); Memory mem = {b, b->size()}; while (b->next) { b = b->next; // We must first advance before deleting this block @@ -179,7 +179,7 @@ ThreadSafeArenaStats::RecordAllocateStats(parent_.arena_stats_.MutableStats(), /*used=*/used, /*allocated=*/mem.size, wasted); - set_head(new (mem.ptr) Block{head(), mem.size}); + set_head(new (mem.ptr) ArenaBlock{head(), mem.size}); set_ptr(head()->Pointer(kBlockHeaderSize)); limit_ = head()->Pointer(head()->size()); @@ -199,7 +199,7 @@ const uint64_t current_block_size = head()->size(); uint64_t space_used = std::min( static_cast<uint64_t>( - ptr() - const_cast<Block*>(head())->Pointer(kBlockHeaderSize)), + ptr() - const_cast<ArenaBlock*>(head())->Pointer(kBlockHeaderSize)), current_block_size); space_used += space_used_.load(std::memory_order_relaxed); // Remove the overhead of the SerialArena itself. @@ -208,7 +208,7 @@ } void SerialArena::CleanupList() { - Block* b = head(); + ArenaBlock* b = head(); b->cleanup_nodes = limit_; do { char* limit = reinterpret_cast<char*>(
diff --git a/src/google/protobuf/arena.h b/src/google/protobuf/arena.h index 4bc3994..d3dec65 100644 --- a/src/google/protobuf/arena.h +++ b/src/google/protobuf/arena.h
@@ -252,9 +252,6 @@ inline ~Arena() {} - // TODO(protobuf-team): Fix callers to use constructor and delete this method. - void Init(const ArenaOptions&) {} - // API to create proto2 message objects on the arena. If the arena passed in // is nullptr, then a heap allocated object is returned. Type T must be a // message defined in a .proto file with cc_enable_arenas set to true,
diff --git a/src/google/protobuf/arena_impl.h b/src/google/protobuf/arena_impl.h index 2eb6c50..b8969a5 100644 --- a/src/google/protobuf/arena_impl.h +++ b/src/google/protobuf/arena_impl.h
@@ -90,6 +90,29 @@ } } +// Arena blocks are variable length malloc-ed objects. The following structure +// describes the common header for all blocks. +struct ArenaBlock { + ArenaBlock(ArenaBlock* next, size_t size) + : next(next), cleanup_nodes(nullptr), relaxed_size(size) { + GOOGLE_DCHECK_GT(size, sizeof(ArenaBlock)); + } + + char* Pointer(size_t n) { + GOOGLE_DCHECK(n <= size()); + return reinterpret_cast<char*>(this) + n; + } + + size_t size() const { return relaxed_size.load(std::memory_order_relaxed); } + + ArenaBlock* const next; + void* cleanup_nodes; + + private: + const std::atomic<size_t> relaxed_size; + // data follows +}; + namespace cleanup { template <typename T> @@ -545,29 +568,8 @@ template <typename Deallocator> Memory Free(Deallocator deallocator); - // Blocks are variable length malloc-ed objects. The following structure - // describes the common header for all blocks. - struct Block { - Block(Block* next, size_t size) - : next(next), cleanup_nodes(nullptr), relaxed_size(size) {} - - char* Pointer(size_t n) { - GOOGLE_DCHECK(n <= size()); - return reinterpret_cast<char*>(this) + n; - } - - size_t size() const { return relaxed_size.load(std::memory_order_relaxed); } - - Block* const next; - void* cleanup_nodes; - - private: - const std::atomic<size_t> relaxed_size; - // data follows - }; - ThreadSafeArena& parent_; - std::atomic<Block*> head_; // Head of linked list of blocks. + std::atomic<ArenaBlock*> head_; // Head of linked list of blocks. std::atomic<size_t> space_used_{0}; // Necessary for metrics. std::atomic<size_t> space_allocated_; @@ -577,9 +579,11 @@ std::atomic<char*> ptr_; // Helper getters/setters to handle relaxed operations on atomic variables. - Block* head() { return head_.load(std::memory_order_relaxed); } - const Block* head() const { return head_.load(std::memory_order_relaxed); } - void set_head(Block* head) { + ArenaBlock* head() { return head_.load(std::memory_order_relaxed); } + const ArenaBlock* head() const { + return head_.load(std::memory_order_relaxed); + } + void set_head(ArenaBlock* head) { return head_.store(head, std::memory_order_relaxed); } char* ptr() { return ptr_.load(std::memory_order_relaxed); } @@ -604,7 +608,8 @@ CachedBlock** cached_blocks_ = nullptr; // Constructor is private as only New() should be used. - inline SerialArena(Block* b, ThreadSafeArena& parent); + inline SerialArena(ArenaBlock* b, ThreadSafeArena& parent); + void* AllocateAlignedFallback(size_t n); void* AllocateAlignedWithCleanupFallback(size_t n, size_t align, void (*destructor)(void*)); @@ -612,7 +617,7 @@ void AllocateNewBlock(size_t n); public: - static constexpr size_t kBlockHeaderSize = AlignUpTo8(sizeof(Block)); + static constexpr size_t kBlockHeaderSize = AlignUpTo8(sizeof(ArenaBlock)); }; // Tag type used to invoke the constructor of message-owned arena.
diff --git a/src/google/protobuf/compiler/code_generator.cc b/src/google/protobuf/compiler/code_generator.cc index 6c1a967..3f48e37 100644 --- a/src/google/protobuf/compiler/code_generator.cc +++ b/src/google/protobuf/compiler/code_generator.cc
@@ -38,8 +38,8 @@ #include "google/protobuf/stubs/common.h" #include "google/protobuf/compiler/plugin.pb.h" #include "google/protobuf/descriptor.h" -#include "google/protobuf/stubs/strutil.h" #include "absl/strings/str_split.h" +#include "absl/strings/strip.h" namespace google { namespace protobuf { @@ -126,10 +126,10 @@ // Strips ".proto" or ".protodevel" from the end of a filename. std::string StripProto(const std::string& filename) { - if (HasSuffixString(filename, ".protodevel")) { - return StripSuffixString(filename, ".protodevel"); + if (absl::EndsWith(filename, ".protodevel")) { + return std::string(absl::StripSuffix(filename, ".protodevel")); } else { - return StripSuffixString(filename, ".proto"); + return std::string(absl::StripSuffix(filename, ".proto")); } }
diff --git a/src/google/protobuf/compiler/command_line_interface.cc b/src/google/protobuf/compiler/command_line_interface.cc index 09d82f0..dba9729 100644 --- a/src/google/protobuf/compiler/command_line_interface.cc +++ b/src/google/protobuf/compiler/command_line_interface.cc
@@ -75,6 +75,7 @@ #include "google/protobuf/compiler/subprocess.h" #include "google/protobuf/compiler/plugin.pb.h" #include "google/protobuf/stubs/strutil.h" +#include "absl/strings/match.h" #include "google/protobuf/stubs/stringprintf.h" #include "absl/strings/str_replace.h" #include "absl/strings/str_split.h" @@ -1065,9 +1066,9 @@ if (mode_ == MODE_COMPILE) { for (int i = 0; i < output_directives_.size(); i++) { std::string output_location = output_directives_[i].output_location; - if (!HasSuffixString(output_location, ".zip") && - !HasSuffixString(output_location, ".jar") && - !HasSuffixString(output_location, ".srcjar")) { + if (!absl::EndsWith(output_location, ".zip") && + !absl::EndsWith(output_location, ".jar") && + !absl::EndsWith(output_location, ".srcjar")) { AddTrailingSlash(&output_location); } @@ -1088,12 +1089,12 @@ for (const auto& pair : output_directories) { const std::string& location = pair.first; GeneratorContextImpl* directory = pair.second.get(); - if (HasSuffixString(location, "/")) { + if (absl::EndsWith(location, "/")) { if (!directory->WriteAllToDisk(location)) { return 1; } } else { - if (HasSuffixString(location, ".jar")) { + if (absl::EndsWith(location, ".jar")) { directory->AddJarManifest(); } @@ -1971,7 +1972,7 @@ // Some other flag. Look it up in the generators list. const GeneratorInfo* generator_info = FindGeneratorByFlag(name); if (generator_info == nullptr && - (plugin_prefix_.empty() || !HasSuffixString(name, "_out"))) { + (plugin_prefix_.empty() || !absl::EndsWith(name, "_out"))) { // Check if it's a generator option flag. generator_info = FindGeneratorByOption(name); if (generator_info != nullptr) { @@ -1981,7 +1982,7 @@ parameters->append(","); } parameters->append(value); - } else if (HasPrefixString(name, "--") && HasSuffixString(name, "_opt")) { + } else if (absl::StartsWith(name, "--") && absl::EndsWith(name, "_opt")) { std::string* parameters = &plugin_parameters_[PluginName(plugin_prefix_, name)]; if (!parameters->empty()) { @@ -2165,8 +2166,8 @@ std::string error; if (output_directive.generator == nullptr) { // This is a plugin. - GOOGLE_CHECK(HasPrefixString(output_directive.name, "--") && - HasSuffixString(output_directive.name, "_out")) + GOOGLE_CHECK(absl::StartsWith(output_directive.name, "--") && + absl::EndsWith(output_directive.name, "_out")) << "Bad name for plugin generator: " << output_directive.name; std::string plugin_name = PluginName(plugin_prefix_, output_directive.name);
diff --git a/src/google/protobuf/compiler/command_line_interface_unittest.cc b/src/google/protobuf/compiler/command_line_interface_unittest.cc index 6b330b8..1ac81e6 100644 --- a/src/google/protobuf/compiler/command_line_interface_unittest.cc +++ b/src/google/protobuf/compiler/command_line_interface_unittest.cc
@@ -794,6 +794,7 @@ "bar.proto", "Bar"); } + TEST_F(CommandLineInterfaceTest, MultipleInputsWithImport_DescriptorSetIn) { // Test parsing multiple input files with an import of a separate file. FileDescriptorSet file_descriptor_set;
diff --git a/src/google/protobuf/compiler/cpp/BUILD.bazel b/src/google/protobuf/compiler/cpp/BUILD.bazel index 8d6657d..4463a09 100644 --- a/src/google/protobuf/compiler/cpp/BUILD.bazel +++ b/src/google/protobuf/compiler/cpp/BUILD.bazel
@@ -56,6 +56,7 @@ "//src/google/protobuf:protobuf_nowkt", "//src/google/protobuf/compiler:code_generator", "@com_google_absl//absl/base:core_headers", + "@com_google_absl//absl/container:btree", "@com_google_absl//absl/container:flat_hash_map", "@com_google_absl//absl/container:flat_hash_set", "@com_google_absl//absl/container:layout",
diff --git a/src/google/protobuf/compiler/cpp/file.cc b/src/google/protobuf/compiler/cpp/file.cc index dff09a8..729e66e 100644 --- a/src/google/protobuf/compiler/cpp/file.cc +++ b/src/google/protobuf/compiler/cpp/file.cc
@@ -38,21 +38,32 @@ #include <map> #include <memory> #include <set> +#include <string> #include <unordered_map> #include <unordered_set> #include <vector> #include "google/protobuf/compiler/scc.h" +#include "absl/container/btree_map.h" +#include "absl/container/btree_set.h" +#include "absl/container/flat_hash_map.h" +#include "absl/container/flat_hash_set.h" #include "absl/strings/escaping.h" +#include "absl/strings/match.h" #include "absl/strings/str_cat.h" +#include "google/protobuf/stubs/stringprintf.h" #include "absl/strings/str_replace.h" +#include "absl/strings/string_view.h" +#include "absl/strings/strip.h" #include "google/protobuf/compiler/cpp/enum.h" #include "google/protobuf/compiler/cpp/extension.h" #include "google/protobuf/compiler/cpp/helpers.h" #include "google/protobuf/compiler/cpp/message.h" +#include "google/protobuf/compiler/cpp/names.h" #include "google/protobuf/compiler/cpp/service.h" #include "google/protobuf/descriptor.h" #include "google/protobuf/descriptor.pb.h" +#include "google/protobuf/io/printer.h" // Must be last. #include "google/protobuf/port_def.inc" @@ -61,103 +72,101 @@ namespace protobuf { namespace compiler { namespace cpp { - 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> -std::string GetSortKey(const T& val) { - return val.full_name(); -} - -template <> -std::string GetSortKey<FileDescriptor>(const FileDescriptor& val) { - return val.name(); -} - -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; +absl::flat_hash_map<std::string, std::string> FileVars( + const FileDescriptor* file, const Options& options) { + return { + {"filename", file->name()}, + {"package_ns", Namespace(file, options)}, + {"tablename", UniqueName("TableStruct", file, options)}, + {"desc_table", DescriptorTableName(file, options)}, + {"dllexport_decl", options.dllexport_decl}, + {"file_level_metadata", UniqueName("file_level_metadata", file, options)}, + {"file_level_enum_descriptors", + UniqueName("file_level_enum_descriptors", file, options)}, + {"file_level_service_descriptors", + UniqueName("file_level_service_descriptors", file, options)}, + }; } // TODO(b/203101078): remove pragmas that suppresses uninitialized warnings when // clang bug is fixed. -inline void MuteWuninitialized(Formatter& format) { - format( - "#if defined(__llvm__)\n" - " #pragma clang diagnostic push\n" - " #pragma clang diagnostic ignored \"-Wuninitialized\"\n" - "#endif // __llvm__\n"); +void MuteWuninitialized(io::Printer* p) { + p->Emit(R"( + #if defined(__llvm__) + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wuninitialized" + #endif // __llvm__ + )"); } -inline void UnmuteWuninitialized(Formatter& format) { - format( - "#if defined(__llvm__)\n" - " #pragma clang diagnostic pop\n" - "#endif // __llvm__\n"); +void UnmuteWuninitialized(io::Printer* p) { + p->Emit(R"( + #if defined(__llvm__) + #pragma clang diagnostic pop + #endif // __llvm__ + )"); } - } // 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 - variables_["dllexport_decl"] = options.dllexport_decl; - variables_["tablename"] = UniqueName("TableStruct", file_, options_); - variables_["file_level_metadata"] = - UniqueName("file_level_metadata", file_, options_); - variables_["desc_table"] = DescriptorTableName(file_, options_); - variables_["file_level_enum_descriptors"] = - UniqueName("file_level_enum_descriptors", file_, options_); - variables_["file_level_service_descriptors"] = - UniqueName("file_level_service_descriptors", file_, options_); - variables_["filename"] = file_->name(); - variables_["package_ns"] = Namespace(file_, options); - std::vector<const Descriptor*> msgs = FlattenMessagesInFile(file); - for (int i = 0; i < msgs.size(); i++) { - // Deleted in destructor - MessageGenerator* msg_gen = - new MessageGenerator(msgs[i], variables_, i, options, &scc_analyzer_); - message_generators_.emplace_back(msg_gen); - msg_gen->AddGenerators(&enum_generators_, &extension_generators_); + + for (int i = 0; i < msgs.size(); ++i) { + message_generators_.push_back(absl::make_unique<MessageGenerator>( + msgs[i], variables_, i, options, &scc_analyzer_)); + message_generators_.back()->AddGenerators(&enum_generators_, + &extension_generators_); } - for (int i = 0; i < file->enum_type_count(); i++) { - enum_generators_.emplace_back( - new EnumGenerator(file->enum_type(i), variables_, options)); + for (int i = 0; i < file->enum_type_count(); ++i) { + enum_generators_.push_back(absl::make_unique<EnumGenerator>( + file->enum_type(i), variables_, options)); } - for (int i = 0; i < file->service_count(); i++) { - service_generators_.emplace_back( - new ServiceGenerator(file->service(i), variables_, options)); + for (int i = 0; i < file->service_count(); ++i) { + service_generators_.push_back(absl::make_unique<ServiceGenerator>( + file->service(i), variables_, options)); } if (HasGenericServices(file_, options_)) { - for (int i = 0; i < service_generators_.size(); i++) { + 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, &scc_analyzer_)); + + for (int i = 0; i < file->extension_count(); ++i) { + extension_generators_.push_back(absl::make_unique<ExtensionGenerator>( + file->extension(i), options, &scc_analyzer_)); } + for (int i = 0; i < file->weak_dependency_count(); ++i) { weak_deps_.insert(file->weak_dependency(i)); } } -FileGenerator::~FileGenerator() = default; +void FileGenerator::GenerateFile(io::Printer* p, GeneratedFileType file_type, + std::function<void()> cb) { + auto v = p->WithVars(FileVars(file_, options_)); + auto guard = IncludeGuard(file_, file_type, options_); + p->Emit({{"cb", cb}, {"guard", guard}}, R"( + // Generated by the protocol buffer compiler. DO NOT EDIT! + // source: $filename$ -void FileGenerator::GenerateMacroUndefs(io::Printer* printer) { - Formatter format(printer, variables_); + #ifndef $guard$ + #define $guard$ + + #include <limits> + #include <string> + #include <type_traits> + + $cb$; + + #endif // $guard$ + )"); +} + +void FileGenerator::GenerateMacroUndefs(io::Printer* p) { // Only do this for protobuf's own types. There are some google3 protos using // macros as field names and the generated code compiles after the macro // expansion. Undefing these macros actually breaks such code. @@ -165,412 +174,471 @@ file_->name() != "google/protobuf/compiler/plugin.proto") { return; } - std::vector<std::string> names_to_undef; + std::vector<const FieldDescriptor*> fields; ListAllFields(file_, &fields); - for (int i = 0; i < fields.size(); i++) { - const std::string& name = fields[i]->name(); - static const char* kMacroNames[] = {"major", "minor"}; - for (int j = 0; j < ABSL_ARRAYSIZE(kMacroNames); ++j) { - if (name == kMacroNames[j]) { - names_to_undef.push_back(name); - break; - } + + absl::flat_hash_set<absl::string_view> all_fields; + for (const FieldDescriptor* field : fields) { + all_fields.insert(field->name()); + } + + for (absl::string_view name : {"major", "minor"}) { + if (!all_fields.contains(name)) { + continue; } - } - for (int i = 0; i < names_to_undef.size(); ++i) { - format( - "#ifdef $1$\n" - "#undef $1$\n" - "#endif\n", - names_to_undef[i]); + + p->Emit({{"name", std::string(name)}}, R"( + #ifdef $name$ + #undef $name$ + #endif // $name$ + )"); } } -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); +void FileGenerator::GenerateSharedHeaderCode(io::Printer* p) { + p->Emit( + { + {"port_def", + [&] { IncludeFile("net/proto2/public/port_def.inc", p); }}, + {"port_undef", + [&] { IncludeFile("net/proto2/public/port_undef.inc", p); }}, + {"dllexport_macro", FileDllExport(file_, options_)}, + {"undefs", [&] { GenerateMacroUndefs(p); }}, + {"global_state_decls", + [&] { GenerateGlobalStateFunctionDeclarations(p); }}, + {"fwd_decls", [&] { GenerateForwardDeclarations(p); }}, + {"proto2_ns_enums", + [&] { GenerateProto2NamespaceEnumSpecializations(p); }}, + {"main_decls", + [&] { + NamespaceOpener ns(Namespace(file_, options_), p); + p->Emit( + { + {"enums", [&] { GenerateEnumDefinitions(p); }}, + {"messages", [&] { GenerateMessageDefinitions(p); }}, + {"services", [&] { GenerateServiceDefinitions(p); }}, + {"extensions", [&] { GenerateExtensionIdentifiers(p); }}, + {"inline_fns", + [&] { GenerateInlineFunctionDefinitions(p); }}, + }, + R"( + $enums$ - // For Any support with lite protos, we need to friend AnyMetadata, so we - // forward-declare it here. - format( - "PROTOBUF_NAMESPACE_OPEN\n" - "namespace internal {\n" - "class AnyMetadata;\n" - "} // namespace internal\n" - "PROTOBUF_NAMESPACE_CLOSE\n"); + $hrule_thick$ - GenerateGlobalStateFunctionDeclarations(printer); + $messages$ - GenerateForwardDeclarations(printer); + $hrule_thick$ - { - NamespaceOpener ns(Namespace(file_, options_), format); + $services$ - format("\n"); + $extensions$ - GenerateEnumDefinitions(printer); + $hrule_thick$ - format(kThickSeparator); - format("\n"); + $inline_fns$ - GenerateMessageDefinitions(printer); + // @@protoc_insertion_point(namespace_scope) + )"); + }}, + }, + R"( + // Must be included last. + $port_def$ - format("\n"); - format(kThickSeparator); - format("\n"); + #define $dllexport_macro$$ dllexport_decl$ + $undefs$ - GenerateServiceDefinitions(printer); + PROTOBUF_NAMESPACE_OPEN + namespace internal { + class AnyMetadata; + } // namespace internal + PROTOBUF_NAMESPACE_CLOSE - GenerateExtensionIdentifiers(printer); + $global_state_decls$; + $fwd_decls$ - format("\n"); - format(kThickSeparator); - format("\n"); + $main_decls$ - GenerateInlineFunctionDefinitions(printer); + $proto2_ns_enums$ - format( - "\n" - "// @@protoc_insertion_point(namespace_scope)\n" - "\n"); - } + // @@protoc_insertion_point(global_scope) - // We need to specialize some templates in the ::google::protobuf namespace: - GenerateProto2NamespaceEnumSpecializations(printer); - - format( - "\n" - "// @@protoc_insertion_point(global_scope)\n" - "\n"); - IncludeFile("net/proto2/public/port_undef.inc", printer); + $port_undef$ + )"); } -void FileGenerator::GenerateProtoHeader(io::Printer* printer, - const std::string& info_path) { - Formatter format(printer, variables_); +void FileGenerator::GenerateProtoHeader(io::Printer* p, + absl::string_view info_path) { if (!options_.proto_h) { return; } - GenerateTopHeaderGuard(printer, - google::protobuf::compiler::cpp::GeneratedFileType::kProtoH); - - if (!options_.opensource_runtime) { - format( - "#ifdef SWIG\n" - "#error \"Do not SWIG-wrap protobufs.\"\n" - "#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); - format("#include \"$1$.proto.h\"\n", StripProto(dep->name())); - } - - format("// @@protoc_insertion_point(includes)\n"); - - GenerateMetadataPragma(printer, info_path); - - GenerateHeader(printer); - - GenerateBottomHeaderGuard(printer, - google::protobuf::compiler::cpp::GeneratedFileType::kProtoH); -} - -void FileGenerator::GeneratePBHeader(io::Printer* printer, - const std::string& info_path) { - Formatter format(printer, variables_); - GenerateTopHeaderGuard(printer, - google::protobuf::compiler::cpp::GeneratedFileType::kPbH); - - if (options_.proto_h) { - std::string target_basename = StripProto(file_->name()); + GenerateFile(p, GeneratedFileType::kProtoH, [&] { if (!options_.opensource_runtime) { - GetBootstrapBasename(options_, target_basename, &target_basename); + p->Emit(R"( + #ifdef SWIG + #error "Do not SWIG-wrap protobufs." + #endif // SWIG + )"); } - format("#include \"$1$.proto.h\" // IWYU pragma: export\n", - target_basename); - } else { - GenerateLibraryIncludes(printer); - } - - if (options_.transitive_pb_h) { - GenerateDependencyIncludes(printer); - } - - // This is unfortunately necessary for some plugins. I don't see why we - // need two of the same insertion points. - // TODO(gerbens) remove this. - format("// @@protoc_insertion_point(includes)\n"); - - GenerateMetadataPragma(printer, info_path); - - if (!options_.proto_h) { - GenerateHeader(printer); - } else { - { - NamespaceOpener ns(Namespace(file_, options_), format); - format( - "\n" - "// @@protoc_insertion_point(namespace_scope)\n"); + if (IsBootstrapProto(options_, file_)) { + p->Emit({{"name", StripProto(file_->name())}}, R"cc( + // IWYU pragma: private, include "$name$.proto.h" + )cc"); } - format( - "\n" - "// @@protoc_insertion_point(global_scope)\n" - "\n"); - } - GenerateBottomHeaderGuard(printer, - google::protobuf::compiler::cpp::GeneratedFileType::kPbH); + p->Emit( + { + {"library_includes", [&] { GenerateLibraryIncludes(p); }}, + {"proto_includes", + [&] { + for (int i = 0; i < file_->public_dependency_count(); ++i) { + const FileDescriptor* dep = file_->public_dependency(i); + p->Emit({{"name", StripProto(dep->name())}}, R"( + #include "$name$.proto.h" + )"); + } + }}, + {"metadata_pragma", [&] { GenerateMetadataPragma(p, info_path); }}, + {"header_main", [&] { GenerateSharedHeaderCode(p); }}, + }, + R"cc( + $library_includes$; + $proto_includes$; + // @@protoc_insertion_point(includes) + + $metadata_pragma$; + $header_main$; + )cc"); + }); } -void FileGenerator::DoIncludeFile(const std::string& google3_name, - bool do_export, io::Printer* printer) { - Formatter format(printer, variables_); - const std::string prefix = "net/proto2/"; - GOOGLE_CHECK(google3_name.find(prefix) == 0) << google3_name; +void FileGenerator::GeneratePBHeader(io::Printer* p, + absl::string_view info_path) { + GenerateFile(p, GeneratedFileType::kPbH, [&] { + p->Emit( + { + {"library_includes", + [&] { + if (options_.proto_h) { + std::string target_basename = StripProto(file_->name()); + if (!options_.opensource_runtime) { + GetBootstrapBasename(options_, target_basename, + &target_basename); + } + p->Emit({{"name", target_basename}}, R"( + #include "$name$.proto.h" // IWYU pragma: export + )"); + } else { + GenerateLibraryIncludes(p); + } + }}, + {"proto_includes", + [&] { + if (options_.transitive_pb_h) { + GenerateDependencyIncludes(p); + } + }}, + {"metadata_pragma", [&] { GenerateMetadataPragma(p, info_path); }}, + {"header_main", + [&] { + if (!options_.proto_h) { + GenerateSharedHeaderCode(p); + return; + } + + { + NamespaceOpener ns(Namespace(file_, options_), p); + p->Emit(R"cc( + + // @@protoc_insertion_point(namespace_scope) + )cc"); + } + p->Emit(R"cc( + + // @@protoc_insertion_point(global_scope) + )cc"); + }}, + }, + R"cc( + $library_includes$; + $proto_includes$; + // @@protoc_insertion_point(includes) + + $metadata_pragma$; + $header_main$; + )cc"); + }); +} + +void FileGenerator::DoIncludeFile(absl::string_view google3_name, + bool do_export, io::Printer* p) { + absl::string_view prefix = "net/proto2/"; + GOOGLE_CHECK(absl::StartsWith(google3_name, prefix)) << google3_name; + + auto v = p->WithVars( + {{"export_suffix", do_export ? "// IWYU pragma: export" : ""}}); if (options_.opensource_runtime) { - std::string path = google3_name.substr(prefix.size()); + absl::ConsumePrefix(&google3_name, prefix); + std::string path(google3_name); path = StringReplace(path, "internal/", "", false); path = StringReplace(path, "proto/", "", false); path = StringReplace(path, "public/", "", false); + if (options_.runtime_include_base.empty()) { - format("#include \"google/protobuf/$1$\"", path); + p->Emit({{"path", path}}, R"( + #include "google/protobuf/$path$"$ export_suffix$ + )"); } else { - format("#include \"$1$google/protobuf/$2$\"", - options_.runtime_include_base, path); + p->Emit({{"base", options_.runtime_include_base}, {"path", path}}, R"( + #include "$base$google/protobuf/$path$"$ export_suffix$ + )"); } } else { - std::string path = google3_name; + std::string path(google3_name); // The bootstrapped proto generated code needs to use the // third_party/protobuf header paths to avoid circular dependencies. if (options_.bootstrap) { - path = StringReplace(google3_name, "net/proto2/public", - "third_party/protobuf", false); + path = StringReplace(path, "net/proto2/public", "third_party/protobuf", + false); } - format("#include \"$1$\"", path); - } - if (do_export) { - format(" // IWYU pragma: export"); + p->Emit({{"path", path}}, R"( + #include "$path$"$ export_suffix$ + )"); } - - format("\n"); } -std::string FileGenerator::CreateHeaderInclude(const std::string& basename, +std::string FileGenerator::CreateHeaderInclude(absl::string_view basename, const FileDescriptor* file) { - bool use_system_include = false; - std::string name = basename; - - if (options_.opensource_runtime) { - if (IsWellKnownMessage(file)) { - if (options_.runtime_include_base.empty()) { - use_system_include = true; - } else { - name = options_.runtime_include_base + basename; - } - } + if (options_.opensource_runtime && IsWellKnownMessage(file) && + !options_.runtime_include_base.empty()) { + return absl::StrCat("\"", options_.runtime_include_base, basename, "\""); } - std::string left = "\""; - std::string right = "\""; - if (use_system_include) { - left = "<"; - right = ">"; - } - return left + name + right; + return absl::StrCat("\"", basename, "\""); } -void FileGenerator::GenerateSourceIncludes(io::Printer* printer) { - Formatter format(printer, variables_); +void FileGenerator::GenerateSourceIncludes(io::Printer* p) { std::string target_basename = StripProto(file_->name()); if (!options_.opensource_runtime) { GetBootstrapBasename(options_, target_basename, &target_basename); } - target_basename += options_.proto_h ? ".proto.h" : ".pb.h"; - format( - "// Generated by the protocol buffer compiler. DO NOT EDIT!\n" - "// source: $filename$\n" - "\n" - "#include $1$\n" - "\n" - "#include <algorithm>\n" // for swap() - "\n", - CreateHeaderInclude(target_basename, file_)); - IncludeFile("net/proto2/io/public/coded_stream.h", printer); + absl::StrAppend(&target_basename, options_.proto_h ? ".proto.h" : ".pb.h"); + p->Emit({{"h_include", CreateHeaderInclude(target_basename, file_)}}, + R"( + // Generated by the protocol buffer compiler. DO NOT EDIT! + // source: $filename$ + + #include $h_include$ + + #include <algorithm> + )"); + + IncludeFile("net/proto2/io/public/coded_stream.h", p); // TODO(gerbens) This is to include parse_context.h, we need a better way - IncludeFile("net/proto2/public/extension_set.h", printer); - IncludeFile("net/proto2/public/wire_format_lite.h", printer); + IncludeFile("net/proto2/public/extension_set.h", p); + IncludeFile("net/proto2/public/wire_format_lite.h", p); // Unknown fields implementation in lite mode uses StringOutputStream if (!UseUnknownFieldSet(file_, options_) && !message_generators_.empty()) { - IncludeFile("net/proto2/io/public/zero_copy_stream_impl_lite.h", printer); + IncludeFile("net/proto2/io/public/zero_copy_stream_impl_lite.h", p); } if (HasDescriptorMethods(file_, options_)) { - IncludeFile("net/proto2/public/descriptor.h", printer); - IncludeFile("net/proto2/public/generated_message_reflection.h", printer); - IncludeFile("net/proto2/public/reflection_ops.h", printer); - IncludeFile("net/proto2/public/wire_format.h", printer); + IncludeFile("net/proto2/public/descriptor.h", p); + IncludeFile("net/proto2/public/generated_message_reflection.h", p); + IncludeFile("net/proto2/public/reflection_ops.h", p); + IncludeFile("net/proto2/public/wire_format.h", p); } if (HasGeneratedMethods(file_, options_) && options_.tctable_mode != Options::kTCTableNever) { - IncludeFile("net/proto2/public/generated_message_tctable_impl.h", printer); + IncludeFile("net/proto2/public/generated_message_tctable_impl.h", p); } if (options_.proto_h) { // Use the smaller .proto.h files. - for (int i = 0; i < file_->dependency_count(); i++) { + for (int i = 0; i < file_->dependency_count(); ++i) { const FileDescriptor* dep = file_->dependency(i); - // Do not import weak deps. - if (!options_.opensource_runtime && IsDepWeak(dep)) continue; + + if (!options_.opensource_runtime && + IsDepWeak(dep)) { // Do not import weak deps. + continue; + } + std::string basename = StripProto(dep->name()); if (IsBootstrapProto(options_, file_)) { GetBootstrapBasename(options_, basename, &basename); } - format("#include \"$1$.proto.h\"\n", basename); + p->Emit({{"name", basename}}, R"( + #include "$name$.proto.h" + )"); } } + if (HasCordFields(file_, options_)) { - format( - "#include \"third_party/absl/strings/internal/string_constant.h\"\n"); + p->Emit(R"( + #include "third_party/absl/strings/internal/string_constant.h" + )"); } - format("// @@protoc_insertion_point(includes)\n"); - IncludeFile("net/proto2/public/port_def.inc", printer); + p->Emit(R"cc( + // @@protoc_insertion_point(includes) + + // Must be included last. + )cc"); + IncludeFile("net/proto2/public/port_def.inc", p); } -void FileGenerator::GenerateSourcePrelude(io::Printer* printer) { - Formatter format(printer, variables_); - +void FileGenerator::GenerateSourcePrelude(io::Printer* p) { // For MSVC builds, we use #pragma init_seg to move the initialization of our // libraries to happen before the user code. // This worksaround the fact that MSVC does not do constant initializers when // required by the standard. - format("\nPROTOBUF_PRAGMA_INIT_SEG\n"); + p->Emit(R"cc( + PROTOBUF_PRAGMA_INIT_SEG + namespace _pb = ::$proto_ns$; + namespace _pbi = ::$proto_ns$::internal; + )cc"); - // Generate convenience aliases. - format( - "\n" - "namespace _pb = ::$1$;\n" - "namespace _pbi = _pb::internal;\n", - ProtobufNamespace(options_)); if (HasGeneratedMethods(file_, options_) && options_.tctable_mode != Options::kTCTableNever) { - format("namespace _fl = _pbi::field_layout;\n"); + p->Emit(R"cc( + namespace _fl = ::$proto_ns$::internal::field_layout; + )cc"); } - format("\n"); } -void FileGenerator::GenerateSourceDefaultInstance(int idx, - io::Printer* printer) { - Formatter format(printer, variables_); +void FileGenerator::GenerateSourceDefaultInstance(int idx, io::Printer* p) { MessageGenerator* generator = message_generators_[idx].get(); + // Generate the split instance first because it's needed in the constexpr // constructor. if (ShouldSplit(generator->descriptor_, options_)) { // Use a union to disable the destructor of the _instance member. // We can constant initialize, but the object will still have a non-trivial // destructor that we need to elide. - format( - "struct $1$ {\n" - " PROTOBUF_CONSTEXPR $1$()\n" - " : _instance{", - DefaultInstanceType(generator->descriptor_, options_, - /*split=*/true)); - generator->GenerateInitDefaultSplitInstance(printer); - format( - "} {}\n" - " union {\n" - " $1$ _instance;\n" - " };\n" - "};\n", - absl::StrCat(generator->classname_, "::Impl_::Split")); + // // NO_DESTROY is not necessary for correctness. The empty destructor is // enough. However, the empty destructor fails to be elided in some // configurations (like non-opt or with certain sanitizers). NO_DESTROY is // there just to improve performance and binary size in these builds. - format( - "PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT " - "PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 const $1$ $2$;\n", - DefaultInstanceType(generator->descriptor_, options_, /*split=*/true), - DefaultInstanceName(generator->descriptor_, options_, /*split=*/true)); + p->Emit( + { + {"type", DefaultInstanceType(generator->descriptor_, options_, + /*split=*/true)}, + {"name", DefaultInstanceName(generator->descriptor_, options_, + /*split=*/true)}, + {"default", + [&] { generator->GenerateInitDefaultSplitInstance(p); }}, + {"class", absl::StrCat(generator->classname_, "::Impl_::Split")}, + }, + R"cc( + struct $type$ { + PROTOBUF_CONSTEXPR $type$() : _instance{$default$} {} + union { + $class$ _instance; + }; + }; + + PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 const $type$ $name$; + )cc"); } - generator->GenerateConstexprConstructor(printer); - format( - "struct $1$ {\n" - " PROTOBUF_CONSTEXPR $1$()\n" - " : _instance(::_pbi::ConstantInitialized{}) {}\n" - " ~$1$() {}\n" - " union {\n" - " $2$ _instance;\n" - " };\n" - "};\n", - DefaultInstanceType(generator->descriptor_, options_), - generator->classname_); - format( - "PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT " - "PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 $1$ $2$;\n", - DefaultInstanceType(generator->descriptor_, options_), - DefaultInstanceName(generator->descriptor_, options_)); + generator->GenerateConstexprConstructor(p); - for (int i = 0; i < generator->descriptor_->field_count(); i++) { + p->Emit( + { + {"type", DefaultInstanceType(generator->descriptor_, options_)}, + {"name", DefaultInstanceName(generator->descriptor_, options_)}, + {"default", [&] { generator->GenerateInitDefaultSplitInstance(p); }}, + {"class", generator->classname_}, + }, + R"cc( + struct $type$ { + PROTOBUF_CONSTEXPR $type$() : _instance(::_pbi::ConstantInitialized{}) {} + ~$type$() {} + union { + $class$ _instance; + }; + }; + + PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 $type$ $name$; + )cc"); + + for (int i = 0; i < generator->descriptor_->field_count(); ++i) { const FieldDescriptor* field = generator->descriptor_->field(i); - if (IsStringInlined(field, options_)) { - // Force the initialization of the inlined string in the default instance. - format( - "PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 std::true_type " - "$1$::Impl_::_init_inline_$2$_ = " - "($3$._instance.$4$.Init(), std::true_type{});\n", - ClassName(generator->descriptor_), FieldName(field), - DefaultInstanceName(generator->descriptor_, options_), - FieldMemberName(field, ShouldSplit(field, options_))); + if (!IsStringInlined(field, options_)) { + continue; } + + // Force the initialization of the inlined string in the default instance. + p->Emit( + { + {"class", ClassName(generator->descriptor_)}, + {"field", FieldName(field)}, + {"default", DefaultInstanceName(generator->descriptor_, options_)}, + {"member", FieldMemberName(field, ShouldSplit(field, options_))}, + }, + R"cc( + PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 std::true_type + $class$::Impl_::_init_inline_$field$_ = + ($default$._instance.$member$.Init(), std::true_type{}); + )cc"); } if (options_.lite_implicit_weak_fields) { - format( - "PROTOBUF_CONSTINIT const void* $1$ =\n" - " &$2$;\n", - DefaultInstancePtr(generator->descriptor_, options_), - DefaultInstanceName(generator->descriptor_, options_)); + p->Emit( + { + {"ptr", DefaultInstancePtr(generator->descriptor_, options_)}, + {"name", DefaultInstanceName(generator->descriptor_, options_)}, + }, + R"cc( + PROTOBUF_CONSTINIT const void* $ptr$ = &$name$; + )cc"); } } // A list of things defined in one .pb.cc file that we need to reference from // another .pb.cc file. struct FileGenerator::CrossFileReferences { + // When we forward-declare things, we want to create a sorted order so our + // output is deterministic and minimizes namespace changes. + struct DescCompare { + template <typename T> + bool operator()(const T* const& a, const T* const& b) const { + return a->full_name() < b->full_name(); + } + + bool operator()(const FileDescriptor* const& a, + const FileDescriptor* const& b) const { + return a->name() < b->name(); + } + }; + // Populated if we are referencing from messages or files. - std::unordered_set<const Descriptor*> weak_default_instances; + absl::btree_set<const Descriptor*, DescCompare> weak_default_instances; // Only if we are referencing from files. - std::unordered_set<const FileDescriptor*> strong_reflection_files; - std::unordered_set<const FileDescriptor*> weak_reflection_files; + absl::btree_set<const FileDescriptor*, DescCompare> strong_reflection_files; + absl::btree_set<const FileDescriptor*, DescCompare> weak_reflection_files; }; void FileGenerator::GetCrossFileReferencesForField(const FieldDescriptor* field, CrossFileReferences* refs) { const Descriptor* msg = field->message_type(); - if (msg == nullptr) return; + if (msg == nullptr) { + return; + } if (IsImplicitWeakField(field, options_, &scc_analyzer_) || IsWeak(field, options_)) { @@ -584,10 +652,13 @@ GetCrossFileReferencesForField(field, refs); }); - if (!HasDescriptorMethods(file, options_)) return; + if (!HasDescriptorMethods(file, options_)) { + return; + } - for (int i = 0; i < file->dependency_count(); i++) { + for (int i = 0; i < file->dependency_count(); ++i) { const FileDescriptor* dep = file->dependency(i); + if (IsDepWeak(dep)) { refs->weak_reflection_files.insert(dep); } else { @@ -598,119 +669,128 @@ // Generates references to variables defined in other files. void FileGenerator::GenerateInternalForwardDeclarations( - const CrossFileReferences& refs, io::Printer* printer) { - Formatter format(printer, variables_); - + const CrossFileReferences& refs, io::Printer* p) { { - NamespaceOpener ns(format); - for (auto instance : Sorted(refs.weak_default_instances)) { + NamespaceOpener ns(p); + for (auto instance : refs.weak_default_instances) { ns.ChangeTo(Namespace(instance, options_)); + if (options_.lite_implicit_weak_fields) { - format( - "PROTOBUF_CONSTINIT __attribute__((weak)) const void* $1$ =\n" - " &::_pbi::implicit_weak_message_default_instance;\n", - DefaultInstancePtr(instance, options_)); + p->Emit({{"ptr", DefaultInstancePtr(instance, options_)}}, R"cc( + PROTOBUF_CONSTINIT __attribute__((weak)) const void* $ptr$ = + &::_pbi::implicit_weak_message_default_instance; + )cc"); } else { - format("extern __attribute__((weak)) $1$ $2$;\n", - DefaultInstanceType(instance, options_), - DefaultInstanceName(instance, options_)); + p->Emit({{"type", DefaultInstanceType(instance, options_)}, + {"name", DefaultInstanceName(instance, options_)}}, + R"cc( + extern __attribute__((weak)) $type$ $name$; + )cc"); } } } - for (auto file : Sorted(refs.weak_reflection_files)) { - format( - "extern __attribute__((weak)) const ::_pbi::DescriptorTable $1$;\n", - DescriptorTableName(file, options_)); + for (auto file : refs.weak_reflection_files) { + p->Emit({{"table", DescriptorTableName(file, options_)}}, R"cc( + extern __attribute__((weak)) const ::_pbi::DescriptorTable $table$; + )cc"); } } -void FileGenerator::GenerateSourceForMessage(int idx, io::Printer* printer) { - Formatter format(printer, variables_); - GenerateSourceIncludes(printer); - GenerateSourcePrelude(printer); +void FileGenerator::GenerateSourceForMessage(int idx, io::Printer* p) { + auto v = p->WithVars(FileVars(file_, options_)); - if (IsAnyMessage(file_, options_)) MuteWuninitialized(format); + GenerateSourceIncludes(p); + GenerateSourcePrelude(p); + + if (IsAnyMessage(file_, options_)) { + MuteWuninitialized(p); + } CrossFileReferences refs; ForEachField(message_generators_[idx]->descriptor_, [this, &refs](const FieldDescriptor* field) { GetCrossFileReferencesForField(field, &refs); }); - GenerateInternalForwardDeclarations(refs, printer); - { // package namespace - NamespaceOpener ns(Namespace(file_, options_), format); - - // Define default instances - GenerateSourceDefaultInstance(idx, printer); - - // Generate classes. - format("\n"); - message_generators_[idx]->GenerateClassMethods(printer); - - format( - "\n" - "// @@protoc_insertion_point(namespace_scope)\n"); - } // end package namespace + GenerateInternalForwardDeclarations(refs, p); { - NamespaceOpener proto_ns(ProtobufNamespace(options_), format); - message_generators_[idx]->GenerateSourceInProto2Namespace(printer); + NamespaceOpener ns(Namespace(file_, options_), p); + p->Emit( + { + {"defaults", [&] { GenerateSourceDefaultInstance(idx, p); }}, + {"class_methods", + [&] { message_generators_[idx]->GenerateClassMethods(p); }}, + }, + R"cc( + $defaults$; + + $class_methods$; + + // @@protoc_insertion_point(namespace_scope) + )cc"); } - if (IsAnyMessage(file_, options_)) UnmuteWuninitialized(format); + { + NamespaceOpener proto_ns(ProtobufNamespace(options_), p); + message_generators_[idx]->GenerateSourceInProto2Namespace(p); + } - format( - "\n" - "// @@protoc_insertion_point(global_scope)\n"); + if (IsAnyMessage(file_, options_)) { + UnmuteWuninitialized(p); + } + + p->Emit(R"cc( + // @@protoc_insertion_point(global_scope) + )cc"); } -void FileGenerator::GenerateSourceForExtension(int idx, io::Printer* printer) { - Formatter format(printer, variables_); - GenerateSourceIncludes(printer); - GenerateSourcePrelude(printer); - NamespaceOpener ns(Namespace(file_, options_), format); - extension_generators_[idx]->GenerateDefinition(printer); +void FileGenerator::GenerateSourceForExtension(int idx, io::Printer* p) { + auto v = p->WithVars(FileVars(file_, options_)); + GenerateSourceIncludes(p); + GenerateSourcePrelude(p); + + NamespaceOpener ns(Namespace(file_, options_), p); + extension_generators_[idx]->GenerateDefinition(p); } -void FileGenerator::GenerateGlobalSource(io::Printer* printer) { - Formatter format(printer, variables_); - GenerateSourceIncludes(printer); - GenerateSourcePrelude(printer); +void FileGenerator::GenerateGlobalSource(io::Printer* p) { + auto v = p->WithVars(FileVars(file_, options_)); + GenerateSourceIncludes(p); + GenerateSourcePrelude(p); { // Define the code to initialize reflection. This code uses a global // constructor to register reflection data with the runtime pre-main. if (HasDescriptorMethods(file_, options_)) { - GenerateReflectionInitializationCode(printer); + GenerateReflectionInitializationCode(p); } } - NamespaceOpener ns(Namespace(file_, options_), format); - - // Generate enums. - for (int i = 0; i < enum_generators_.size(); i++) { - enum_generators_[i]->GenerateMethods(i, printer); + NamespaceOpener ns(Namespace(file_, options_), p); + for (int i = 0; i < enum_generators_.size(); ++i) { + enum_generators_[i]->GenerateMethods(i, p); } } -void FileGenerator::GenerateSource(io::Printer* printer) { - Formatter format(printer, variables_); - GenerateSourceIncludes(printer); - GenerateSourcePrelude(printer); +void FileGenerator::GenerateSource(io::Printer* p) { + auto v = p->WithVars(FileVars(file_, options_)); + + GenerateSourceIncludes(p); + GenerateSourcePrelude(p); CrossFileReferences refs; GetCrossFileReferencesForFile(file_, &refs); - GenerateInternalForwardDeclarations(refs, printer); + GenerateInternalForwardDeclarations(refs, p); - if (IsAnyMessage(file_, options_)) MuteWuninitialized(format); + if (IsAnyMessage(file_, options_)) { + MuteWuninitialized(p); + } { - NamespaceOpener ns(Namespace(file_, options_), format); - - // Define default instances - for (int i = 0; i < message_generators_.size(); i++) { - GenerateSourceDefaultInstance(i, printer); + NamespaceOpener ns(Namespace(file_, options_), p); + for (int i = 0; i < message_generators_.size(); ++i) { + GenerateSourceDefaultInstance(i, p); } } @@ -718,144 +798,155 @@ if (HasDescriptorMethods(file_, options_)) { // Define the code to initialize reflection. This code uses a global // constructor to register reflection data with the runtime pre-main. - GenerateReflectionInitializationCode(printer); + GenerateReflectionInitializationCode(p); } } { - NamespaceOpener ns(Namespace(file_, options_), format); + NamespaceOpener ns(Namespace(file_, options_), p); // Actually implement the protos // Generate enums. - for (int i = 0; i < enum_generators_.size(); i++) { - enum_generators_[i]->GenerateMethods(i, printer); + for (int i = 0; i < enum_generators_.size(); ++i) { + enum_generators_[i]->GenerateMethods(i, p); } // Generate classes. - for (int i = 0; i < message_generators_.size(); i++) { - format("\n"); - format(kThickSeparator); - format("\n"); - message_generators_[i]->GenerateClassMethods(printer); + for (int i = 0; i < message_generators_.size(); ++i) { + p->Emit(R"( + $hrule_thick$ + )"); + message_generators_[i]->GenerateClassMethods(p); } if (HasGenericServices(file_, options_)) { // Generate services. - for (int i = 0; i < service_generators_.size(); i++) { - if (i == 0) format("\n"); - format(kThickSeparator); - format("\n"); - service_generators_[i]->GenerateImplementation(printer); + for (int i = 0; i < service_generators_.size(); ++i) { + p->Emit(R"( + $hrule_thick$ + )"); + service_generators_[i]->GenerateImplementation(p); } } // Define extensions. - for (int i = 0; i < extension_generators_.size(); i++) { - extension_generators_[i]->GenerateDefinition(printer); + for (int i = 0; i < extension_generators_.size(); ++i) { + extension_generators_[i]->GenerateDefinition(p); } - format( - "\n" - "// @@protoc_insertion_point(namespace_scope)\n"); + p->Emit(R"cc( + // @@protoc_insertion_point(namespace_scope) + )cc"); } { - NamespaceOpener proto_ns(ProtobufNamespace(options_), format); - for (int i = 0; i < message_generators_.size(); i++) { - message_generators_[i]->GenerateSourceInProto2Namespace(printer); + NamespaceOpener proto_ns(ProtobufNamespace(options_), p); + for (int i = 0; i < message_generators_.size(); ++i) { + message_generators_[i]->GenerateSourceInProto2Namespace(p); } } - format( - "\n" - "// @@protoc_insertion_point(global_scope)\n"); + p->Emit(R"cc( + // @@protoc_insertion_point(global_scope) + )cc"); - if (IsAnyMessage(file_, options_)) UnmuteWuninitialized(format); + if (IsAnyMessage(file_, options_)) { + UnmuteWuninitialized(p); + } - IncludeFile("net/proto2/public/port_undef.inc", printer); + IncludeFile("net/proto2/public/port_undef.inc", p); } -void FileGenerator::GenerateReflectionInitializationCode(io::Printer* printer) { - Formatter format(printer, variables_); - +void FileGenerator::GenerateReflectionInitializationCode(io::Printer* p) { if (!message_generators_.empty()) { - format("static ::_pb::Metadata $file_level_metadata$[$1$];\n", - message_generators_.size()); + p->Emit({{"len", absl::StrCat(message_generators_.size())}}, R"cc( + static ::_pb::Metadata $file_level_metadata$[$len$]; + )cc"); } + if (!enum_generators_.empty()) { - format( - "static const ::_pb::EnumDescriptor* " - "$file_level_enum_descriptors$[$1$];\n", - enum_generators_.size()); + p->Emit({{"len", absl::StrCat(enum_generators_.size())}}, R"cc( + static const ::_pb::EnumDescriptor* $file_level_enum_descriptors$[$len$]; + )cc"); } else { - format( - "static " - "constexpr ::_pb::EnumDescriptor const** " - "$file_level_enum_descriptors$ = nullptr;\n"); + p->Emit(R"cc( + static constexpr const ::_pb::EnumDescriptor** + $file_level_enum_descriptors$ = nullptr; + )cc"); } + if (HasGenericServices(file_, options_) && file_->service_count() > 0) { - format( - "static " - "const ::_pb::ServiceDescriptor* " - "$file_level_service_descriptors$[$1$];\n", - file_->service_count()); + p->Emit({{"len", absl::StrCat(file_->service_count())}}, R"cc( + static const ::_pb::ServiceDescriptor* + $file_level_service_descriptors$[$len$]; + )cc"); } else { - format( - "static " - "constexpr ::_pb::ServiceDescriptor const** " - "$file_level_service_descriptors$ = nullptr;\n"); + p->Emit(R"cc( + static constexpr const ::_pb::ServiceDescriptor** + $file_level_service_descriptors$ = nullptr; + )cc"); } if (!message_generators_.empty()) { - format( - "\n" - "const $uint32$ $tablename$::offsets[] " - "PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {\n"); - format.Indent(); - std::vector<std::pair<size_t, size_t> > pairs; - pairs.reserve(message_generators_.size()); - for (int i = 0; i < message_generators_.size(); i++) { - pairs.push_back(message_generators_[i]->GenerateOffsets(printer)); - } - format.Outdent(); - format( - "};\n" - "static const ::_pbi::MigrationSchema schemas[] " - "PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {\n"); - format.Indent(); - { - int offset = 0; - for (int i = 0; i < message_generators_.size(); i++) { - message_generators_[i]->GenerateSchema(printer, offset, - pairs[i].second); - offset += pairs[i].first; - } - } - format.Outdent(); - format( - "};\n" - "\nstatic const ::_pb::Message* const file_default_instances[] = {\n"); - format.Indent(); - for (int i = 0; i < message_generators_.size(); i++) { - const Descriptor* descriptor = message_generators_[i]->descriptor_; - format("&$1$::_$2$_default_instance_._instance,\n", - Namespace(descriptor, options_), // 1 - ClassName(descriptor)); // 2 - } - format.Outdent(); - format( - "};\n" - "\n"); + std::vector<std::pair<size_t, size_t>> offsets; + offsets.reserve(message_generators_.size()); + + p->Emit( + { + {"offsets", + [&] { + for (int i = 0; i < message_generators_.size(); ++i) { + offsets.push_back(message_generators_[i]->GenerateOffsets(p)); + } + }}, + {"schemas", + [&] { + int offset = 0; + for (int i = 0; i < message_generators_.size(); ++i) { + message_generators_[i]->GenerateSchema(p, offset, + offsets[i].second); + offset += offsets[i].first; + } + }}, + {"defaults", + [&] { + for (auto& gen : message_generators_) { + p->Emit( + { + {"ns", Namespace(gen->descriptor_, options_)}, + {"class", ClassName(gen->descriptor_)}, + }, + R"cc( + &$ns$::_$class$_default_instance_._instance, + )cc"); + } + }}, + }, + R"cc( + const uint32_t $tablename$::offsets[] PROTOBUF_SECTION_VARIABLE( + protodesc_cold) = { + $offsets$, + }; + + static const ::_pbi::MigrationSchema + schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + $schemas$, + }; + + static const ::_pb::Message* const file_default_instances[] = { + $defaults$, + }; + )cc"); } else { - // we still need these symbols to exist - format( - // MSVC doesn't like empty arrays, so we add a dummy. - "const $uint32$ $tablename$::offsets[1] = {};\n" - "static constexpr ::_pbi::MigrationSchema* schemas = nullptr;\n" - "static constexpr ::_pb::Message* const* " - "file_default_instances = nullptr;\n" - "\n"); + // Ee still need these symbols to exist. + // + // MSVC doesn't like empty arrays, so we add a dummy. + p->Emit(R"cc( + const uint32_t $tablename$::offsets[1] = {}; + static constexpr ::_pbi::MigrationSchema* schemas = nullptr; + static constexpr ::_pb::Message* const* file_default_instances = nullptr; + )cc"); } // --------------------------------------------------------------- @@ -863,63 +954,88 @@ // 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. - const std::string protodef_name = - UniqueName("descriptor_table_protodef", file_, options_); - format("const char $1$[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) =\n", - protodef_name); - format.Indent(); + FileDescriptorProto file_proto; file_->CopyTo(&file_proto); std::string file_data; file_proto.SerializeToString(&file_data); - { - if (file_data.size() > 65535) { - // Workaround for MSVC: "Error C1091: compiler limit: string exceeds - // 65535 bytes in length". Declare a static array of chars rather than - // use a string literal. Only write 25 bytes per line. - static const int kBytesPerLine = 25; - format("{ "); - for (int i = 0; i < file_data.size();) { - for (int j = 0; j < kBytesPerLine && i < file_data.size(); ++i, ++j) { - format("'$1$', ", absl::CEscape(file_data.substr(i, 1))); - } - format("\n"); - } - format("'\\0' }"); // null-terminate - } else { - // Only write 40 bytes per line. - static const int kBytesPerLine = 40; - for (int i = 0; i < file_data.size(); i += kBytesPerLine) { - format( - "\"$1$\"\n", - EscapeTrigraphs(absl::CEscape(file_data.substr(i, kBytesPerLine)))); - } - } - format(";\n"); - } - format.Outdent(); + auto desc_name = UniqueName("descriptor_table_protodef", file_, options_); + p->Emit( + {{"desc_name", desc_name}, + {"encoded_file_proto", + [&] { + absl::string_view data = file_data; + if (data.size() <= 65535) { + static constexpr size_t kBytesPerLine = 40; + while (!data.empty()) { + auto to_write = std::min(kBytesPerLine, data.size()); + auto chunk = data.substr(0, to_write); + data = data.substr(to_write); + + p->Emit({{"text", EscapeTrigraphs(absl::CEscape(chunk))}}, R"cc( + "$text$" + )cc"); + } + return; + } + + // Workaround for MSVC: "Error C1091: compiler limit: string exceeds + // 65535 bytes in length". Declare a static array of chars rather than + // use a string literal. Only write 25 bytes per line. + static constexpr size_t kBytesPerLine = 25; + while (!data.empty()) { + auto to_write = std::min(kBytesPerLine, data.size()); + auto chunk = data.substr(0, to_write); + data = data.substr(to_write); + + std::string line; + for (char c : chunk) { + absl::StrAppend(&line, "'", + absl::CEscape(absl::string_view(&c, 1)), "', "); + } + + p->Emit({{"line", line}}, R"cc( + $line$ + )cc"); + } + }}}, + R"cc( + const char $desc_name$[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + $encoded_file_proto$, + }; + )cc"); CrossFileReferences refs; GetCrossFileReferencesForFile(file_, &refs); - int num_deps = + size_t num_deps = refs.strong_reflection_files.size() + refs.weak_reflection_files.size(); // Build array of DescriptorTable deps. if (num_deps > 0) { - format( - "static const ::_pbi::DescriptorTable* const " - "$desc_table$_deps[$1$] = {\n", - num_deps); - - for (auto dep : Sorted(refs.strong_reflection_files)) { - format(" &::$1$,\n", DescriptorTableName(dep, options_)); - } - for (auto dep : Sorted(refs.weak_reflection_files)) { - format(" &::$1$,\n", DescriptorTableName(dep, options_)); - } - - format("};\n"); + p->Emit( + { + {"len", absl::StrCat(num_deps)}, + {"deps", + [&] { + for (auto dep : refs.strong_reflection_files) { + p->Emit({{"name", DescriptorTableName(dep, options_)}}, R"cc( + &::$name$, + )cc"); + } + for (auto dep : refs.weak_reflection_files) { + p->Emit({{"name", DescriptorTableName(dep, options_)}}, R"cc( + &::$name$, + )cc"); + } + }}, + }, + R"cc( + static const ::_pbi::DescriptorTable* const $desc_table$_deps[$len$] = + { + $deps$, + }; + )cc"); } // The DescriptorTable itself. @@ -927,344 +1043,358 @@ // however this might cause a tsan failure in superroot b/148382879, // so disable for now. bool eager = false; - format( - "static ::absl::once_flag $desc_table$_once;\n" - "const ::_pbi::DescriptorTable $desc_table$ = {\n" - " false, $1$, $2$, $3$,\n" - " \"$filename$\",\n" - " &$desc_table$_once, $4$, $5$, $6$,\n" - " schemas, file_default_instances, $tablename$::offsets,\n" - " $7$, $file_level_enum_descriptors$,\n" - " $file_level_service_descriptors$,\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 - // of more than 35% of walltime for optimized builds. - // Without the weak attribute all the messages in the file, including all - // the vtables and everything they use become part of the same SCC through - // a cycle like: - // GetMetadata -> descriptor table -> default instances -> - // vtables -> GetMetadata - // By adding a weak function here we break the connection from the - // individual vtables back into the descriptor table. - "PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* " - "$desc_table$_getter() {\n" - " return &$desc_table$;\n" - "}\n" - "\n", - eager ? "true" : "false", file_data.size(), protodef_name, - num_deps == 0 ? "nullptr" : variables_["desc_table"] + "_deps", num_deps, - message_generators_.size(), - message_generators_.empty() ? "nullptr" - : variables_["file_level_metadata"]); + p->Emit( + { + {"eager", eager ? "true" : "false"}, + {"file_proto_len", absl::StrCat(file_data.size())}, + {"proto_name", desc_name}, + {"deps_ptr", num_deps == 0 + ? "nullptr" + : absl::StrCat(p->LookupVar("desc_table"), "_deps")}, + {"num_deps", absl::StrCat(num_deps)}, + {"num_msgs", absl::StrCat(message_generators_.size())}, + {"msgs_ptr", message_generators_.empty() + ? "nullptr" + : std::string(p->LookupVar("file_level_metadata"))}, + }, + R"cc( + static ::absl::once_flag $desc_table$_once; + const ::_pbi::DescriptorTable $desc_table$ = { + false, + $eager$, + $file_proto_len$, + $proto_name$, + "$filename$", + &$desc_table$_once, + $deps_ptr$, + $num_deps$, + $num_msgs$, + schemas, + file_default_instances, + $tablename$::offsets, + $msgs_ptr$, + $file_level_enum_descriptors$, + $file_level_service_descriptors$, + }; + + // 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 of more than 35% of walltime for optimized builds. Without + // the weak attribute all the messages in the file, including all the + // vtables and everything they use become part of the same SCC through + // a cycle like: + // GetMetadata -> descriptor table -> default instances -> + // vtables -> GetMetadata + // By adding a weak function here we break the connection from the + // individual vtables back into the descriptor table. + PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* $desc_table$_getter() { + return &$desc_table$; + } + )cc"); // 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 // initialization will still be performed lazily when it's needed. - if (file_->name() != "net/proto2/proto/descriptor.proto") { - format( - "// Force running AddDescriptors() at dynamic initialization time.\n" - "PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 " - "static ::_pbi::AddDescriptorsRunner $1$(&$desc_table$);\n", - UniqueName("dynamic_init_dummy", file_, options_)); + if (file_->name() == "net/proto2/proto/descriptor.proto") { + return; } + + p->Emit({{"dummy", UniqueName("dynamic_init_dummy", file_, options_)}}, R"cc( + // Force running AddDescriptors() at dynamic initialization time. + PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 + static ::_pbi::AddDescriptorsRunner $dummy$(&$desc_table$); + )cc"); } class FileGenerator::ForwardDeclarations { public: - void AddMessage(const Descriptor* d) { classes_[ClassName(d)] = d; } - void AddEnum(const EnumDescriptor* d) { enums_[ClassName(d)] = d; } - void AddSplit(const Descriptor* d) { splits_[ClassName(d)] = d; } + void AddMessage(const Descriptor* d) { classes_.emplace(ClassName(d), d); } + void AddEnum(const EnumDescriptor* d) { enums_.emplace(ClassName(d), d); } + void AddSplit(const Descriptor* d) { splits_.emplace(ClassName(d), d); } - void Print(const Formatter& format, const Options& options) const { - for (const auto& p : enums_) { - const std::string& enumname = p.first; - const EnumDescriptor* enum_desc = p.second; - format( - "enum ${1$$2$$}$ : int;\n" - "bool $2$_IsValid(int value);\n", - enum_desc, enumname); + void Print(io::Printer* p, const Options& options) const { + for (const auto& e : enums_) { + auto a = p->WithAnnotations({{"enum", e.second}}); + p->Emit({{"enum", e.first}}, R"cc( + enum $enum$ : int; + bool $enum$_IsValid(int value); + )cc"); } - for (const auto& p : classes_) { - const std::string& classname = p.first; - const Descriptor* class_desc = p.second; - format( - "class ${1$$2$$}$;\n" - "struct $3$;\n" - "$dllexport_decl $extern $3$ $4$;\n", - class_desc, classname, DefaultInstanceType(class_desc, options), - DefaultInstanceName(class_desc, options)); + + for (const auto& c : classes_) { + const Descriptor* desc = c.second; + auto a = p->WithAnnotations({{"class", desc}}); + p->Emit( + { + {"class", c.first}, + {"default_type", DefaultInstanceType(desc, options)}, + {"default_name", DefaultInstanceName(desc, options)}, + }, + R"cc( + class $class$; + struct $default_type$; + $dllexport_decl $extern $default_type$ $default_name$; + )cc"); } - for (const auto& p : splits_) { - const Descriptor* class_desc = p.second; - format( - "struct $1$;\n" - "$dllexport_decl $extern const $1$ $2$;\n", - DefaultInstanceType(class_desc, options, /*split=*/true), - DefaultInstanceName(class_desc, options, /*split=*/true)); + + for (const auto& s : splits_) { + const Descriptor* desc = s.second; + p->Emit( + { + {"default_type", + DefaultInstanceType(desc, options, /*split=*/true)}, + {"default_name", + DefaultInstanceName(desc, options, /*split=*/true)}, + }, + R"cc( + struct $default_type$; + $dllexport_decl $extern const $default_type$ $default_name$; + )cc"); } } - void PrintTopLevelDecl(const Formatter& format, - const Options& options) const { - for (const auto& pair : classes_) { - format( - "template<> $dllexport_decl $" - "$1$* Arena::CreateMaybeMessage<$1$>(Arena*);\n", - QualifiedClassName(pair.second, options)); + void PrintTopLevelDecl(io::Printer* p, const Options& options) const { + for (const auto& c : classes_) { + p->Emit({{"class", QualifiedClassName(c.second, options)}}, R"cc( + template <> + $dllexport_decl $$class$* Arena::CreateMaybeMessage<$class$>(Arena*); + )cc"); } } private: - std::map<std::string, const Descriptor*> classes_; - std::map<std::string, const EnumDescriptor*> enums_; - std::map<std::string, const Descriptor*> splits_; + absl::btree_map<std::string, const Descriptor*> classes_; + absl::btree_map<std::string, const EnumDescriptor*> enums_; + absl::btree_map<std::string, const Descriptor*> splits_; }; -static void PublicImportDFS(const FileDescriptor* fd, - std::unordered_set<const FileDescriptor*>* fd_set) { - for (int i = 0; i < fd->public_dependency_count(); i++) { +static void PublicImportDFS( + const FileDescriptor* fd, + absl::flat_hash_set<const FileDescriptor*>& fd_set) { + for (int i = 0; i < fd->public_dependency_count(); ++i) { const FileDescriptor* dep = fd->public_dependency(i); - if (fd_set->insert(dep).second) PublicImportDFS(dep, fd_set); + if (fd_set.insert(dep).second) { + PublicImportDFS(dep, fd_set); + } } } -void FileGenerator::GenerateForwardDeclarations(io::Printer* printer) { - Formatter format(printer, variables_); +void FileGenerator::GenerateForwardDeclarations(io::Printer* p) { std::vector<const Descriptor*> classes; - std::vector<const EnumDescriptor*> enums; - FlattenMessagesInFile(file_, &classes); // All messages need forward decls. + std::vector<const EnumDescriptor*> enums; if (options_.proto_h) { // proto.h needs extra forward declarations. // All classes / enums referred to as field members std::vector<const FieldDescriptor*> fields; ListAllFields(file_, &fields); - for (int i = 0; i < fields.size(); i++) { - classes.push_back(fields[i]->containing_type()); - classes.push_back(fields[i]->message_type()); - enums.push_back(fields[i]->enum_type()); + for (const auto* field : fields) { + classes.push_back(field->containing_type()); + classes.push_back(field->message_type()); + enums.push_back(field->enum_type()); } + ListAllTypesForServices(file_, &classes); } // Calculate the set of files whose definitions we get through include. // No need to forward declare types that are defined in these. - std::unordered_set<const FileDescriptor*> public_set; - PublicImportDFS(file_, &public_set); + absl::flat_hash_set<const FileDescriptor*> public_set; + PublicImportDFS(file_, public_set); - std::map<std::string, ForwardDeclarations> decls; - for (int i = 0; i < classes.size(); i++) { - const Descriptor* d = classes[i]; - if (d && !public_set.count(d->file())) + absl::btree_map<std::string, ForwardDeclarations> decls; + for (const auto* d : classes) { + if (d != nullptr && !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())) - decls[Namespace(d, options_)].AddEnum(d); + for (const auto* e : enums) { + if (e != nullptr && !public_set.count(e->file())) + decls[Namespace(e, options_)].AddEnum(e); } for (const auto& mg : message_generators_) { const Descriptor* d = mg->descriptor_; - if ((d != nullptr) && (public_set.count(d->file()) == 0u) && + if (d != nullptr && public_set.count(d->file()) == 0u && ShouldSplit(mg->descriptor_, options_)) decls[Namespace(d, options_)].AddSplit(d); } - { - NamespaceOpener ns(format); - for (const auto& pair : decls) { - ns.ChangeTo(pair.first); - pair.second.Print(format, options_); - } + NamespaceOpener ns(p); + for (const auto& decl : decls) { + ns.ChangeTo(decl.first); + decl.second.Print(p, options_); } - format("PROTOBUF_NAMESPACE_OPEN\n"); - for (const auto& pair : decls) { - pair.second.PrintTopLevelDecl(format, options_); + + ns.ChangeTo("PROTOBUF_NAMESPACE_ID"); + for (const auto& decl : decls) { + decl.second.PrintTopLevelDecl(p, options_); } - format("PROTOBUF_NAMESPACE_CLOSE\n"); } -void FileGenerator::GenerateTopHeaderGuard( - io::Printer* printer, google::protobuf::compiler::cpp::GeneratedFileType file_type) { - Formatter format(printer, variables_); - // Generate top of header. - format( - "// Generated by the protocol buffer compiler. DO NOT EDIT!\n" - "// source: $filename$\n" - "\n" - "#ifndef $1$\n" - "#define $1$\n" - "\n" - "#include <limits>\n" - "#include <string>\n", - IncludeGuard(file_, file_type, options_)); - if (!options_.opensource_runtime && !enum_generators_.empty()) { - // Add header to provide std::is_integral for safe Enum_Name() function. - format("#include <type_traits>\n"); - } - format("\n"); -} - -void FileGenerator::GenerateBottomHeaderGuard( - io::Printer* printer, google::protobuf::compiler::cpp::GeneratedFileType file_type) { - Formatter format(printer, variables_); - format("#endif // $GOOGLE_PROTOBUF$_INCLUDED_$1$\n", - IncludeGuard(file_, file_type, options_)); -} - -void FileGenerator::GenerateLibraryIncludes(io::Printer* printer) { - Formatter format(printer, variables_); +void FileGenerator::GenerateLibraryIncludes(io::Printer* p) { if (UsingImplicitWeakFields(file_, options_)) { - IncludeFile("net/proto2/public/implicit_weak_message.h", printer); + IncludeFile("net/proto2/public/implicit_weak_message.h", p); } if (HasWeakFields(file_, options_)) { GOOGLE_CHECK(!options_.opensource_runtime); - IncludeFile("net/proto2/public/weak_field_map.h", printer); + IncludeFile("net/proto2/public/weak_field_map.h", p); } if (HasLazyFields(file_, options_, &scc_analyzer_)) { GOOGLE_CHECK(!options_.opensource_runtime); - IncludeFile("net/proto2/public/lazy_field.h", printer); + IncludeFile("net/proto2/public/lazy_field.h", p); } if (ShouldVerify(file_, options_, &scc_analyzer_)) { - IncludeFile("net/proto2/public/wire_format_verify.h", printer); + IncludeFile("net/proto2/public/wire_format_verify.h", p); } if (options_.opensource_runtime) { // Verify the protobuf library header version is compatible with the protoc // version before going any further. - IncludeFile("net/proto2/public/port_def.inc", printer); - format( - "#if PROTOBUF_VERSION < $1$\n" - "#error This file was generated by a newer version of protoc which is\n" - "#error incompatible with your Protocol Buffer headers. Please update\n" - "#error your headers.\n" - "#endif\n" - "#if $2$ < PROTOBUF_MIN_PROTOC_VERSION\n" - "#error This file was generated by an older version of protoc which " - "is\n" - "#error incompatible with your Protocol Buffer headers. Please\n" - "#error regenerate this file with a newer version of protoc.\n" - "#endif\n" - "\n", - PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC, // 1 - PROTOBUF_VERSION); // 2 - IncludeFile("net/proto2/public/port_undef.inc", printer); + IncludeFile("net/proto2/public/port_def.inc", p); + p->Emit( + { + {"min_version", + absl::StrCat(PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC)}, + {"version", absl::StrCat(PROTOBUF_VERSION)}, + }, + R"( + #if PROTOBUF_VERSION < $min_version$ + #error "This file was generated by a newer version of protoc which is" + #error "incompatible with your Protocol Buffer headers. Please update" + #error "your headers." + #endif // PROTOBUF_VERSION + + #if $version$ < PROTOBUF_MIN_PROTOC_VERSION + #error "This file was generated by an older version of protoc which is" + #error "incompatible with your Protocol Buffer headers. Please" + #error "regenerate this file with a newer version of protoc." + #endif // PROTOBUF_MIN_PROTOC_VERSION + )"); + IncludeFile("net/proto2/public/port_undef.inc", p); } // OK, it's now safe to #include other files. - IncludeFile("net/proto2/io/public/coded_stream.h", printer); - IncludeFile("net/proto2/public/arena.h", printer); - IncludeFile("net/proto2/public/arenastring.h", printer); + IncludeFile("net/proto2/io/public/coded_stream.h", p); + IncludeFile("net/proto2/public/arena.h", p); + IncludeFile("net/proto2/public/arenastring.h", p); if ((options_.force_inline_string || options_.profile_driven_inline_string) && !options_.opensource_runtime) { - IncludeFile("net/proto2/public/inlined_string_field.h", printer); + IncludeFile("net/proto2/public/inlined_string_field.h", p); } if (HasSimpleBaseClasses(file_, options_)) { - IncludeFile("net/proto2/public/generated_message_bases.h", printer); + IncludeFile("net/proto2/public/generated_message_bases.h", p); } if (HasGeneratedMethods(file_, options_) && options_.tctable_mode != Options::kTCTableNever) { - IncludeFile("net/proto2/public/generated_message_tctable_decl.h", printer); + IncludeFile("net/proto2/public/generated_message_tctable_decl.h", p); } - IncludeFile("net/proto2/public/generated_message_util.h", printer); - IncludeFile("net/proto2/public/metadata_lite.h", printer); + IncludeFile("net/proto2/public/generated_message_util.h", p); + IncludeFile("net/proto2/public/metadata_lite.h", p); if (HasDescriptorMethods(file_, options_)) { - IncludeFile("net/proto2/public/generated_message_reflection.h", printer); + IncludeFile("net/proto2/public/generated_message_reflection.h", p); } if (!message_generators_.empty()) { if (HasDescriptorMethods(file_, options_)) { - IncludeFile("net/proto2/public/message.h", printer); + IncludeFile("net/proto2/public/message.h", p); } else { - IncludeFile("net/proto2/public/message_lite.h", printer); + IncludeFile("net/proto2/public/message_lite.h", p); } } if (options_.opensource_runtime) { // Open-source relies on unconditional includes of these. - IncludeFileAndExport("net/proto2/public/repeated_field.h", printer); - IncludeFileAndExport("net/proto2/public/extension_set.h", printer); + IncludeFileAndExport("net/proto2/public/repeated_field.h", p); + IncludeFileAndExport("net/proto2/public/extension_set.h", p); } else { // Google3 includes these files only when they are necessary. if (HasExtensionsOrExtendableMessage(file_)) { - IncludeFileAndExport("net/proto2/public/extension_set.h", printer); + IncludeFileAndExport("net/proto2/public/extension_set.h", p); } if (HasRepeatedFields(file_)) { - IncludeFileAndExport("net/proto2/public/repeated_field.h", printer); + IncludeFileAndExport("net/proto2/public/repeated_field.h", p); } if (HasStringPieceFields(file_, options_)) { - IncludeFile("net/proto2/public/string_piece_field_support.h", printer); + IncludeFile("net/proto2/public/string_piece_field_support.h", p); } if (HasCordFields(file_, options_)) { - format("#include \"third_party/absl/strings/cord.h\"\n"); + p->Emit(R"( + #include "third_party/absl/strings/cord.h" + )"); } } if (HasMapFields(file_)) { - IncludeFileAndExport("net/proto2/public/map.h", printer); + IncludeFileAndExport("net/proto2/public/map.h", p); if (HasDescriptorMethods(file_, options_)) { - IncludeFile("net/proto2/public/map_entry.h", printer); - IncludeFile("net/proto2/public/map_field_inl.h", printer); + IncludeFile("net/proto2/public/map_entry.h", p); + IncludeFile("net/proto2/public/map_field_inl.h", p); } else { - IncludeFile("net/proto2/public/map_entry_lite.h", printer); - IncludeFile("net/proto2/public/map_field_lite.h", printer); + IncludeFile("net/proto2/public/map_entry_lite.h", p); + IncludeFile("net/proto2/public/map_field_lite.h", p); } } if (HasEnumDefinitions(file_)) { if (HasDescriptorMethods(file_, options_)) { - IncludeFile("net/proto2/public/generated_enum_reflection.h", printer); + IncludeFile("net/proto2/public/generated_enum_reflection.h", p); } else { - IncludeFile("net/proto2/public/generated_enum_util.h", printer); + IncludeFile("net/proto2/public/generated_enum_util.h", p); } } if (HasGenericServices(file_, options_)) { - IncludeFile("net/proto2/public/service.h", printer); + IncludeFile("net/proto2/public/service.h", p); } if (UseUnknownFieldSet(file_, options_) && !message_generators_.empty()) { - IncludeFile("net/proto2/public/unknown_field_set.h", printer); + IncludeFile("net/proto2/public/unknown_field_set.h", p); } } -void FileGenerator::GenerateMetadataPragma(io::Printer* printer, - const std::string& info_path) { - Formatter format(printer, variables_); - if (!info_path.empty() && !options_.annotation_pragma_name.empty() && - !options_.annotation_guard_name.empty()) { - format.Set("guard", options_.annotation_guard_name); - format.Set("pragma", options_.annotation_pragma_name); - format.Set("info_path", info_path); - format( - "#ifdef $guard$\n" - "#pragma $pragma$ \"$info_path$\"\n" - "#endif // $guard$\n"); +void FileGenerator::GenerateMetadataPragma(io::Printer* p, + absl::string_view info_path) { + if (info_path.empty() || options_.annotation_pragma_name.empty() || + options_.annotation_guard_name.empty()) { + return; } + + p->Emit( + { + {"guard", options_.annotation_guard_name}, + {"pragma", options_.annotation_pragma_name}, + {"info_path", std::string(info_path)}, + }, + R"( + #ifdef $guard$ + #pragma $pragma$ "$info_path$" + #endif // $guard$ + )"); } -void FileGenerator::GenerateDependencyIncludes(io::Printer* printer) { - Formatter format(printer, variables_); - for (int i = 0; i < file_->dependency_count(); i++) { - std::string basename = StripProto(file_->dependency(i)->name()); +void FileGenerator::GenerateDependencyIncludes(io::Printer* p) { + for (int i = 0; i < file_->dependency_count(); ++i) { + const FileDescriptor* dep = file_->dependency(i); // Do not import weak deps. - if (IsDepWeak(file_->dependency(i))) continue; + if (IsDepWeak(dep)) { + continue; + } + std::string basename = StripProto(dep->name()); if (IsBootstrapProto(options_, file_)) { GetBootstrapBasename(options_, basename, &basename); } - format("#include $1$\n", - CreateHeaderInclude(basename + ".pb.h", file_->dependency(i))); + p->Emit( + {{"name", CreateHeaderInclude(absl::StrCat(basename, ".pb.h"), dep)}}, + R"( + #include $name$ + )"); } } -void FileGenerator::GenerateGlobalStateFunctionDeclarations( - io::Printer* printer) { - Formatter format(printer, variables_); +void FileGenerator::GenerateGlobalStateFunctionDeclarations(io::Printer* p) { // Forward-declare the DescriptorTable because this is referenced by .pb.cc // files depending on this file. // @@ -1272,114 +1402,102 @@ // weak fields must refer to table struct but cannot include the header. // Also it annotates extra weak attributes. // TODO(gerbens) make sure this situation is handled better. - format( - "\n" - "// Internal implementation detail -- do not use these members.\n" - "struct $dllexport_decl $$tablename$ {\n" - " static const $uint32$ offsets[];\n" - "};\n"); + p->Emit(R"cc( + // Internal implementation detail -- do not use these members. + struct $dllexport_decl $$tablename$ { + static const uint32_t offsets[]; + }; + )cc"); + if (HasDescriptorMethods(file_, options_)) { - format( - "$dllexport_decl $extern const ::$proto_ns$::internal::DescriptorTable " - "$desc_table$;\n"); + p->Emit(R"cc( + $dllexport_decl $extern const ::$proto_ns$::internal::DescriptorTable + $desc_table$; + )cc"); } } -void FileGenerator::GenerateMessageDefinitions(io::Printer* printer) { - Formatter format(printer, variables_); - // Generate class definitions. - for (int i = 0; i < message_generators_.size(); i++) { - if (i > 0) { - format("\n"); - format(kThinSeparator); - format("\n"); - } - message_generators_[i]->GenerateClassDefinition(printer); +void FileGenerator::GenerateMessageDefinitions(io::Printer* p) { + for (int i = 0; i < message_generators_.size(); ++i) { + p->Emit(R"cc( + $hrule_thin$ + )cc"); + message_generators_[i]->GenerateClassDefinition(p); } } -void FileGenerator::GenerateEnumDefinitions(io::Printer* printer) { - // Generate enum definitions. - for (int i = 0; i < enum_generators_.size(); i++) { - enum_generators_[i]->GenerateDefinition(printer); +void FileGenerator::GenerateEnumDefinitions(io::Printer* p) { + for (int i = 0; i < enum_generators_.size(); ++i) { + enum_generators_[i]->GenerateDefinition(p); } } -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++) { - if (i > 0) { - format("\n"); - format(kThinSeparator); - format("\n"); - } - service_generators_[i]->GenerateDeclarations(printer); - } - - format("\n"); - format(kThickSeparator); - format("\n"); +void FileGenerator::GenerateServiceDefinitions(io::Printer* p) { + if (!HasGenericServices(file_, options_)) { + return; } + + for (int i = 0; i < service_generators_.size(); ++i) { + p->Emit(R"cc( + $hrule_thin$ + )cc"); + service_generators_[i]->GenerateDeclarations(p); + } + + p->Emit(R"cc( + $hrule_thick$ + )cc"); } -void FileGenerator::GenerateExtensionIdentifiers(io::Printer* printer) { +void FileGenerator::GenerateExtensionIdentifiers(io::Printer* p) { // 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); + if (extension_generator->IsScoped()) { + continue; + } + extension_generator->GenerateDeclaration(p); } } -void FileGenerator::GenerateInlineFunctionDefinitions(io::Printer* printer) { - Formatter format(printer, variables_); +void FileGenerator::GenerateInlineFunctionDefinitions(io::Printer* p) { // 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++) { - if (i > 0) { - format(kThinSeparator); - format("\n"); - } - message_generators_[i]->GenerateInlineMethods(printer); - } - format( - "#ifdef __GNUC__\n" - " #pragma GCC diagnostic pop\n" - "#endif // __GNUC__\n"); + p->Emit(R"( + #ifdef __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wstrict-aliasing" + #endif // __GNUC__ + )"); - for (int i = 0; i < message_generators_.size(); i++) { - if (i > 0) { - format(kThinSeparator); - format("\n"); - } + for (int i = 0; i < message_generators_.size(); ++i) { + p->Emit(R"cc( + $hrule_thin$ + )cc"); + message_generators_[i]->GenerateInlineMethods(p); } + + p->Emit(R"( + #ifdef __GNUC__ + #pragma GCC diagnostic pop + #endif // __GNUC__ + )"); } -void FileGenerator::GenerateProto2NamespaceEnumSpecializations( - io::Printer* printer) { - Formatter format(printer, variables_); - // Emit GetEnumDescriptor specializations into google::protobuf namespace: - if (HasEnumDefinitions(file_)) { - format("\n"); - { - NamespaceOpener proto_ns(ProtobufNamespace(options_), format); - format("\n"); - for (int i = 0; i < enum_generators_.size(); i++) { - enum_generators_[i]->GenerateGetEnumDescriptorSpecializations(printer); - } - format("\n"); - } +void FileGenerator::GenerateProto2NamespaceEnumSpecializations(io::Printer* p) { + // Emit GetEnumDescriptor specializations into google::protobuf namespace. + if (!HasEnumDefinitions(file_)) { + return; } -} + p->PrintRaw("\n"); + NamespaceOpener ns(ProtobufNamespace(options_), p); + p->PrintRaw("\n"); + for (auto& gen : enum_generators_) { + gen->GenerateGetEnumDescriptorSpecializations(p); + } + p->PrintRaw("\n"); +} } // namespace cpp } // namespace compiler } // namespace protobuf
diff --git a/src/google/protobuf/compiler/cpp/file.h b/src/google/protobuf/compiler/cpp/file.h index 072b913..cd38345 100644 --- a/src/google/protobuf/compiler/cpp/file.h +++ b/src/google/protobuf/compiler/cpp/file.h
@@ -36,55 +36,47 @@ #define GOOGLE_PROTOBUF_COMPILER_CPP_FILE_H__ #include <algorithm> +#include <functional> #include <memory> #include <set> #include <string> #include <vector> #include "google/protobuf/stubs/common.h" +#include "google/protobuf/compiler/scc.h" +#include "absl/container/flat_hash_set.h" +#include "google/protobuf/compiler/cpp/enum.h" +#include "google/protobuf/compiler/cpp/extension.h" #include "google/protobuf/compiler/cpp/field.h" #include "google/protobuf/compiler/cpp/helpers.h" -#include "google/protobuf/port.h" -#include "google/protobuf/compiler/scc.h" +#include "google/protobuf/compiler/cpp/message.h" #include "google/protobuf/compiler/cpp/options.h" +#include "google/protobuf/compiler/cpp/service.h" +#include "google/protobuf/descriptor.h" +#include "google/protobuf/io/printer.h" +#include "google/protobuf/port.h" -namespace google { -namespace protobuf { -class FileDescriptor; // descriptor.h -namespace io { -class Printer; // printer.h -} -} // namespace protobuf -} // namespace google namespace google { namespace protobuf { namespace compiler { namespace cpp { - -class EnumGenerator; // enum.h -class MessageGenerator; // message.h -class ServiceGenerator; // service.h -class ExtensionGenerator; // extension.h - class FileGenerator { public: - // See generator.cc for the meaning of dllexport_decl. FileGenerator(const FileDescriptor* file, const Options& options); + FileGenerator(const FileGenerator&) = delete; FileGenerator& operator=(const FileGenerator&) = delete; - ~FileGenerator(); - // Shared code between the two header generators below. - void GenerateHeader(io::Printer* printer); + ~FileGenerator() = default; // 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 std::string& info_path); + void GenerateProtoHeader(io::Printer* p, absl::string_view info_path); // info_path, if non-empty, should be the path (relative to printer's // output) to the metadata file describing this PB header. - void GeneratePBHeader(io::Printer* printer, const std::string& info_path); - void GenerateSource(io::Printer* printer); + void GeneratePBHeader(io::Printer* p, absl::string_view info_path); + void GenerateSource(io::Printer* p); // The following member functions are used when the lite_implicit_weak_fields // option is set. In this mode the code is organized a bit differently to @@ -95,80 +87,86 @@ int NumMessages() const { return message_generators_.size(); } int NumExtensions() const { return extension_generators_.size(); } // Generates the source file for one message. - void GenerateSourceForMessage(int idx, io::Printer* printer); + void GenerateSourceForMessage(int idx, io::Printer* p); // Generates the source file for one extension. - void GenerateSourceForExtension(int idx, io::Printer* printer); + void GenerateSourceForExtension(int idx, io::Printer* p); // Generates a source file containing everything except messages and // extensions. - void GenerateGlobalSource(io::Printer* printer); + void GenerateGlobalSource(io::Printer* p); private: + // Generates a file, setting up the necessary accoutrements that start and + // end the file, calling `cb` in between. + // + // This includes header guards and file-global variables. + void GenerateFile(io::Printer* p, GeneratedFileType file_type, + std::function<void()> cb); + + // Shared code between the two header generators. + void GenerateSharedHeaderCode(io::Printer* p); + // Internal type used by GenerateForwardDeclarations (defined in file.cc). class ForwardDeclarations; struct CrossFileReferences; - void IncludeFile(const std::string& google3_name, io::Printer* printer) { - DoIncludeFile(google3_name, false, printer); + void IncludeFile(absl::string_view google3_name, io::Printer* p) { + DoIncludeFile(google3_name, false, p); } - void IncludeFileAndExport(const std::string& google3_name, - io::Printer* printer) { - DoIncludeFile(google3_name, true, printer); + void IncludeFileAndExport(absl::string_view google3_name, io::Printer* p) { + DoIncludeFile(google3_name, true, p); } - void DoIncludeFile(const std::string& google3_name, bool do_export, - io::Printer* printer); + void DoIncludeFile(absl::string_view google3_name, bool do_export, + io::Printer* p); - std::string CreateHeaderInclude(const std::string& basename, + std::string CreateHeaderInclude(absl::string_view basename, const FileDescriptor* file); void GetCrossFileReferencesForField(const FieldDescriptor* field, CrossFileReferences* refs); void GetCrossFileReferencesForFile(const FileDescriptor* file, CrossFileReferences* refs); void GenerateInternalForwardDeclarations(const CrossFileReferences& refs, - io::Printer* printer); - void GenerateSourceIncludes(io::Printer* printer); - void GenerateSourcePrelude(io::Printer* printer); - void GenerateSourceDefaultInstance(int idx, io::Printer* printer); + io::Printer* p); + void GenerateSourceIncludes(io::Printer* p); + void GenerateSourcePrelude(io::Printer* p); + void GenerateSourceDefaultInstance(int idx, io::Printer* p); void GenerateInitForSCC(const SCC* scc, const CrossFileReferences& refs, - io::Printer* printer); - void GenerateReflectionInitializationCode(io::Printer* printer); + io::Printer* p); + void GenerateReflectionInitializationCode(io::Printer* p); // For other imports, generates their forward-declarations. - void GenerateForwardDeclarations(io::Printer* printer); + void GenerateForwardDeclarations(io::Printer* p); // Generates top or bottom of a header file. - void GenerateTopHeaderGuard( - io::Printer* printer, google::protobuf::compiler::cpp::GeneratedFileType file_type); - void GenerateBottomHeaderGuard( - io::Printer* printer, google::protobuf::compiler::cpp::GeneratedFileType file_type); + void GenerateTopHeaderGuard(io::Printer* p, GeneratedFileType file_type); + void GenerateBottomHeaderGuard(io::Printer* p, GeneratedFileType file_type); // Generates #include directives. - void GenerateLibraryIncludes(io::Printer* printer); - void GenerateDependencyIncludes(io::Printer* printer); + void GenerateLibraryIncludes(io::Printer* p); + void GenerateDependencyIncludes(io::Printer* p); // Generate a pragma to pull in metadata using the given info_path (if // non-empty). info_path should be relative to printer's output. - void GenerateMetadataPragma(io::Printer* printer, - const std::string& info_path); + void GenerateMetadataPragma(io::Printer* p, absl::string_view info_path); // Generates a couple of different pieces before definitions: - void GenerateGlobalStateFunctionDeclarations(io::Printer* printer); + void GenerateGlobalStateFunctionDeclarations(io::Printer* p); // Generates types for classes. - void GenerateMessageDefinitions(io::Printer* printer); + void GenerateMessageDefinitions(io::Printer* p); - void GenerateEnumDefinitions(io::Printer* printer); + void GenerateEnumDefinitions(io::Printer* p); // Generates generic service definitions. - void GenerateServiceDefinitions(io::Printer* printer); + void GenerateServiceDefinitions(io::Printer* p); // Generates extension identifiers. - void GenerateExtensionIdentifiers(io::Printer* printer); + void GenerateExtensionIdentifiers(io::Printer* p); // Generates inline function definitions. - void GenerateInlineFunctionDefinitions(io::Printer* printer); + void GenerateInlineFunctionDefinitions(io::Printer* p); - void GenerateProto2NamespaceEnumSpecializations(io::Printer* printer); + void GenerateProto2NamespaceEnumSpecializations(io::Printer* p); // Sometimes the names we use in a .proto file happen to be defined as // macros on some platforms (e.g., macro/minor used in plugin.proto are @@ -177,7 +175,7 @@ // 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* p); bool IsDepWeak(const FileDescriptor* dep) const { if (weak_deps_.count(dep) != 0) { @@ -187,13 +185,16 @@ return false; } - std::set<const FileDescriptor*> weak_deps_; + absl::flat_hash_set<const FileDescriptor*> weak_deps_; const FileDescriptor* file_; - const Options options_; + Options options_; MessageSCCAnalyzer scc_analyzer_; + // This member is unused and should be deleted once all old-style variable + // maps are gone. + // TODO(b/245791219) std::map<std::string, std::string> variables_; // Contains the post-order walk of all the messages (and child messages) in
diff --git a/src/google/protobuf/compiler/cpp/generator.cc b/src/google/protobuf/compiler/cpp/generator.cc index 3c25ec8..8403312 100644 --- a/src/google/protobuf/compiler/cpp/generator.cc +++ b/src/google/protobuf/compiler/cpp/generator.cc
@@ -70,6 +70,9 @@ {"uint32", "uint32_t"}, {"uint64", "uint64_t"}, + {"hrule_thick", kThickSeparator}, + {"hrule_thin", kThinSeparator}, + // Warning: there is some clever naming/splitting here to avoid extract // script rewrites. The names of these variables must not be things that // the extract script will rewrite. That's why we use "CHK" (for example) @@ -83,9 +86,11 @@ : "GOOGLE3_PROTOBU" "F"}, {"CHK", is_oss ? "GOOGLE_CHECK" - : "CHECK"}, + : "CHEC" + "K"}, {"DCHK", is_oss ? "GOOGLE_DCHECK" - : "DCHECK"}, + : "DCHEC" + "K"}, }; } } // namespace
diff --git a/src/google/protobuf/compiler/cpp/helpers.cc b/src/google/protobuf/compiler/cpp/helpers.cc index bba2ff5..c89a48d 100644 --- a/src/google/protobuf/compiler/cpp/helpers.cc +++ b/src/google/protobuf/compiler/cpp/helpers.cc
@@ -43,6 +43,7 @@ #include <queue> #include <set> #include <string> +#include <utility> #include <vector> #include "google/protobuf/stubs/common.h" @@ -1087,6 +1088,46 @@ return well_known_files->find(file->name()) != well_known_files->end(); } +void NamespaceOpener::ChangeTo(absl::string_view name) { + std::vector<std::string> new_stack = + absl::StrSplit(name, "::", absl::SkipEmpty()); + size_t len = std::min(name_stack_.size(), new_stack.size()); + size_t common_idx = 0; + while (common_idx < len) { + if (name_stack_[common_idx] != new_stack[common_idx]) { + break; + } + ++common_idx; + } + + for (size_t i = name_stack_.size(); i > common_idx; i--) { + const auto& ns = name_stack_[i - 1]; + if (ns == "PROTOBUF_NAMESPACE_ID") { + p_->Emit(R"cc( + PROTOBUF_NAMESPACE_CLOSE + )cc"); + } else { + p_->Emit({{"ns", ns}}, R"( + } // namespace $ns$ + )"); + } + } + for (size_t i = common_idx; i < new_stack.size(); ++i) { + const auto& ns = new_stack[i]; + if (ns == "PROTOBUF_NAMESPACE_ID") { + p_->Emit(R"cc( + PROTOBUF_NAMESPACE_OPEN + )cc"); + } else { + p_->Emit({{"ns", ns}}, R"( + namespace $ns$ { + )"); + } + } + + name_stack_ = std::move(new_stack); +} + static void GenerateUtf8CheckCode(const FieldDescriptor* field, const Options& options, bool for_parse, const char* parameters,
diff --git a/src/google/protobuf/compiler/cpp/helpers.h b/src/google/protobuf/compiler/cpp/helpers.h index 19120e3..251214f 100644 --- a/src/google/protobuf/compiler/cpp/helpers.h +++ b/src/google/protobuf/compiler/cpp/helpers.h
@@ -44,7 +44,7 @@ #include "google/protobuf/compiler/scc.h" #include "google/protobuf/compiler/code_generator.h" #include "absl/container/flat_hash_map.h" -#include "google/protobuf/stubs/strutil.h" +#include "absl/strings/match.h" #include "absl/strings/str_split.h" #include "google/protobuf/compiler/cpp/names.h" #include "google/protobuf/compiler/cpp/options.h" @@ -52,6 +52,7 @@ #include "google/protobuf/io/printer.h" #include "google/protobuf/descriptor.h" #include "google/protobuf/port.h" +#include "google/protobuf/stubs/strutil.h" #include "absl/strings/str_cat.h" // Must be included last. @@ -887,43 +888,21 @@ class PROTOC_EXPORT NamespaceOpener { public: - explicit NamespaceOpener(const Formatter& format) - : printer_(format.printer()) {} - NamespaceOpener(const std::string& name, const Formatter& format) + explicit NamespaceOpener(io::Printer* p) : p_(p) {} + explicit NamespaceOpener(const Formatter& format) : p_(format.printer()) {} + NamespaceOpener(absl::string_view name, const Formatter& format) : NamespaceOpener(format) { ChangeTo(name); } + NamespaceOpener(absl::string_view name, io::Printer* p) : NamespaceOpener(p) { + ChangeTo(name); + } ~NamespaceOpener() { ChangeTo(""); } - void ChangeTo(const std::string& name) { - std::vector<std::string> new_stack_ = - absl::StrSplit(name, "::", absl::SkipEmpty()); - size_t len = std::min(name_stack_.size(), new_stack_.size()); - size_t common_idx = 0; - while (common_idx < len) { - if (name_stack_[common_idx] != new_stack_[common_idx]) break; - common_idx++; - } - for (auto it = name_stack_.crbegin(); - it != name_stack_.crend() - common_idx; ++it) { - if (*it == "PROTOBUF_NAMESPACE_ID") { - printer_->Print("PROTOBUF_NAMESPACE_CLOSE\n"); - } else { - printer_->Print("} // namespace $ns$\n", "ns", *it); - } - } - name_stack_.swap(new_stack_); - for (size_t i = common_idx; i < name_stack_.size(); ++i) { - if (name_stack_[i] == "PROTOBUF_NAMESPACE_ID") { - printer_->Print("PROTOBUF_NAMESPACE_OPEN\n"); - } else { - printer_->Print("namespace $ns$ {\n", "ns", name_stack_[i]); - } - } - } + void ChangeTo(absl::string_view name); private: - io::Printer* printer_; + io::Printer* p_; std::vector<std::string> name_stack_; };
diff --git a/src/google/protobuf/compiler/cpp/parse_function_generator.cc b/src/google/protobuf/compiler/cpp/parse_function_generator.cc index e4f057f..00f4823 100644 --- a/src/google/protobuf/compiler/cpp/parse_function_generator.cc +++ b/src/google/protobuf/compiler/cpp/parse_function_generator.cc
@@ -630,11 +630,11 @@ std::string func_name = info.func_name; // For 1-byte tags we have a more optimized version of the varint parser // that can hardcode the offset and has bit. - if (HasSuffixString(func_name, "V8S1") || - HasSuffixString(func_name, "V32S1") || - HasSuffixString(func_name, "V64S1")) { - std::string field_type = HasSuffixString(func_name, "V8S1") ? "bool" - : HasSuffixString(func_name, "V32S1") + if (absl::EndsWith(func_name, "V8S1") || + absl::EndsWith(func_name, "V32S1") || + absl::EndsWith(func_name, "V64S1")) { + std::string field_type = absl::EndsWith(func_name, "V8S1") ? "bool" + : absl::EndsWith(func_name, "V32S1") ? "uint32_t" : "uint64_t"; func_name =
diff --git a/src/google/protobuf/compiler/csharp/csharp_doc_comment.cc b/src/google/protobuf/compiler/csharp/csharp_doc_comment.cc index 72a4c12..507b826 100644 --- a/src/google/protobuf/compiler/csharp/csharp_doc_comment.cc +++ b/src/google/protobuf/compiler/csharp/csharp_doc_comment.cc
@@ -33,9 +33,6 @@ // Sanjay Ghemawat, Jeff Dean, and others. #include "google/protobuf/compiler/csharp/csharp_doc_comment.h" -#include "google/protobuf/stubs/strutil.h" -#include "absl/strings/ascii.h" -#include "absl/strings/escaping.h" #include "absl/strings/str_replace.h" #include "absl/strings/str_split.h" #include "google/protobuf/descriptor.h"
diff --git a/src/google/protobuf/compiler/csharp/csharp_enum.cc b/src/google/protobuf/compiler/csharp/csharp_enum.cc index 2b2bcf8..846da9b 100644 --- a/src/google/protobuf/compiler/csharp/csharp_enum.cc +++ b/src/google/protobuf/compiler/csharp/csharp_enum.cc
@@ -33,22 +33,13 @@ #include <sstream> #include "google/protobuf/compiler/code_generator.h" -#include "google/protobuf/descriptor.h" -#include "google/protobuf/stubs/strutil.h" -#include "absl/strings/ascii.h" -#include "absl/strings/escaping.h" -#include "absl/strings/str_split.h" -#include "absl/strings/str_replace.h" -#include "absl/strings/ascii.h" -#include "absl/strings/escaping.h" -#include "absl/strings/str_replace.h" -#include "absl/strings/str_split.h" +#include "absl/strings/str_cat.h" #include "google/protobuf/compiler/csharp/csharp_doc_comment.h" #include "google/protobuf/compiler/csharp/csharp_helpers.h" #include "google/protobuf/compiler/csharp/csharp_options.h" +#include "google/protobuf/descriptor.h" #include "google/protobuf/descriptor.pb.h" #include "google/protobuf/io/printer.h" -#include "google/protobuf/io/zero_copy_stream.h" namespace google { namespace protobuf {
diff --git a/src/google/protobuf/compiler/csharp/csharp_field_base.cc b/src/google/protobuf/compiler/csharp/csharp_field_base.cc index e808b7d..da205df 100644 --- a/src/google/protobuf/compiler/csharp/csharp_field_base.cc +++ b/src/google/protobuf/compiler/csharp/csharp_field_base.cc
@@ -37,21 +37,11 @@ #include "google/protobuf/compiler/code_generator.h" #include "google/protobuf/descriptor.h" #include "google/protobuf/wire_format.h" -#include "google/protobuf/stubs/strutil.h" -#include "absl/strings/ascii.h" -#include "absl/strings/escaping.h" -#include "absl/strings/str_split.h" -#include "absl/strings/str_replace.h" -#include "absl/strings/ascii.h" -#include "absl/strings/escaping.h" -#include "absl/strings/str_replace.h" -#include "absl/strings/str_split.h" #include "google/protobuf/compiler/csharp/csharp_helpers.h" #include "google/protobuf/compiler/csharp/csharp_names.h" #include "google/protobuf/descriptor.pb.h" #include "google/protobuf/io/coded_stream.h" #include "google/protobuf/io/printer.h" -#include "google/protobuf/io/zero_copy_stream.h" // Must be last. #include "google/protobuf/port_def.inc"
diff --git a/src/google/protobuf/compiler/csharp/csharp_field_base.h b/src/google/protobuf/compiler/csharp/csharp_field_base.h index 9eecde9..b2ad2c2 100644 --- a/src/google/protobuf/compiler/csharp/csharp_field_base.h +++ b/src/google/protobuf/compiler/csharp/csharp_field_base.h
@@ -32,17 +32,13 @@ #define GOOGLE_PROTOBUF_COMPILER_CSHARP_FIELD_BASE_H__ #include <string> + +#include "google/protobuf/compiler/code_generator.h" #include "google/protobuf/stubs/strutil.h" #include "absl/strings/ascii.h" #include "absl/strings/escaping.h" -#include "absl/strings/str_split.h" #include "absl/strings/str_replace.h" -#include "absl/strings/ascii.h" -#include "absl/strings/escaping.h" #include "absl/strings/str_split.h" -#include "absl/strings/str_replace.h" - -#include "google/protobuf/compiler/code_generator.h" #include "google/protobuf/compiler/csharp/csharp_source_generator_base.h" #include "google/protobuf/descriptor.h" #include "google/protobuf/io/printer.h"
diff --git a/src/google/protobuf/compiler/csharp/csharp_generator.cc b/src/google/protobuf/compiler/csharp/csharp_generator.cc index 8a3286e..0dab071 100644 --- a/src/google/protobuf/compiler/csharp/csharp_generator.cc +++ b/src/google/protobuf/compiler/csharp/csharp_generator.cc
@@ -34,16 +34,6 @@ #include "google/protobuf/compiler/code_generator.h" #include "google/protobuf/descriptor.h" -#include "google/protobuf/stubs/strutil.h" -#include "absl/strings/ascii.h" -#include "absl/strings/escaping.h" -#include "absl/strings/str_split.h" -#include "absl/strings/str_replace.h" -#include "absl/strings/ascii.h" -#include "absl/strings/escaping.h" -#include "absl/strings/str_replace.h" -#include "absl/strings/str_split.h" -#include "google/protobuf/compiler/csharp/csharp_helpers.h" #include "google/protobuf/compiler/csharp/csharp_names.h" #include "google/protobuf/compiler/csharp/csharp_options.h" #include "google/protobuf/compiler/csharp/csharp_reflection_class.h"
diff --git a/src/google/protobuf/compiler/csharp/csharp_helpers.cc b/src/google/protobuf/compiler/csharp/csharp_helpers.cc index dd60eb7..b917d8f 100644 --- a/src/google/protobuf/compiler/csharp/csharp_helpers.cc +++ b/src/google/protobuf/compiler/csharp/csharp_helpers.cc
@@ -41,9 +41,7 @@ #include "absl/container/flat_hash_set.h" #include "absl/strings/ascii.h" -#include "absl/strings/escaping.h" #include "absl/strings/str_replace.h" -#include "absl/strings/str_split.h" #include "absl/strings/string_view.h" #include "google/protobuf/compiler/csharp/csharp_enum_field.h" #include "google/protobuf/compiler/csharp/csharp_field_base.h" @@ -57,8 +55,6 @@ #include "google/protobuf/compiler/csharp/csharp_repeated_primitive_field.h" #include "google/protobuf/compiler/csharp/csharp_wrapper_field.h" #include "google/protobuf/descriptor.pb.h" -#include "google/protobuf/io/printer.h" -#include "google/protobuf/wire_format.h" // Must be last. #include "google/protobuf/port_def.inc"
diff --git a/src/google/protobuf/compiler/csharp/csharp_helpers.h b/src/google/protobuf/compiler/csharp/csharp_helpers.h index 55660b7..9c48cc8 100644 --- a/src/google/protobuf/compiler/csharp/csharp_helpers.h +++ b/src/google/protobuf/compiler/csharp/csharp_helpers.h
@@ -39,11 +39,11 @@ #include "google/protobuf/compiler/code_generator.h" #include "google/protobuf/descriptor.h" +#include "google/protobuf/port.h" #include "google/protobuf/stubs/common.h" #include "google/protobuf/descriptor.pb.h" #include "google/protobuf/io/printer.h" #include "google/protobuf/port_def.inc" -#include "google/protobuf/port.h" namespace google { namespace protobuf {
diff --git a/src/google/protobuf/compiler/csharp/csharp_map_field.cc b/src/google/protobuf/compiler/csharp/csharp_map_field.cc index 34ea3e9..efe87f2 100644 --- a/src/google/protobuf/compiler/csharp/csharp_map_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_map_field.cc
@@ -34,20 +34,10 @@ #include "google/protobuf/compiler/code_generator.h" #include "google/protobuf/descriptor.h" -#include "google/protobuf/stubs/strutil.h" -#include "absl/strings/ascii.h" -#include "absl/strings/escaping.h" -#include "absl/strings/str_split.h" -#include "absl/strings/str_replace.h" -#include "absl/strings/ascii.h" -#include "absl/strings/escaping.h" -#include "absl/strings/str_replace.h" -#include "absl/strings/str_split.h" #include "google/protobuf/compiler/csharp/csharp_doc_comment.h" #include "google/protobuf/compiler/csharp/csharp_helpers.h" #include "google/protobuf/descriptor.pb.h" #include "google/protobuf/io/printer.h" -#include "google/protobuf/io/zero_copy_stream.h" namespace google { namespace protobuf { @@ -98,7 +88,7 @@ void MapFieldGenerator::GenerateMergingCode(io::Printer* printer) { printer->Print( variables_, - "$name$_.MergeFrom(other.$name$_);\n"); + "$name$_.Add(other.$name$_);\n"); } void MapFieldGenerator::GenerateParsingCode(io::Printer* printer) {
diff --git a/src/google/protobuf/compiler/csharp/csharp_message.cc b/src/google/protobuf/compiler/csharp/csharp_message.cc index 993e9d6..92fe55d 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message.cc +++ b/src/google/protobuf/compiler/csharp/csharp_message.cc
@@ -35,27 +35,18 @@ #include <sstream> #include "google/protobuf/compiler/code_generator.h" -#include "google/protobuf/descriptor.h" -#include "google/protobuf/wire_format.h" -#include "google/protobuf/wire_format_lite.h" -#include "google/protobuf/stubs/strutil.h" -#include "absl/strings/ascii.h" -#include "absl/strings/escaping.h" -#include "absl/strings/str_split.h" -#include "absl/strings/str_replace.h" -#include "absl/strings/ascii.h" -#include "absl/strings/escaping.h" -#include "absl/strings/str_replace.h" -#include "absl/strings/str_split.h" +#include "absl/strings/str_cat.h" #include "google/protobuf/compiler/csharp/csharp_doc_comment.h" #include "google/protobuf/compiler/csharp/csharp_enum.h" #include "google/protobuf/compiler/csharp/csharp_field_base.h" #include "google/protobuf/compiler/csharp/csharp_helpers.h" #include "google/protobuf/compiler/csharp/csharp_names.h" #include "google/protobuf/compiler/csharp/csharp_options.h" +#include "google/protobuf/descriptor.h" #include "google/protobuf/descriptor.pb.h" #include "google/protobuf/io/printer.h" -#include "google/protobuf/io/zero_copy_stream.h" +#include "google/protobuf/wire_format.h" +#include "google/protobuf/wire_format_lite.h" // Must be last. #include "google/protobuf/port_def.inc"
diff --git a/src/google/protobuf/compiler/csharp/csharp_message_field.cc b/src/google/protobuf/compiler/csharp/csharp_message_field.cc index 9d70bd0..1f30bdc 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_message_field.cc
@@ -34,23 +34,11 @@ #include "google/protobuf/compiler/code_generator.h" #include "google/protobuf/descriptor.h" -#include "google/protobuf/wire_format.h" -#include "google/protobuf/wire_format_lite.h" -#include "google/protobuf/stubs/strutil.h" -#include "absl/strings/ascii.h" -#include "absl/strings/escaping.h" -#include "absl/strings/str_split.h" -#include "absl/strings/str_replace.h" -#include "absl/strings/ascii.h" -#include "absl/strings/escaping.h" -#include "absl/strings/str_replace.h" -#include "absl/strings/str_split.h" #include "google/protobuf/compiler/csharp/csharp_doc_comment.h" #include "google/protobuf/compiler/csharp/csharp_helpers.h" #include "google/protobuf/compiler/csharp/csharp_options.h" #include "google/protobuf/descriptor.pb.h" #include "google/protobuf/io/printer.h" -#include "google/protobuf/io/zero_copy_stream.h" namespace google { namespace protobuf {
diff --git a/src/google/protobuf/compiler/csharp/csharp_names.h b/src/google/protobuf/compiler/csharp/csharp_names.h index 61f4b7b..e768811 100644 --- a/src/google/protobuf/compiler/csharp/csharp_names.h +++ b/src/google/protobuf/compiler/csharp/csharp_names.h
@@ -39,8 +39,6 @@ #define GOOGLE_PROTOBUF_COMPILER_CSHARP_NAMES_H__ #include <string> -#include "google/protobuf/port.h" -#include "google/protobuf/stubs/common.h" #include "google/protobuf/port_def.inc"
diff --git a/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc b/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc index f42ff90..1467bd3 100644 --- a/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc
@@ -33,22 +33,13 @@ #include <sstream> #include "google/protobuf/compiler/code_generator.h" -#include "google/protobuf/descriptor.h" -#include "google/protobuf/stubs/strutil.h" -#include "absl/strings/ascii.h" -#include "absl/strings/escaping.h" -#include "absl/strings/str_split.h" -#include "absl/strings/str_replace.h" -#include "absl/strings/ascii.h" -#include "absl/strings/escaping.h" -#include "absl/strings/str_replace.h" -#include "absl/strings/str_split.h" +#include "absl/strings/str_cat.h" #include "google/protobuf/compiler/csharp/csharp_doc_comment.h" #include "google/protobuf/compiler/csharp/csharp_helpers.h" #include "google/protobuf/compiler/csharp/csharp_options.h" +#include "google/protobuf/descriptor.h" #include "google/protobuf/descriptor.pb.h" #include "google/protobuf/io/printer.h" -#include "google/protobuf/io/zero_copy_stream.h" namespace google { namespace protobuf {
diff --git a/src/google/protobuf/compiler/csharp/csharp_reflection_class.cc b/src/google/protobuf/compiler/csharp/csharp_reflection_class.cc index b767c9d..95a0056 100644 --- a/src/google/protobuf/compiler/csharp/csharp_reflection_class.cc +++ b/src/google/protobuf/compiler/csharp/csharp_reflection_class.cc
@@ -33,25 +33,16 @@ #include <sstream> #include "google/protobuf/compiler/code_generator.h" -#include "google/protobuf/descriptor.h" -#include "google/protobuf/stubs/strutil.h" -#include "absl/strings/ascii.h" -#include "absl/strings/escaping.h" -#include "absl/strings/str_split.h" -#include "absl/strings/str_replace.h" -#include "absl/strings/ascii.h" -#include "absl/strings/escaping.h" -#include "absl/strings/str_replace.h" -#include "absl/strings/str_split.h" +#include "absl/strings/str_join.h" #include "google/protobuf/compiler/csharp/csharp_enum.h" #include "google/protobuf/compiler/csharp/csharp_field_base.h" #include "google/protobuf/compiler/csharp/csharp_helpers.h" #include "google/protobuf/compiler/csharp/csharp_message.h" #include "google/protobuf/compiler/csharp/csharp_names.h" #include "google/protobuf/compiler/csharp/csharp_options.h" +#include "google/protobuf/descriptor.h" #include "google/protobuf/descriptor.pb.h" #include "google/protobuf/io/printer.h" -#include "google/protobuf/io/zero_copy_stream.h" // Must be last. #include "google/protobuf/port_def.inc"
diff --git a/src/google/protobuf/compiler/importer.cc b/src/google/protobuf/compiler/importer.cc index 287b22e..a2de7e5 100644 --- a/src/google/protobuf/compiler/importer.cc +++ b/src/google/protobuf/compiler/importer.cc
@@ -48,7 +48,7 @@ #include <memory> #include <vector> -#include "google/protobuf/stubs/strutil.h" +#include "absl/strings/match.h" #include "absl/strings/str_join.h" #include "absl/strings/str_replace.h" #include "absl/strings/str_split.h" @@ -282,7 +282,7 @@ // backslashes are standard. Let's avoid confusion and use only forward // slashes. std::string path_str; - if (HasPrefixString(path, "\\\\")) { + if (absl::StartsWith(path, "\\\\")) { // Avoid converting two leading backslashes. path_str = "\\\\" + absl::StrReplaceAll(path.substr(2), {{"\\", "/"}}); } else { @@ -306,8 +306,8 @@ } static inline bool ContainsParentReference(absl::string_view path) { - return path == ".." || HasPrefixString(path, "../") || - HasSuffixString(path, "/..") || absl::StrContains(path, "/../"); + return path == ".." || absl::StartsWith(path, "../") || + absl::EndsWith(path, "/..") || absl::StrContains(path, "/../"); } // Maps a file from an old location to a new one. Typically, old_prefix is @@ -336,7 +336,7 @@ // We do not allow the file name to use "..". return false; } - if (HasPrefixString(filename, "/") || IsWindowsAbsolutePath(filename)) { + if (absl::StartsWith(filename, "/") || IsWindowsAbsolutePath(filename)) { // This is an absolute path, so it isn't matched by the empty string. return false; } @@ -344,7 +344,7 @@ if (!result->empty()) result->push_back('/'); result->append(std::string(filename)); return true; - } else if (HasPrefixString(filename, old_prefix)) { + } else if (absl::StartsWith(filename, old_prefix)) { // old_prefix is a prefix of the filename. Is it the whole filename? if (filename.size() == old_prefix.size()) { // Yep, it's an exact match.
diff --git a/src/google/protobuf/compiler/java/helpers.cc b/src/google/protobuf/compiler/java/helpers.cc index 625ff18..680a750 100644 --- a/src/google/protobuf/compiler/java/helpers.cc +++ b/src/google/protobuf/compiler/java/helpers.cc
@@ -221,7 +221,7 @@ if (i == '_') { capitalize_next = true; } else if (capitalize_next) { - result.push_back(ToUpperCh(i)); + result.push_back(absl::ascii_toupper(i)); capitalize_next = false; } else { result.push_back(i); @@ -230,20 +230,12 @@ // Lower-case the first letter. if (lower_first && !result.empty()) { - result[0] = ToLowerCh(result[0]); + result[0] = absl::ascii_tolower(result[0]); } return result; } -char ToUpperCh(char ch) { - return (ch >= 'a' && ch <= 'z') ? (ch - 'a' + 'A') : ch; -} - -char ToLowerCh(char ch) { - return (ch >= 'A' && ch <= 'Z') ? (ch - 'A' + 'a') : ch; -} - std::string UnderscoresToCamelCase(const FieldDescriptor* field) { return UnderscoresToCamelCase(FieldName(field), false); }
diff --git a/src/google/protobuf/compiler/java/helpers.h b/src/google/protobuf/compiler/java/helpers.h index eb16096..6fe43ae 100644 --- a/src/google/protobuf/compiler/java/helpers.h +++ b/src/google/protobuf/compiler/java/helpers.h
@@ -84,9 +84,6 @@ // first letter. std::string ToCamelCase(const std::string& input, bool lower_first); -char ToUpperCh(char ch); -char ToLowerCh(char ch); - // Converts a name to camel-case. If cap_first_letter is true, capitalize the // first letter. std::string UnderscoresToCamelCase(const std::string& name,
diff --git a/src/google/protobuf/compiler/mock_code_generator.cc b/src/google/protobuf/compiler/mock_code_generator.cc index f19cbf5..a4cc9e6 100644 --- a/src/google/protobuf/compiler/mock_code_generator.cc +++ b/src/google/protobuf/compiler/mock_code_generator.cc
@@ -39,19 +39,18 @@ #include <memory> #include <vector> -#include "google/protobuf/stubs/strutil.h" - #include "google/protobuf/stubs/logging.h" #include "google/protobuf/stubs/common.h" #include "google/protobuf/testing/file.h" #include "google/protobuf/testing/file.h" -#include "google/protobuf/testing/file.h" #include "google/protobuf/compiler/plugin.pb.h" #include "google/protobuf/descriptor.pb.h" #include <gtest/gtest.h> #include "absl/strings/str_join.h" #include "absl/strings/str_replace.h" #include "absl/strings/str_split.h" +#include "absl/strings/string_view.h" +#include "absl/strings/strip.h" #include "absl/strings/substitute.h" #include "google/protobuf/descriptor.h" #include "google/protobuf/io/printer.h" @@ -208,8 +207,8 @@ std::string* error) const { bool annotate = false; for (int i = 0; i < file->message_type_count(); i++) { - if (HasPrefixString(file->message_type(i)->name(), "MockCodeGenerator_")) { - std::string command = StripPrefixString( + if (absl::StartsWith(file->message_type(i)->name(), "MockCodeGenerator_")) { + absl::string_view command = absl::StripPrefix( file->message_type(i)->name(), "MockCodeGenerator_"); if (command == "Error") { *error = "Saw message type MockCodeGenerator_Error."; @@ -252,12 +251,12 @@ } } - bool insert_endlines = HasPrefixString(parameter, "insert_endlines="); - if (insert_endlines || HasPrefixString(parameter, "insert=")) { + bool insert_endlines = absl::StartsWith(parameter, "insert_endlines="); + if (insert_endlines || absl::StartsWith(parameter, "insert=")) { std::vector<std::string> insert_into = absl::StrSplit( - StripPrefixString( - parameter, insert_endlines ? "insert_endlines=" : "insert="), - ",", absl::SkipEmpty()); + absl::StripPrefix(parameter, + insert_endlines ? "insert_endlines=" : "insert="), + ',', absl::SkipEmpty()); for (size_t i = 0; i < insert_into.size(); i++) { { @@ -265,7 +264,7 @@ std::string content = GetOutputFileContent(name_, "first_insert", file, context); if (insert_endlines) { - GlobalReplaceSubstring(",", ",\n", &content); + absl::StrReplaceAll({{",", ",\n"}}, &content); } if (annotate) { auto* annotation = info.add_annotation(); @@ -290,7 +289,7 @@ std::string content = GetOutputFileContent(name_, "second_insert", file, context); if (insert_endlines) { - GlobalReplaceSubstring(",", ",\n", &content); + absl::StrReplaceAll({{",", ",\n"}}, &content); } if (annotate) { auto* annotation = info.add_annotation();
diff --git a/src/google/protobuf/compiler/objectivec/objectivec_enum.cc b/src/google/protobuf/compiler/objectivec/objectivec_enum.cc index 28ef44c..13954ca 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_enum.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_enum.cc
@@ -28,18 +28,16 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include "google/protobuf/compiler/objectivec/objectivec_enum.h" + #include <algorithm> #include <map> #include <string> -#include "absl/strings/ascii.h" #include "absl/strings/escaping.h" -#include "absl/strings/str_replace.h" -#include "absl/strings/str_split.h" -#include "google/protobuf/compiler/objectivec/objectivec_enum.h" +#include "absl/strings/str_cat.h" #include "google/protobuf/compiler/objectivec/objectivec_helpers.h" #include "google/protobuf/io/printer.h" -#include "google/protobuf/stubs/strutil.h" namespace google { namespace protobuf {
diff --git a/src/google/protobuf/compiler/objectivec/objectivec_extension.cc b/src/google/protobuf/compiler/objectivec/objectivec_extension.cc index 3c20a13..8102df2 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_extension.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_extension.cc
@@ -28,13 +28,11 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include "google/protobuf/compiler/objectivec/objectivec_extension.h" + #include <iostream> -#include "absl/strings/ascii.h" -#include "absl/strings/escaping.h" -#include "absl/strings/str_replace.h" -#include "absl/strings/str_split.h" -#include "google/protobuf/compiler/objectivec/objectivec_extension.h" +#include "absl/strings/str_cat.h" #include "google/protobuf/compiler/objectivec/objectivec_helpers.h" #include "google/protobuf/descriptor.pb.h" #include "google/protobuf/io/printer.h"
diff --git a/src/google/protobuf/compiler/objectivec/objectivec_field.cc b/src/google/protobuf/compiler/objectivec/objectivec_field.cc index 4397231..b98955b 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_field.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_field.cc
@@ -28,20 +28,17 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include "google/protobuf/compiler/objectivec/objectivec_field.h" + #include <iostream> -#include "absl/strings/ascii.h" -#include "absl/strings/escaping.h" -#include "absl/strings/str_replace.h" -#include "absl/strings/str_split.h" +#include "absl/strings/str_cat.h" #include "google/protobuf/compiler/objectivec/objectivec_enum_field.h" -#include "google/protobuf/compiler/objectivec/objectivec_field.h" #include "google/protobuf/compiler/objectivec/objectivec_helpers.h" #include "google/protobuf/compiler/objectivec/objectivec_map_field.h" #include "google/protobuf/compiler/objectivec/objectivec_message_field.h" #include "google/protobuf/compiler/objectivec/objectivec_primitive_field.h" #include "google/protobuf/io/printer.h" -#include "google/protobuf/stubs/strutil.h" namespace google { namespace protobuf {
diff --git a/src/google/protobuf/compiler/objectivec/objectivec_file.cc b/src/google/protobuf/compiler/objectivec/objectivec_file.cc index 72caa47..496786e 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_file.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_file.cc
@@ -28,24 +28,20 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include "google/protobuf/compiler/objectivec/objectivec_file.h" + #include <algorithm> #include <iostream> #include <sstream> -#include "absl/strings/ascii.h" -#include "absl/strings/escaping.h" -#include "absl/strings/str_replace.h" -#include "absl/strings/str_split.h" #include "google/protobuf/compiler/code_generator.h" +#include "absl/strings/str_cat.h" #include "google/protobuf/compiler/objectivec/objectivec_enum.h" #include "google/protobuf/compiler/objectivec/objectivec_extension.h" #include "google/protobuf/compiler/objectivec/objectivec_file.h" #include "google/protobuf/compiler/objectivec/objectivec_helpers.h" #include "google/protobuf/compiler/objectivec/objectivec_message.h" #include "google/protobuf/io/printer.h" -#include "google/protobuf/io/zero_copy_stream_impl.h" -#include "google/protobuf/stubs/stl_util.h" -#include "google/protobuf/stubs/strutil.h" // NOTE: src/google/protobuf/compiler/plugin.cc makes use of cerr for some // error cases, so it seems to be ok to use as a back door for errors.
diff --git a/src/google/protobuf/compiler/objectivec/objectivec_generator.cc b/src/google/protobuf/compiler/objectivec/objectivec_generator.cc index 225a7d2..ec4071b 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_generator.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_generator.cc
@@ -28,21 +28,21 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include "google/protobuf/compiler/objectivec/objectivec_generator.h" + #include <fstream> #include <iostream> #include <string> #include <unordered_set> #include "absl/strings/ascii.h" -#include "absl/strings/escaping.h" -#include "absl/strings/str_replace.h" #include "absl/strings/str_split.h" +#include "absl/strings/strip.h" #include "google/protobuf/compiler/objectivec/objectivec_file.h" #include "google/protobuf/compiler/objectivec/objectivec_generator.h" #include "google/protobuf/compiler/objectivec/objectivec_helpers.h" #include "google/protobuf/io/printer.h" #include "google/protobuf/io/zero_copy_stream.h" -#include "google/protobuf/stubs/strutil.h" namespace google { namespace protobuf { @@ -104,7 +104,7 @@ std::vector<std::pair<std::string, std::string> > options; ParseGeneratorParameter(parameter, &options); - for (int i = 0; i < options.size(); i++) { + for (size_t i = 0; i < options.size(); i++) { if (options[i].first == "expected_prefixes_path") { // Path to find a file containing the expected prefixes // (objc_class_prefix "PREFIX") for proto packages (package NAME). The @@ -194,7 +194,8 @@ // generated files. When integrating ObjC protos into a build system, // this can be used to avoid having to add the runtime directory to the // header search path since the generate #import will be more complete. - generation_options.runtime_import_prefix = StripSuffixString(options[i].second, "/"); + generation_options.runtime_import_prefix = + std::string(absl::StripSuffix(options[i].second, "/")); } else if (options[i].first == "package_to_prefix_mappings_path") { // Path to use for when loading the objc class prefix mappings to use. // The `objc_class_prefix` file option is always honored first if one is present.
diff --git a/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc b/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc index f4a3693..a9404ca 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc
@@ -31,21 +31,24 @@ #ifndef _MSC_VER #include <unistd.h> #endif -#include <climits> #include <errno.h> #include <fcntl.h> +#include <stdlib.h> + +#include <climits> #include <fstream> #include <iostream> #include <sstream> -#include <stdlib.h> #include <unordered_set> #include <vector> +#include "google/protobuf/compiler/code_generator.h" +#include "google/protobuf/stubs/strutil.h" #include "absl/strings/ascii.h" #include "absl/strings/escaping.h" #include "absl/strings/str_replace.h" #include "absl/strings/str_split.h" -#include "google/protobuf/compiler/code_generator.h" +#include "absl/strings/strip.h" #include "google/protobuf/compiler/objectivec/objectivec_helpers.h" #include "google/protobuf/compiler/objectivec/objectivec_nsobject_methods.h" #include "google/protobuf/descriptor.pb.h" @@ -55,7 +58,6 @@ #include "google/protobuf/io/zero_copy_stream_impl.h" #include "google/protobuf/port.h" #include "google/protobuf/stubs/common.h" -#include "google/protobuf/stubs/strutil.h" // NOTE: src/google/protobuf/compiler/plugin.cc makes use of cerr for some // error cases, so it seems to be ok to use as a back door for errors. @@ -466,7 +468,7 @@ // a) Doesn't start with the prefix or // b) Isn't equivalent to the prefix or // c) Has the prefix, but the letter after the prefix is lowercase - if (HasPrefixString(input, prefix)) { + if (absl::StartsWith(input, prefix)) { if (input.length() == prefix.length() || !absl::ascii_isupper(input[prefix.length()])) { sanitized = prefix + input; } else { @@ -797,7 +799,7 @@ const std::string class_name = EnumName(descriptor->type()); const std::string long_name_prefix = class_name + "_"; const std::string long_name = EnumValueName(descriptor); - return StripPrefixString(long_name, long_name_prefix); + return std::string(absl::StripPrefix(long_name, long_name_prefix)); } std::string UnCamelCaseEnumShortName(const std::string& name) { @@ -826,7 +828,7 @@ result += "Array"; } else { // If it wasn't repeated, but ends in "Array", force on the _p suffix. - if (HasSuffixString(result, "Array")) { + if (absl::EndsWith(result, "Array")) { result += "_p"; } } @@ -876,20 +878,22 @@ } std::string UnCamelCaseFieldName(const std::string& name, const FieldDescriptor* field) { - std::string worker(name); - if (HasSuffixString(worker, "_p")) { - worker = StripSuffixString(worker, "_p"); + absl::string_view worker(name); + if (absl::EndsWith(worker, "_p")) { + worker = absl::StripSuffix(worker, "_p"); } - if (field->is_repeated() && HasSuffixString(worker, "Array")) { - worker = StripSuffixString(worker, "Array"); + if (field->is_repeated() && absl::EndsWith(worker, "Array")) { + worker = absl::StripSuffix(worker, "Array"); } if (field->type() == FieldDescriptor::TYPE_GROUP) { if (worker.length() > 0) { if (absl::ascii_islower(worker[0])) { - worker[0] = absl::ascii_toupper(worker[0]); + std::string copy(worker); + copy[0] = absl::ascii_toupper(worker[0]); + return copy; } } - return worker; + return std::string(worker); } else { std::string result; for (int i = 0; i < worker.size(); i++) { @@ -1252,7 +1256,7 @@ for (size_t i = 0; i < lines.size(); i++) { std::string line = absl::StrReplaceAll( - StripPrefixString(lines[i], " "), + absl::StripPrefix(lines[i], " "), {// HeaderDoc and appledoc use '\' and '@' for markers; escape them. {"\\", "\\\\"}, {"@", "\\@"}, @@ -1260,9 +1264,9 @@ {"/*", "/\\*"}, {"*/", "*\\/"}}); line = prefix + line; - StripWhitespace(&line); + absl::StripAsciiWhitespace(&line); // If not a one line, need to add the first space before *, as - // StripWhitespace would have removed it. + // absl::StripAsciiWhitespace would have removed it. line = (add_leading_space ? " " : "") + line; final_comments += line + suffix; } @@ -1425,7 +1429,7 @@ other_package_for_prefix = i->first; // Stop on the first real package listing, if it was a no_package file // specific entry, keep looking to try and find a package one. - if (!HasPrefixString(other_package_for_prefix, no_package_prefix)) { + if (!absl::StartsWith(other_package_for_prefix, no_package_prefix)) { break; } } @@ -1438,16 +1442,19 @@ *out_error = "error: Found 'option objc_class_prefix = \"" + prefix + "\";' in '" + file->name() + "'; that prefix is already used for "; - if (HasPrefixString(other_package_for_prefix, no_package_prefix)) { - *out_error += "file '" + - StripPrefixString(other_package_for_prefix, no_package_prefix) + - "'."; + if (absl::StartsWith(other_package_for_prefix, no_package_prefix)) { + absl::StrAppend( + out_error, "file '", + absl::StripPrefix(other_package_for_prefix, no_package_prefix), + "'."); } else { - *out_error += "'package " + other_package_for_prefix + ";'."; + absl::StrAppend(out_error, "'package ", + other_package_for_prefix + ";'."); } - *out_error += - " It can only be reused by adding '" + lookup_key + " = " + prefix + - "' to the expected prefixes file (" + expected_prefixes_path + ")."; + absl::StrAppend(out_error, " It can only be reused by adding '", + lookup_key, " = ", prefix, + "' to the expected prefixes file (", + expected_prefixes_path, ")."); return false; // Only report first usage of the prefix. } } // !prefix.empty() && have_expected_prefix_file
diff --git a/src/google/protobuf/compiler/objectivec/objectivec_message.cc b/src/google/protobuf/compiler/objectivec/objectivec_message.cc index dd3eacb..9816149 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_message.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_message.cc
@@ -28,24 +28,19 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include "google/protobuf/compiler/objectivec/objectivec_message.h" + #include <algorithm> #include <iostream> #include <sstream> -#include "absl/strings/ascii.h" #include "absl/strings/escaping.h" -#include "absl/strings/str_replace.h" -#include "absl/strings/str_split.h" +#include "absl/strings/str_cat.h" #include "google/protobuf/compiler/objectivec/objectivec_enum.h" #include "google/protobuf/compiler/objectivec/objectivec_extension.h" #include "google/protobuf/compiler/objectivec/objectivec_helpers.h" -#include "google/protobuf/compiler/objectivec/objectivec_message.h" #include "google/protobuf/descriptor.pb.h" -#include "google/protobuf/io/coded_stream.h" #include "google/protobuf/io/printer.h" -#include "google/protobuf/io/zero_copy_stream_impl.h" -#include "google/protobuf/stubs/stl_util.h" -#include "google/protobuf/stubs/strutil.h" namespace google { namespace protobuf {
diff --git a/src/google/protobuf/compiler/objectivec/objectivec_oneof.cc b/src/google/protobuf/compiler/objectivec/objectivec_oneof.cc index dc218df..279928b 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_oneof.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_oneof.cc
@@ -28,17 +28,14 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include "google/protobuf/compiler/objectivec/objectivec_oneof.h" + #include <map> #include <string> -#include "absl/strings/ascii.h" -#include "absl/strings/escaping.h" -#include "absl/strings/str_replace.h" -#include "absl/strings/str_split.h" +#include "absl/strings/str_cat.h" #include "google/protobuf/compiler/objectivec/objectivec_helpers.h" -#include "google/protobuf/compiler/objectivec/objectivec_oneof.h" #include "google/protobuf/io/printer.h" -#include "google/protobuf/stubs/strutil.h" namespace google { namespace protobuf {
diff --git a/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc b/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc index 824bdbf..c9339a5 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc
@@ -28,17 +28,14 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include "google/protobuf/compiler/objectivec/objectivec_primitive_field.h" + #include <map> #include <string> -#include "absl/strings/ascii.h" -#include "absl/strings/escaping.h" -#include "absl/strings/str_replace.h" -#include "absl/strings/str_split.h" +#include "absl/strings/str_cat.h" #include "google/protobuf/compiler/objectivec/objectivec_helpers.h" -#include "google/protobuf/compiler/objectivec/objectivec_primitive_field.h" #include "google/protobuf/io/printer.h" -#include "google/protobuf/stubs/strutil.h" namespace google { namespace protobuf {
diff --git a/src/google/protobuf/compiler/php/php_generator.cc b/src/google/protobuf/compiler/php/php_generator.cc index 7c1daec..7466f74 100644 --- a/src/google/protobuf/compiler/php/php_generator.cc +++ b/src/google/protobuf/compiler/php/php_generator.cc
@@ -33,13 +33,12 @@ #include <sstream> #include "google/protobuf/compiler/code_generator.h" -#include "google/protobuf/compiler/plugin.h" -#include "google/protobuf/descriptor.h" #include "google/protobuf/stubs/strutil.h" #include "absl/strings/ascii.h" #include "absl/strings/escaping.h" -#include "absl/strings/str_split.h" #include "absl/strings/str_replace.h" +#include "absl/strings/str_split.h" +#include "google/protobuf/descriptor.h" #include "google/protobuf/descriptor.pb.h" #include "google/protobuf/io/printer.h" #include "google/protobuf/io/zero_copy_stream.h" @@ -153,8 +152,7 @@ template <typename DescriptorType> std::string DescriptorFullName(const DescriptorType* desc, bool is_internal) { if (is_internal) { - return StringReplace(desc->full_name(), - "google.protobuf", + return StringReplace(desc->full_name(), "google.protobuf", "google.protobuf.internal", false); } else { return desc->full_name(); @@ -1110,7 +1108,7 @@ has_aggregate_metadata_prefix = true; } else { for (const auto& prefix : options.aggregate_metadata_prefixes) { - if (HasPrefixString(file->package(), prefix)) { + if (absl::StartsWith(file->package(), prefix)) { has_aggregate_metadata_prefix = true; break; } @@ -2392,7 +2390,7 @@ for (const auto& option : absl::StrSplit(parameter, ",", absl::SkipEmpty())) { const std::vector<std::string> option_pair = absl::StrSplit(option, "=", absl::SkipEmpty()); - if (HasPrefixString(option_pair[0], "aggregate_metadata")) { + if (absl::StartsWith(option_pair[0], "aggregate_metadata")) { options.aggregate_metadata = true; for (const auto& prefix : absl::StrSplit(option_pair[1], "#", absl::AllowEmpty())) { options.aggregate_metadata_prefixes.emplace(prefix);
diff --git a/src/google/protobuf/compiler/plugin.pb.cc b/src/google/protobuf/compiler/plugin.pb.cc index bcaf8d5..87d4dda 100644 --- a/src/google/protobuf/compiler/plugin.pb.cc +++ b/src/google/protobuf/compiler/plugin.pb.cc
@@ -1,10 +1,9 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/protobuf/compiler/plugin.proto -#include <google/protobuf/compiler/plugin.pb.h> +#include "google/protobuf/compiler/plugin.pb.h" #include <algorithm> - #include "google/protobuf/io/coded_stream.h" #include "google/protobuf/extension_set.h" #include "google/protobuf/wire_format_lite.h" @@ -13,13 +12,12 @@ #include "google/protobuf/reflection_ops.h" #include "google/protobuf/wire_format.h" // @@protoc_insertion_point(includes) + +// Must be included last. #include "google/protobuf/port_def.inc" - PROTOBUF_PRAGMA_INIT_SEG - namespace _pb = ::PROTOBUF_NAMESPACE_ID; -namespace _pbi = _pb::internal; - +namespace _pbi = ::PROTOBUF_NAMESPACE_ID::internal; PROTOBUF_NAMESPACE_OPEN namespace compiler { PROTOBUF_CONSTEXPR Version::Version( @@ -31,14 +29,15 @@ , /*decltype(_impl_.minor_)*/0 , /*decltype(_impl_.patch_)*/0} {} struct VersionDefaultTypeInternal { - PROTOBUF_CONSTEXPR VersionDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR VersionDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~VersionDefaultTypeInternal() {} union { Version _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 VersionDefaultTypeInternal _Version_default_instance_; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 VersionDefaultTypeInternal _Version_default_instance_; PROTOBUF_CONSTEXPR CodeGeneratorRequest::CodeGeneratorRequest( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_._has_bits_)*/{} @@ -48,14 +47,15 @@ , /*decltype(_impl_.parameter_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} , /*decltype(_impl_.compiler_version_)*/nullptr} {} struct CodeGeneratorRequestDefaultTypeInternal { - PROTOBUF_CONSTEXPR CodeGeneratorRequestDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR CodeGeneratorRequestDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~CodeGeneratorRequestDefaultTypeInternal() {} union { CodeGeneratorRequest _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 CodeGeneratorRequestDefaultTypeInternal _CodeGeneratorRequest_default_instance_; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 CodeGeneratorRequestDefaultTypeInternal _CodeGeneratorRequest_default_instance_; PROTOBUF_CONSTEXPR CodeGeneratorResponse_File::CodeGeneratorResponse_File( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_._has_bits_)*/{} @@ -65,14 +65,15 @@ , /*decltype(_impl_.content_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} , /*decltype(_impl_.generated_code_info_)*/nullptr} {} struct CodeGeneratorResponse_FileDefaultTypeInternal { - PROTOBUF_CONSTEXPR CodeGeneratorResponse_FileDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR CodeGeneratorResponse_FileDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~CodeGeneratorResponse_FileDefaultTypeInternal() {} union { CodeGeneratorResponse_File _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 CodeGeneratorResponse_FileDefaultTypeInternal _CodeGeneratorResponse_File_default_instance_; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 CodeGeneratorResponse_FileDefaultTypeInternal _CodeGeneratorResponse_File_default_instance_; PROTOBUF_CONSTEXPR CodeGeneratorResponse::CodeGeneratorResponse( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_._has_bits_)*/{} @@ -81,138 +82,163 @@ , /*decltype(_impl_.error_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} , /*decltype(_impl_.supported_features_)*/uint64_t{0u}} {} struct CodeGeneratorResponseDefaultTypeInternal { - PROTOBUF_CONSTEXPR CodeGeneratorResponseDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR CodeGeneratorResponseDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~CodeGeneratorResponseDefaultTypeInternal() {} union { CodeGeneratorResponse _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 CodeGeneratorResponseDefaultTypeInternal _CodeGeneratorResponse_default_instance_; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 CodeGeneratorResponseDefaultTypeInternal _CodeGeneratorResponse_default_instance_; } // namespace compiler PROTOBUF_NAMESPACE_CLOSE static ::_pb::Metadata file_level_metadata_google_2fprotobuf_2fcompiler_2fplugin_2eproto[4]; static const ::_pb::EnumDescriptor* file_level_enum_descriptors_google_2fprotobuf_2fcompiler_2fplugin_2eproto[1]; -static constexpr ::_pb::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2fcompiler_2fplugin_2eproto = nullptr; - -const uint32_t TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::Version, _impl_._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 _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::Version, _impl_.major_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::Version, _impl_.minor_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::Version, _impl_.patch_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::Version, _impl_.suffix_), - 1, - 2, - 3, - 0, - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest, _impl_._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 _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest, _impl_.file_to_generate_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest, _impl_.parameter_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest, _impl_.proto_file_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest, _impl_.compiler_version_), - ~0u, - 0, - ~0u, - 1, - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File, _impl_._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 _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File, _impl_.name_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File, _impl_.insertion_point_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File, _impl_.content_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File, _impl_.generated_code_info_), - 0, - 1, - 2, - 3, - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse, _impl_._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 _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse, _impl_.error_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse, _impl_.supported_features_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse, _impl_.file_), - 0, - 1, - ~0u, +static constexpr const ::_pb::ServiceDescriptor** + file_level_service_descriptors_google_2fprotobuf_2fcompiler_2fplugin_2eproto = nullptr; +const uint32_t TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE( + protodesc_cold) = { + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::Version, _impl_._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 _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::Version, _impl_.major_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::Version, _impl_.minor_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::Version, _impl_.patch_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::Version, _impl_.suffix_), + 1, + 2, + 3, + 0, + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest, _impl_._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 _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest, _impl_.file_to_generate_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest, _impl_.parameter_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest, _impl_.proto_file_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest, _impl_.compiler_version_), + ~0u, + 0, + ~0u, + 1, + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File, _impl_._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 _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File, _impl_.name_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File, _impl_.insertion_point_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File, _impl_.content_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File, _impl_.generated_code_info_), + 0, + 1, + 2, + 3, + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse, _impl_._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 _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse, _impl_.error_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse, _impl_.supported_features_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse, _impl_.file_), + 0, + 1, + ~0u, }; -static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { - { 0, 12, -1, sizeof(::PROTOBUF_NAMESPACE_ID::compiler::Version)}, - { 16, 28, -1, sizeof(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest)}, - { 32, 44, -1, sizeof(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File)}, - { 48, 59, -1, sizeof(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse)}, + +static const ::_pbi::MigrationSchema + schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + { 0, 12, -1, sizeof(::PROTOBUF_NAMESPACE_ID::compiler::Version)}, + { 16, 28, -1, sizeof(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest)}, + { 32, 44, -1, sizeof(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File)}, + { 48, 59, -1, sizeof(::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse)}, }; static const ::_pb::Message* const file_default_instances[] = { - &::PROTOBUF_NAMESPACE_ID::compiler::_Version_default_instance_._instance, - &::PROTOBUF_NAMESPACE_ID::compiler::_CodeGeneratorRequest_default_instance_._instance, - &::PROTOBUF_NAMESPACE_ID::compiler::_CodeGeneratorResponse_File_default_instance_._instance, - &::PROTOBUF_NAMESPACE_ID::compiler::_CodeGeneratorResponse_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::compiler::_Version_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::compiler::_CodeGeneratorRequest_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::compiler::_CodeGeneratorResponse_File_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::compiler::_CodeGeneratorResponse_default_instance_._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" - "uf/descriptor.proto\"F\n\007Version\022\r\n\005major\030" - "\001 \001(\005\022\r\n\005minor\030\002 \001(\005\022\r\n\005patch\030\003 \001(\005\022\016\n\006s" - "uffix\030\004 \001(\t\"\272\001\n\024CodeGeneratorRequest\022\030\n\020" - "file_to_generate\030\001 \003(\t\022\021\n\tparameter\030\002 \001(" - "\t\0228\n\nproto_file\030\017 \003(\0132$.google.protobuf." - "FileDescriptorProto\022;\n\020compiler_version\030" - "\003 \001(\0132!.google.protobuf.compiler.Version" - "\"\301\002\n\025CodeGeneratorResponse\022\r\n\005error\030\001 \001(" - "\t\022\032\n\022supported_features\030\002 \001(\004\022B\n\004file\030\017 " - "\003(\01324.google.protobuf.compiler.CodeGener" - "atorResponse.File\032\177\n\004File\022\014\n\004name\030\001 \001(\t\022" - "\027\n\017insertion_point\030\002 \001(\t\022\017\n\007content\030\017 \001(" - "\t\022\?\n\023generated_code_info\030\020 \001(\0132\".google." - "protobuf.GeneratedCodeInfo\"8\n\007Feature\022\020\n" - "\014FEATURE_NONE\020\000\022\033\n\027FEATURE_PROTO3_OPTION" - "AL\020\001BW\n\034com.google.protobuf.compilerB\014Pl" - "uginProtosZ)google.golang.org/protobuf/t" - "ypes/pluginpb" - ; -static const ::_pbi::DescriptorTable* const descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_deps[1] = { - &::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto, +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" + "uf/descriptor.proto\"F\n\007Version\022\r\n\005major\030" + "\001 \001(\005\022\r\n\005minor\030\002 \001(\005\022\r\n\005patch\030\003 \001(\005\022\016\n\006s" + "uffix\030\004 \001(\t\"\272\001\n\024CodeGeneratorRequest\022\030\n\020" + "file_to_generate\030\001 \003(\t\022\021\n\tparameter\030\002 \001(" + "\t\0228\n\nproto_file\030\017 \003(\0132$.google.protobuf." + "FileDescriptorProto\022;\n\020compiler_version\030" + "\003 \001(\0132!.google.protobuf.compiler.Version" + "\"\301\002\n\025CodeGeneratorResponse\022\r\n\005error\030\001 \001(" + "\t\022\032\n\022supported_features\030\002 \001(\004\022B\n\004file\030\017 " + "\003(\01324.google.protobuf.compiler.CodeGener" + "atorResponse.File\032\177\n\004File\022\014\n\004name\030\001 \001(\t\022" + "\027\n\017insertion_point\030\002 \001(\t\022\017\n\007content\030\017 \001(" + "\t\022\?\n\023generated_code_info\030\020 \001(\0132\".google." + "protobuf.GeneratedCodeInfo\"8\n\007Feature\022\020\n" + "\014FEATURE_NONE\020\000\022\033\n\027FEATURE_PROTO3_OPTION" + "AL\020\001BW\n\034com.google.protobuf.compilerB\014Pl" + "uginProtosZ)google.golang.org/protobuf/t" + "ypes/pluginpb" +}; +static const ::_pbi::DescriptorTable* const descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_deps[1] = + { + &::descriptor_table_google_2fprotobuf_2fdescriptor_2eproto, }; static ::absl::once_flag descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once; const ::_pbi::DescriptorTable descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto = { - false, false, 773, descriptor_table_protodef_google_2fprotobuf_2fcompiler_2fplugin_2eproto, + false, + false, + 773, + descriptor_table_protodef_google_2fprotobuf_2fcompiler_2fplugin_2eproto, "google/protobuf/compiler/plugin.proto", - &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once, descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_deps, 1, 4, - schemas, file_default_instances, TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto::offsets, - file_level_metadata_google_2fprotobuf_2fcompiler_2fplugin_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fcompiler_2fplugin_2eproto, + &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once, + descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_deps, + 1, + 4, + schemas, + file_default_instances, + TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto::offsets, + file_level_metadata_google_2fprotobuf_2fcompiler_2fplugin_2eproto, + file_level_enum_descriptors_google_2fprotobuf_2fcompiler_2fplugin_2eproto, file_level_service_descriptors_google_2fprotobuf_2fcompiler_2fplugin_2eproto, }; + +// 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 of more than 35% of walltime for optimized builds. Without +// the weak attribute all the messages in the file, including all the +// vtables and everything they use become part of the same SCC through +// a cycle like: +// GetMetadata -> descriptor table -> default instances -> +// vtables -> GetMetadata +// By adding a weak function here we break the connection from the +// individual vtables back into the descriptor table. PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::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_PRIORITY2 static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2fcompiler_2fplugin_2eproto(&descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto); +PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 +static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2fcompiler_2fplugin_2eproto(&descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto); PROTOBUF_NAMESPACE_OPEN namespace compiler { const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* CodeGeneratorResponse_Feature_descriptor() { @@ -236,7 +262,6 @@ constexpr CodeGeneratorResponse_Feature CodeGeneratorResponse::Feature_MAX; constexpr int CodeGeneratorResponse::Feature_ARRAYSIZE; #endif // (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) - // =================================================================== class Version::_Internal { @@ -562,7 +587,6 @@ &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 { @@ -916,7 +940,6 @@ &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_getter, &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once, file_level_metadata_google_2fprotobuf_2fcompiler_2fplugin_2eproto[1]); } - // =================================================================== class CodeGeneratorResponse_File::_Internal { @@ -1308,7 +1331,6 @@ &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_getter, &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once, file_level_metadata_google_2fprotobuf_2fcompiler_2fplugin_2eproto[2]); } - // =================================================================== class CodeGeneratorResponse::_Internal { @@ -1601,7 +1623,6 @@ &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_getter, &descriptor_table_google_2fprotobuf_2fcompiler_2fplugin_2eproto_once, file_level_metadata_google_2fprotobuf_2fcompiler_2fplugin_2eproto[3]); } - // @@protoc_insertion_point(namespace_scope) } // namespace compiler PROTOBUF_NAMESPACE_CLOSE @@ -1623,6 +1644,5 @@ return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse >(arena); } PROTOBUF_NAMESPACE_CLOSE - // @@protoc_insertion_point(global_scope) #include "google/protobuf/port_undef.inc"
diff --git a/src/google/protobuf/compiler/plugin.pb.h b/src/google/protobuf/compiler/plugin.pb.h index dc3712a..9b8dd81 100644 --- a/src/google/protobuf/compiler/plugin.pb.h +++ b/src/google/protobuf/compiler/plugin.pb.h
@@ -6,6 +6,7 @@ #include <limits> #include <string> +#include <type_traits> #include "google/protobuf/port_def.inc" #if PROTOBUF_VERSION < 3021000 @@ -19,6 +20,11 @@ #error regenerate this file with a newer version of protoc. #endif +#if 3021005 < PROTOBUF_MIN_PROTOC_VERSION +#error "This file was generated by an older version of protoc which is" +#error "incompatible with your Protocol Buffer headers. Please" +#error "regenerate this file with a newer version of protoc." +#endif // PROTOBUF_MIN_PROTOC_VERSION #include "google/protobuf/port_undef.inc" #include "google/protobuf/io/coded_stream.h" #include "google/protobuf/arena.h" @@ -31,16 +37,20 @@ #include "google/protobuf/extension_set.h" // IWYU pragma: export #include "google/protobuf/generated_enum_reflection.h" #include "google/protobuf/unknown_field_set.h" -#include <google/protobuf/descriptor.pb.h> +#include "google/protobuf/descriptor.pb.h" // @@protoc_insertion_point(includes) + +// Must be included last. #include "google/protobuf/port_def.inc" + #define PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fcompiler_2fplugin_2eproto PROTOC_EXPORT #ifdef major #undef major -#endif +#endif // major #ifdef minor #undef minor -#endif +#endif // minor + PROTOBUF_NAMESPACE_OPEN namespace internal { class AnyMetadata; @@ -51,7 +61,8 @@ struct PROTOC_EXPORT TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto { static const uint32_t offsets[]; }; -PROTOC_EXPORT extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_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; @@ -67,16 +78,18 @@ struct VersionDefaultTypeInternal; PROTOC_EXPORT extern VersionDefaultTypeInternal _Version_default_instance_; } // namespace compiler +template <> +PROTOC_EXPORT ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest>(Arena*); +template <> +PROTOC_EXPORT ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse>(Arena*); +template <> +PROTOC_EXPORT ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File>(Arena*); +template <> +PROTOC_EXPORT ::PROTOBUF_NAMESPACE_ID::compiler::Version* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::compiler::Version>(Arena*); PROTOBUF_NAMESPACE_CLOSE -PROTOBUF_NAMESPACE_OPEN -template<> PROTOC_EXPORT ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorRequest>(Arena*); -template<> PROTOC_EXPORT ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse>(Arena*); -template<> PROTOC_EXPORT ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_File>(Arena*); -template<> PROTOC_EXPORT ::PROTOBUF_NAMESPACE_ID::compiler::Version* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::compiler::Version>(Arena*); -PROTOBUF_NAMESPACE_CLOSE + PROTOBUF_NAMESPACE_OPEN namespace compiler { - enum CodeGeneratorResponse_Feature : int { CodeGeneratorResponse_Feature_FEATURE_NONE = 0, CodeGeneratorResponse_Feature_FEATURE_PROTO3_OPTIONAL = 1 @@ -104,8 +117,12 @@ return ::PROTOBUF_NAMESPACE_ID::internal::ParseNamedEnum<CodeGeneratorResponse_Feature>( CodeGeneratorResponse_Feature_descriptor(), name, value); } + // =================================================================== + +// ------------------------------------------------------------------- + class PROTOC_EXPORT Version final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.Version) */ { public: @@ -313,8 +330,7 @@ }; union { Impl_ _impl_; }; 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) */ { @@ -544,8 +560,7 @@ }; union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto; -}; -// ------------------------------------------------------------------- +};// ------------------------------------------------------------------- class PROTOC_EXPORT CodeGeneratorResponse_File final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.CodeGeneratorResponse.File) */ { @@ -769,8 +784,7 @@ }; union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fcompiler_2fplugin_2eproto; -}; -// ------------------------------------------------------------------- +};// ------------------------------------------------------------------- class PROTOC_EXPORT CodeGeneratorResponse final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.CodeGeneratorResponse) */ { @@ -1005,12 +1019,17 @@ // =================================================================== + + // =================================================================== + #ifdef __GNUC__ - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wstrict-aliasing" +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstrict-aliasing" #endif // __GNUC__ +// ------------------------------------------------------------------- + // Version // optional int32 major = 1; @@ -1861,20 +1880,14 @@ } #ifdef __GNUC__ - #pragma GCC diagnostic pop +#pragma GCC diagnostic pop #endif // __GNUC__ -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - // @@protoc_insertion_point(namespace_scope) - } // namespace compiler PROTOBUF_NAMESPACE_CLOSE + PROTOBUF_NAMESPACE_OPEN template <> struct is_proto_enum< ::PROTOBUF_NAMESPACE_ID::compiler::CodeGeneratorResponse_Feature> : ::std::true_type {}; @@ -1888,4 +1901,5 @@ // @@protoc_insertion_point(global_scope) #include "google/protobuf/port_undef.inc" -#endif // GOOGLE_PROTOBUF_INCLUDED_GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fcompiler_2fplugin_2eproto_2epb_2eh + +#endif // GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fcompiler_2fplugin_2eproto_2epb_2eh
diff --git a/src/google/protobuf/compiler/python/generator.cc b/src/google/protobuf/compiler/python/generator.cc index 3d580ad..deb5b09 100644 --- a/src/google/protobuf/compiler/python/generator.cc +++ b/src/google/protobuf/compiler/python/generator.cc
@@ -59,6 +59,8 @@ #include "absl/strings/escaping.h" #include "absl/strings/str_cat.h" #include "google/protobuf/stubs/stringprintf.h" +#include "absl/strings/str_replace.h" +#include "absl/strings/strip.h" #include "absl/strings/substitute.h" #include "google/protobuf/compiler/python/helpers.h" #include "google/protobuf/compiler/python/pyi_generator.h" @@ -82,8 +84,8 @@ // We can't have dots in the module name, so we replace each with _dot_. // But that could lead to a collision between a.b and a_dot_b, so we also // duplicate each underscore. - GlobalReplaceSubstring("_", "__", &module_name); - GlobalReplaceSubstring(".", "_dot_", &module_name); + absl::StrReplaceAll({{"_", "__"}}, &module_name); + absl::StrReplaceAll({{".", "_dot_"}}, &module_name); return module_name; } @@ -315,7 +317,8 @@ } std::string module_name = ModuleName(file->name()); if (!opensource_runtime_) { - module_name = StripPrefixString(module_name, kThirdPartyPrefix); + module_name = + std::string(absl::StripPrefix(module_name, kThirdPartyPrefix)); } printer_->Print( "_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, '$module_name$', " @@ -386,7 +389,8 @@ std::string module_name = ModuleName(filename); std::string module_alias = ModuleAlias(filename); if (!opensource_runtime_) { - module_name = StripPrefixString(module_name, kThirdPartyPrefix); + module_name = + std::string(absl::StripPrefix(module_name, kThirdPartyPrefix)); } if (ContainsPythonKeyword(module_name)) { // If the module path contains a Python keyword, we have to quote the @@ -419,7 +423,8 @@ for (int i = 0; i < file_->public_dependency_count(); ++i) { std::string module_name = ModuleName(file_->public_dependency(i)->name()); if (!opensource_runtime_) { - module_name = StripPrefixString(module_name, kThirdPartyPrefix); + module_name = + std::string(absl::StripPrefix(module_name, kThirdPartyPrefix)); } printer_->Print("from $module$ import *\n", "module", module_name); } @@ -592,7 +597,8 @@ kDescriptorKey, "descriptor_name", name); std::string module_name = ModuleName(file_->name()); if (!opensource_runtime_) { - module_name = StripPrefixString(module_name, kThirdPartyPrefix); + module_name = + std::string(absl::StripPrefix(module_name, kThirdPartyPrefix)); } printer_->Print("__module__ = '$module_name$'\n", "module_name", module_name); } @@ -784,7 +790,8 @@ printer_->Print(m, "'$descriptor_key$' : $descriptor_name$,\n"); std::string module_name = ModuleName(file_->name()); if (!opensource_runtime_) { - module_name = StripPrefixString(module_name, kThirdPartyPrefix); + module_name = + std::string(absl::StripPrefix(module_name, kThirdPartyPrefix)); } printer_->Print("'__module__' : '$module_name$'\n", "module_name", module_name);
diff --git a/src/google/protobuf/compiler/python/helpers.cc b/src/google/protobuf/compiler/python/helpers.cc index 711d555..e58ed9c 100644 --- a/src/google/protobuf/compiler/python/helpers.cc +++ b/src/google/protobuf/compiler/python/helpers.cc
@@ -32,9 +32,11 @@ #include <algorithm> -#include "google/protobuf/stubs/strutil.h" #include "absl/strings/escaping.h" +#include "absl/strings/match.h" +#include "absl/strings/str_replace.h" #include "absl/strings/str_split.h" +#include "absl/strings/strip.h" #include "google/protobuf/compiler/code_generator.h" #include "google/protobuf/descriptor.h" #include "google/protobuf/descriptor.pb.h" @@ -47,8 +49,7 @@ // Returns the Python module name expected for a given .proto filename. std::string ModuleName(const std::string& filename) { std::string basename = StripProto(filename); - ReplaceCharacters(&basename, "-", '_'); - ReplaceCharacters(&basename, "/", '.'); + absl::StrReplaceAll({{"-", "_"}, {"/", "."}}, &basename); return basename + "_pb2"; } @@ -94,7 +95,7 @@ const std::string& suffix) { std::string module_name = ModuleName(file_des->name()); std::string filename = module_name; - ReplaceCharacters(&filename, ".", '/'); + absl::StrReplaceAll({{".", "/"}}, &filename); filename += suffix; return filename; }
diff --git a/src/google/protobuf/compiler/python/helpers.h b/src/google/protobuf/compiler/python/helpers.h index 1fff3c9..3741fbb 100644 --- a/src/google/protobuf/compiler/python/helpers.h +++ b/src/google/protobuf/compiler/python/helpers.h
@@ -42,7 +42,6 @@ namespace compiler { namespace python { - std::string ModuleName(const std::string& filename); std::string StrippedModuleName(const std::string& filename); bool ContainsPythonKeyword(const std::string& module_name);
diff --git a/src/google/protobuf/compiler/python/pyi_generator.cc b/src/google/protobuf/compiler/python/pyi_generator.cc index 7c723ef..b09ceb2 100644 --- a/src/google/protobuf/compiler/python/pyi_generator.cc +++ b/src/google/protobuf/compiler/python/pyi_generator.cc
@@ -34,7 +34,7 @@ #include <utility> #include "absl/strings/ascii.h" -#include "google/protobuf/stubs/strutil.h" +#include "absl/strings/match.h" #include "absl/strings/str_split.h" #include "google/protobuf/compiler/python/helpers.h" #include "google/protobuf/descriptor.h" @@ -577,7 +577,7 @@ for (const std::pair<std::string, std::string>& option : options) { if (option.first == "annotate_code") { annotate_code = true; - } else if (HasSuffixString(option.first, ".pyi")) { + } else if (absl::EndsWith(option.first, ".pyi")) { filename = option.first; } else { *error = "Unknown generator option: " + option.first;
diff --git a/src/google/protobuf/descriptor.cc b/src/google/protobuf/descriptor.cc index 81412ff..9048cc6 100644 --- a/src/google/protobuf/descriptor.cc +++ b/src/google/protobuf/descriptor.cc
@@ -2506,12 +2506,7 @@ // CopyTo methods ==================================================== void FileDescriptor::CopyTo(FileDescriptorProto* proto) const { - proto->set_name(name()); - if (!package().empty()) proto->set_package(package()); - // TODO(liujisi): Also populate when syntax="proto2". - if (syntax() == SYNTAX_PROTO3 - ) proto->set_syntax(SyntaxName(syntax())); - + CopyHeadingTo(proto); for (int i = 0; i < dependency_count(); i++) { proto->add_dependency(dependency(i)->name()); @@ -2543,6 +2538,19 @@ } } +void FileDescriptor::CopyHeadingTo(FileDescriptorProto* proto) const { + proto->set_name(name()); + if (!package().empty()) { + proto->set_package(package()); + } + + // TODO(liujisi): Also populate when syntax="proto2". + if (syntax() == SYNTAX_PROTO3 + ) { + proto->set_syntax(SyntaxName(syntax())); + } +} + void FileDescriptor::CopyJsonNameTo(FileDescriptorProto* proto) const { if (message_type_count() != proto->message_type_size() || extension_count() != proto->extension_size()) { @@ -2901,7 +2909,7 @@ // the DebugString() output. std::string FormatComment(const std::string& comment_text) { std::string stripped_comment = comment_text; - StripWhitespace(&stripped_comment); + absl::StripAsciiWhitespace(&stripped_comment); std::vector<std::string> lines = absl::StrSplit(stripped_comment, "\n"); std::string output; for (const std::string& line : lines) { @@ -4206,7 +4214,7 @@ bool DescriptorBuilder::IsInPackage(const FileDescriptor* file, const std::string& package_name) { - return HasPrefixString(file->package(), package_name) && + return absl::StartsWith(file->package(), package_name) && (file->package().size() == package_name.size() || file->package()[package_name.size()] == '.'); }
diff --git a/src/google/protobuf/descriptor.h b/src/google/protobuf/descriptor.h index dfe8d42..5a8b5f3 100644 --- a/src/google/protobuf/descriptor.h +++ b/src/google/protobuf/descriptor.h
@@ -761,6 +761,10 @@ // Reflection::HasField() is semantically meaningful. bool has_presence() const; + // Returns true if this TYPE_STRING-typed field requires UTF-8 validation on + // parse. + bool requires_utf8_validation() const; + // Index of this field within the message's field array, or the file or // extension scope's extensions array. int index() const; @@ -1143,6 +1147,13 @@ // with AllowUnknownDependencies() set. bool is_placeholder() const; + // Returns true whether this is a "closed" enum, meaning that it: + // - Has a fixed set of named values. + // - Encountering values not in this set causes them to be treated as unknown + // fields. + // - The first value (i.e., the default) may be nonzero. + bool is_closed() const; + // Reserved fields ------------------------------------------------- // A range of reserved field numbers. @@ -1650,6 +1661,9 @@ // Fill the json_name field of FieldDescriptorProto for all fields. Can only // be called after CopyTo(). void CopyJsonNameTo(FileDescriptorProto* proto) const; + // Fills in the file-level settings of this file (e.g. syntax, package, + // file options) to `proto`. + void CopyHeadingTo(FileDescriptorProto* proto) const; // See Descriptor::DebugString(). std::string DebugString() const; @@ -2200,6 +2214,10 @@ const EnumDescriptor::ReservedRange*) PROTOBUF_DEFINE_ACCESSOR(EnumDescriptor, reserved_name_count, int) +inline bool EnumDescriptor::is_closed() const { + return file()->syntax() != FileDescriptor::SYNTAX_PROTO3; +} + PROTOBUF_DEFINE_NAME_ACCESSOR(EnumValueDescriptor) PROTOBUF_DEFINE_ACCESSOR(EnumValueDescriptor, number, int) PROTOBUF_DEFINE_ACCESSOR(EnumValueDescriptor, type, const EnumDescriptor*) @@ -2364,6 +2382,11 @@ file()->syntax() == FileDescriptor::SYNTAX_PROTO2; } +inline bool FieldDescriptor::requires_utf8_validation() const { + return type() == TYPE_STRING && + file()->syntax() == FileDescriptor::SYNTAX_PROTO3; +} + // To save space, index() is computed by looking at the descriptor's position // in the parent's array of children. inline int FieldDescriptor::index() const {
diff --git a/src/google/protobuf/descriptor.pb.cc b/src/google/protobuf/descriptor.pb.cc index b8a24a9..7d17e6b 100644 --- a/src/google/protobuf/descriptor.pb.cc +++ b/src/google/protobuf/descriptor.pb.cc
@@ -1,10 +1,9 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/protobuf/descriptor.proto -#include <google/protobuf/descriptor.pb.h> +#include "google/protobuf/descriptor.pb.h" #include <algorithm> - #include "google/protobuf/io/coded_stream.h" #include "google/protobuf/extension_set.h" #include "google/protobuf/wire_format_lite.h" @@ -13,27 +12,27 @@ #include "google/protobuf/reflection_ops.h" #include "google/protobuf/wire_format.h" // @@protoc_insertion_point(includes) + +// Must be included last. #include "google/protobuf/port_def.inc" - PROTOBUF_PRAGMA_INIT_SEG - namespace _pb = ::PROTOBUF_NAMESPACE_ID; -namespace _pbi = _pb::internal; - +namespace _pbi = ::PROTOBUF_NAMESPACE_ID::internal; PROTOBUF_NAMESPACE_OPEN PROTOBUF_CONSTEXPR FileDescriptorSet::FileDescriptorSet( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_.file_)*/{} , /*decltype(_impl_._cached_size_)*/{}} {} struct FileDescriptorSetDefaultTypeInternal { - PROTOBUF_CONSTEXPR FileDescriptorSetDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR FileDescriptorSetDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~FileDescriptorSetDefaultTypeInternal() {} union { FileDescriptorSet _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FileDescriptorSetDefaultTypeInternal _FileDescriptorSet_default_instance_; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FileDescriptorSetDefaultTypeInternal _FileDescriptorSet_default_instance_; PROTOBUF_CONSTEXPR FileDescriptorProto::FileDescriptorProto( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_._has_bits_)*/{} @@ -52,14 +51,15 @@ , /*decltype(_impl_.options_)*/nullptr , /*decltype(_impl_.source_code_info_)*/nullptr} {} struct FileDescriptorProtoDefaultTypeInternal { - PROTOBUF_CONSTEXPR FileDescriptorProtoDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR FileDescriptorProtoDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~FileDescriptorProtoDefaultTypeInternal() {} union { FileDescriptorProto _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FileDescriptorProtoDefaultTypeInternal _FileDescriptorProto_default_instance_; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FileDescriptorProtoDefaultTypeInternal _FileDescriptorProto_default_instance_; PROTOBUF_CONSTEXPR DescriptorProto_ExtensionRange::DescriptorProto_ExtensionRange( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_._has_bits_)*/{} @@ -68,14 +68,15 @@ , /*decltype(_impl_.start_)*/0 , /*decltype(_impl_.end_)*/0} {} struct DescriptorProto_ExtensionRangeDefaultTypeInternal { - PROTOBUF_CONSTEXPR DescriptorProto_ExtensionRangeDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR DescriptorProto_ExtensionRangeDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~DescriptorProto_ExtensionRangeDefaultTypeInternal() {} union { DescriptorProto_ExtensionRange _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 DescriptorProto_ExtensionRangeDefaultTypeInternal _DescriptorProto_ExtensionRange_default_instance_; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 DescriptorProto_ExtensionRangeDefaultTypeInternal _DescriptorProto_ExtensionRange_default_instance_; PROTOBUF_CONSTEXPR DescriptorProto_ReservedRange::DescriptorProto_ReservedRange( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_._has_bits_)*/{} @@ -83,14 +84,15 @@ , /*decltype(_impl_.start_)*/0 , /*decltype(_impl_.end_)*/0} {} struct DescriptorProto_ReservedRangeDefaultTypeInternal { - PROTOBUF_CONSTEXPR DescriptorProto_ReservedRangeDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR DescriptorProto_ReservedRangeDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~DescriptorProto_ReservedRangeDefaultTypeInternal() {} union { DescriptorProto_ReservedRange _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 DescriptorProto_ReservedRangeDefaultTypeInternal _DescriptorProto_ReservedRange_default_instance_; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 DescriptorProto_ReservedRangeDefaultTypeInternal _DescriptorProto_ReservedRange_default_instance_; PROTOBUF_CONSTEXPR DescriptorProto::DescriptorProto( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_._has_bits_)*/{} @@ -106,28 +108,30 @@ , /*decltype(_impl_.name_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} , /*decltype(_impl_.options_)*/nullptr} {} struct DescriptorProtoDefaultTypeInternal { - PROTOBUF_CONSTEXPR DescriptorProtoDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR DescriptorProtoDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~DescriptorProtoDefaultTypeInternal() {} union { DescriptorProto _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 DescriptorProtoDefaultTypeInternal _DescriptorProto_default_instance_; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 DescriptorProtoDefaultTypeInternal _DescriptorProto_default_instance_; PROTOBUF_CONSTEXPR ExtensionRangeOptions::ExtensionRangeOptions( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_._extensions_)*/{} , /*decltype(_impl_.uninterpreted_option_)*/{} , /*decltype(_impl_._cached_size_)*/{}} {} struct ExtensionRangeOptionsDefaultTypeInternal { - PROTOBUF_CONSTEXPR ExtensionRangeOptionsDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR ExtensionRangeOptionsDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~ExtensionRangeOptionsDefaultTypeInternal() {} union { ExtensionRangeOptions _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ExtensionRangeOptionsDefaultTypeInternal _ExtensionRangeOptions_default_instance_; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ExtensionRangeOptionsDefaultTypeInternal _ExtensionRangeOptions_default_instance_; PROTOBUF_CONSTEXPR FieldDescriptorProto::FieldDescriptorProto( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_._has_bits_)*/{} @@ -144,14 +148,15 @@ , /*decltype(_impl_.label_)*/1 , /*decltype(_impl_.type_)*/1} {} struct FieldDescriptorProtoDefaultTypeInternal { - PROTOBUF_CONSTEXPR FieldDescriptorProtoDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR FieldDescriptorProtoDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~FieldDescriptorProtoDefaultTypeInternal() {} union { FieldDescriptorProto _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FieldDescriptorProtoDefaultTypeInternal _FieldDescriptorProto_default_instance_; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FieldDescriptorProtoDefaultTypeInternal _FieldDescriptorProto_default_instance_; PROTOBUF_CONSTEXPR OneofDescriptorProto::OneofDescriptorProto( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_._has_bits_)*/{} @@ -159,14 +164,15 @@ , /*decltype(_impl_.name_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} , /*decltype(_impl_.options_)*/nullptr} {} struct OneofDescriptorProtoDefaultTypeInternal { - PROTOBUF_CONSTEXPR OneofDescriptorProtoDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR OneofDescriptorProtoDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~OneofDescriptorProtoDefaultTypeInternal() {} union { OneofDescriptorProto _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 OneofDescriptorProtoDefaultTypeInternal _OneofDescriptorProto_default_instance_; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 OneofDescriptorProtoDefaultTypeInternal _OneofDescriptorProto_default_instance_; PROTOBUF_CONSTEXPR EnumDescriptorProto_EnumReservedRange::EnumDescriptorProto_EnumReservedRange( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_._has_bits_)*/{} @@ -174,14 +180,15 @@ , /*decltype(_impl_.start_)*/0 , /*decltype(_impl_.end_)*/0} {} struct EnumDescriptorProto_EnumReservedRangeDefaultTypeInternal { - PROTOBUF_CONSTEXPR EnumDescriptorProto_EnumReservedRangeDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR EnumDescriptorProto_EnumReservedRangeDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~EnumDescriptorProto_EnumReservedRangeDefaultTypeInternal() {} union { EnumDescriptorProto_EnumReservedRange _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 EnumDescriptorProto_EnumReservedRangeDefaultTypeInternal _EnumDescriptorProto_EnumReservedRange_default_instance_; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 EnumDescriptorProto_EnumReservedRangeDefaultTypeInternal _EnumDescriptorProto_EnumReservedRange_default_instance_; PROTOBUF_CONSTEXPR EnumDescriptorProto::EnumDescriptorProto( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_._has_bits_)*/{} @@ -192,14 +199,15 @@ , /*decltype(_impl_.name_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} , /*decltype(_impl_.options_)*/nullptr} {} struct EnumDescriptorProtoDefaultTypeInternal { - PROTOBUF_CONSTEXPR EnumDescriptorProtoDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR EnumDescriptorProtoDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~EnumDescriptorProtoDefaultTypeInternal() {} union { EnumDescriptorProto _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 EnumDescriptorProtoDefaultTypeInternal _EnumDescriptorProto_default_instance_; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 EnumDescriptorProtoDefaultTypeInternal _EnumDescriptorProto_default_instance_; PROTOBUF_CONSTEXPR EnumValueDescriptorProto::EnumValueDescriptorProto( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_._has_bits_)*/{} @@ -208,14 +216,15 @@ , /*decltype(_impl_.options_)*/nullptr , /*decltype(_impl_.number_)*/0} {} struct EnumValueDescriptorProtoDefaultTypeInternal { - PROTOBUF_CONSTEXPR EnumValueDescriptorProtoDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR EnumValueDescriptorProtoDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~EnumValueDescriptorProtoDefaultTypeInternal() {} union { EnumValueDescriptorProto _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 EnumValueDescriptorProtoDefaultTypeInternal _EnumValueDescriptorProto_default_instance_; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 EnumValueDescriptorProtoDefaultTypeInternal _EnumValueDescriptorProto_default_instance_; PROTOBUF_CONSTEXPR ServiceDescriptorProto::ServiceDescriptorProto( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_._has_bits_)*/{} @@ -224,14 +233,15 @@ , /*decltype(_impl_.name_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} , /*decltype(_impl_.options_)*/nullptr} {} struct ServiceDescriptorProtoDefaultTypeInternal { - PROTOBUF_CONSTEXPR ServiceDescriptorProtoDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR ServiceDescriptorProtoDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~ServiceDescriptorProtoDefaultTypeInternal() {} union { ServiceDescriptorProto _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ServiceDescriptorProtoDefaultTypeInternal _ServiceDescriptorProto_default_instance_; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ServiceDescriptorProtoDefaultTypeInternal _ServiceDescriptorProto_default_instance_; PROTOBUF_CONSTEXPR MethodDescriptorProto::MethodDescriptorProto( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_._has_bits_)*/{} @@ -243,14 +253,15 @@ , /*decltype(_impl_.client_streaming_)*/false , /*decltype(_impl_.server_streaming_)*/false} {} struct MethodDescriptorProtoDefaultTypeInternal { - PROTOBUF_CONSTEXPR MethodDescriptorProtoDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR MethodDescriptorProtoDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~MethodDescriptorProtoDefaultTypeInternal() {} union { MethodDescriptorProto _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 MethodDescriptorProtoDefaultTypeInternal _MethodDescriptorProto_default_instance_; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 MethodDescriptorProtoDefaultTypeInternal _MethodDescriptorProto_default_instance_; PROTOBUF_CONSTEXPR FileOptions::FileOptions( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_._extensions_)*/{} @@ -278,14 +289,15 @@ , /*decltype(_impl_.optimize_for_)*/1 , /*decltype(_impl_.cc_enable_arenas_)*/true} {} struct FileOptionsDefaultTypeInternal { - PROTOBUF_CONSTEXPR FileOptionsDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR FileOptionsDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~FileOptionsDefaultTypeInternal() {} union { FileOptions _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FileOptionsDefaultTypeInternal _FileOptions_default_instance_; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FileOptionsDefaultTypeInternal _FileOptions_default_instance_; PROTOBUF_CONSTEXPR MessageOptions::MessageOptions( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_._extensions_)*/{} @@ -297,14 +309,15 @@ , /*decltype(_impl_.deprecated_)*/false , /*decltype(_impl_.map_entry_)*/false} {} struct MessageOptionsDefaultTypeInternal { - PROTOBUF_CONSTEXPR MessageOptionsDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR MessageOptionsDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~MessageOptionsDefaultTypeInternal() {} union { MessageOptions _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 MessageOptionsDefaultTypeInternal _MessageOptions_default_instance_; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 MessageOptionsDefaultTypeInternal _MessageOptions_default_instance_; PROTOBUF_CONSTEXPR FieldOptions::FieldOptions( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_._extensions_)*/{} @@ -319,28 +332,30 @@ , /*decltype(_impl_.deprecated_)*/false , /*decltype(_impl_.weak_)*/false} {} struct FieldOptionsDefaultTypeInternal { - PROTOBUF_CONSTEXPR FieldOptionsDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR FieldOptionsDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~FieldOptionsDefaultTypeInternal() {} union { FieldOptions _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FieldOptionsDefaultTypeInternal _FieldOptions_default_instance_; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 FieldOptionsDefaultTypeInternal _FieldOptions_default_instance_; PROTOBUF_CONSTEXPR OneofOptions::OneofOptions( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_._extensions_)*/{} , /*decltype(_impl_.uninterpreted_option_)*/{} , /*decltype(_impl_._cached_size_)*/{}} {} struct OneofOptionsDefaultTypeInternal { - PROTOBUF_CONSTEXPR OneofOptionsDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR OneofOptionsDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~OneofOptionsDefaultTypeInternal() {} union { OneofOptions _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 OneofOptionsDefaultTypeInternal _OneofOptions_default_instance_; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 OneofOptionsDefaultTypeInternal _OneofOptions_default_instance_; PROTOBUF_CONSTEXPR EnumOptions::EnumOptions( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_._extensions_)*/{} @@ -350,14 +365,15 @@ , /*decltype(_impl_.allow_alias_)*/false , /*decltype(_impl_.deprecated_)*/false} {} struct EnumOptionsDefaultTypeInternal { - PROTOBUF_CONSTEXPR EnumOptionsDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR EnumOptionsDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~EnumOptionsDefaultTypeInternal() {} union { EnumOptions _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 EnumOptionsDefaultTypeInternal _EnumOptions_default_instance_; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 EnumOptionsDefaultTypeInternal _EnumOptions_default_instance_; PROTOBUF_CONSTEXPR EnumValueOptions::EnumValueOptions( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_._extensions_)*/{} @@ -366,14 +382,15 @@ , /*decltype(_impl_.uninterpreted_option_)*/{} , /*decltype(_impl_.deprecated_)*/false} {} struct EnumValueOptionsDefaultTypeInternal { - PROTOBUF_CONSTEXPR EnumValueOptionsDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR EnumValueOptionsDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~EnumValueOptionsDefaultTypeInternal() {} union { EnumValueOptions _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 EnumValueOptionsDefaultTypeInternal _EnumValueOptions_default_instance_; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 EnumValueOptionsDefaultTypeInternal _EnumValueOptions_default_instance_; PROTOBUF_CONSTEXPR ServiceOptions::ServiceOptions( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_._extensions_)*/{} @@ -382,14 +399,15 @@ , /*decltype(_impl_.uninterpreted_option_)*/{} , /*decltype(_impl_.deprecated_)*/false} {} struct ServiceOptionsDefaultTypeInternal { - PROTOBUF_CONSTEXPR ServiceOptionsDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR ServiceOptionsDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~ServiceOptionsDefaultTypeInternal() {} union { ServiceOptions _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ServiceOptionsDefaultTypeInternal _ServiceOptions_default_instance_; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 ServiceOptionsDefaultTypeInternal _ServiceOptions_default_instance_; PROTOBUF_CONSTEXPR MethodOptions::MethodOptions( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_._extensions_)*/{} @@ -399,14 +417,15 @@ , /*decltype(_impl_.deprecated_)*/false , /*decltype(_impl_.idempotency_level_)*/0} {} struct MethodOptionsDefaultTypeInternal { - PROTOBUF_CONSTEXPR MethodOptionsDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR MethodOptionsDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~MethodOptionsDefaultTypeInternal() {} union { MethodOptions _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 MethodOptionsDefaultTypeInternal _MethodOptions_default_instance_; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 MethodOptionsDefaultTypeInternal _MethodOptions_default_instance_; PROTOBUF_CONSTEXPR UninterpretedOption_NamePart::UninterpretedOption_NamePart( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_._has_bits_)*/{} @@ -414,14 +433,15 @@ , /*decltype(_impl_.name_part_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} , /*decltype(_impl_.is_extension_)*/false} {} struct UninterpretedOption_NamePartDefaultTypeInternal { - PROTOBUF_CONSTEXPR UninterpretedOption_NamePartDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR UninterpretedOption_NamePartDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~UninterpretedOption_NamePartDefaultTypeInternal() {} union { UninterpretedOption_NamePart _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 UninterpretedOption_NamePartDefaultTypeInternal _UninterpretedOption_NamePart_default_instance_; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 UninterpretedOption_NamePartDefaultTypeInternal _UninterpretedOption_NamePart_default_instance_; PROTOBUF_CONSTEXPR UninterpretedOption::UninterpretedOption( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_._has_bits_)*/{} @@ -434,14 +454,15 @@ , /*decltype(_impl_.negative_int_value_)*/int64_t{0} , /*decltype(_impl_.double_value_)*/0} {} struct UninterpretedOptionDefaultTypeInternal { - PROTOBUF_CONSTEXPR UninterpretedOptionDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR UninterpretedOptionDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~UninterpretedOptionDefaultTypeInternal() {} union { UninterpretedOption _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 UninterpretedOptionDefaultTypeInternal _UninterpretedOption_default_instance_; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 UninterpretedOptionDefaultTypeInternal _UninterpretedOption_default_instance_; PROTOBUF_CONSTEXPR SourceCodeInfo_Location::SourceCodeInfo_Location( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_._has_bits_)*/{} @@ -454,27 +475,29 @@ , /*decltype(_impl_.leading_comments_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} , /*decltype(_impl_.trailing_comments_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}} {} struct SourceCodeInfo_LocationDefaultTypeInternal { - PROTOBUF_CONSTEXPR SourceCodeInfo_LocationDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR SourceCodeInfo_LocationDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~SourceCodeInfo_LocationDefaultTypeInternal() {} union { SourceCodeInfo_Location _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 SourceCodeInfo_LocationDefaultTypeInternal _SourceCodeInfo_Location_default_instance_; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 SourceCodeInfo_LocationDefaultTypeInternal _SourceCodeInfo_Location_default_instance_; PROTOBUF_CONSTEXPR SourceCodeInfo::SourceCodeInfo( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_.location_)*/{} , /*decltype(_impl_._cached_size_)*/{}} {} struct SourceCodeInfoDefaultTypeInternal { - PROTOBUF_CONSTEXPR SourceCodeInfoDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR SourceCodeInfoDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~SourceCodeInfoDefaultTypeInternal() {} union { SourceCodeInfo _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 SourceCodeInfoDefaultTypeInternal _SourceCodeInfo_default_instance_; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 SourceCodeInfoDefaultTypeInternal _SourceCodeInfo_default_instance_; PROTOBUF_CONSTEXPR GeneratedCodeInfo_Annotation::GeneratedCodeInfo_Annotation( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_._has_bits_)*/{} @@ -486,734 +509,759 @@ , /*decltype(_impl_.end_)*/0 , /*decltype(_impl_.semantic_)*/0} {} struct GeneratedCodeInfo_AnnotationDefaultTypeInternal { - PROTOBUF_CONSTEXPR GeneratedCodeInfo_AnnotationDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR GeneratedCodeInfo_AnnotationDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~GeneratedCodeInfo_AnnotationDefaultTypeInternal() {} union { GeneratedCodeInfo_Annotation _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 GeneratedCodeInfo_AnnotationDefaultTypeInternal _GeneratedCodeInfo_Annotation_default_instance_; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 GeneratedCodeInfo_AnnotationDefaultTypeInternal _GeneratedCodeInfo_Annotation_default_instance_; PROTOBUF_CONSTEXPR GeneratedCodeInfo::GeneratedCodeInfo( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_.annotation_)*/{} , /*decltype(_impl_._cached_size_)*/{}} {} struct GeneratedCodeInfoDefaultTypeInternal { - PROTOBUF_CONSTEXPR GeneratedCodeInfoDefaultTypeInternal() - : _instance(::_pbi::ConstantInitialized{}) {} + PROTOBUF_CONSTEXPR GeneratedCodeInfoDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} ~GeneratedCodeInfoDefaultTypeInternal() {} union { GeneratedCodeInfo _instance; }; }; -PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 GeneratedCodeInfoDefaultTypeInternal _GeneratedCodeInfo_default_instance_; + +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT + PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 GeneratedCodeInfoDefaultTypeInternal _GeneratedCodeInfo_default_instance_; PROTOBUF_NAMESPACE_CLOSE static ::_pb::Metadata file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[27]; static const ::_pb::EnumDescriptor* file_level_enum_descriptors_google_2fprotobuf_2fdescriptor_2eproto[7]; -static constexpr ::_pb::ServiceDescriptor const** file_level_service_descriptors_google_2fprotobuf_2fdescriptor_2eproto = nullptr; - -const uint32_t TableStruct_google_2fprotobuf_2fdescriptor_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { - ~0u, // no _has_bits_ - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorSet, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorSet, _impl_.file_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.name_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.package_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.dependency_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.public_dependency_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.weak_dependency_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.message_type_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.enum_type_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.service_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.extension_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.options_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.source_code_info_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.syntax_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.edition_), - 0, - 1, - ~0u, - ~0u, - ~0u, - ~0u, - ~0u, - ~0u, - ~0u, - 4, - 5, - 2, - 3, - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange, _impl_.start_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange, _impl_.end_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange, _impl_.options_), - 1, - 2, - 0, - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange, _impl_.start_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange, _impl_.end_), - 0, - 1, - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.name_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.field_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.extension_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.nested_type_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.enum_type_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.extension_range_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.oneof_decl_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.options_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.reserved_range_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.reserved_name_), - 0, - ~0u, - ~0u, - ~0u, - ~0u, - ~0u, - ~0u, - 1, - ~0u, - ~0u, - ~0u, // no _has_bits_ - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions, _internal_metadata_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions, _impl_._extensions_), - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions, _impl_.uninterpreted_option_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.name_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.number_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.label_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.type_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.type_name_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.extendee_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.default_value_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.oneof_index_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.json_name_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.options_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.proto3_optional_), - 0, - 6, - 9, - 10, - 2, - 1, - 3, - 7, - 4, - 5, - 8, - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto, _impl_.name_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto, _impl_.options_), - 0, - 1, - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange, _impl_.start_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange, _impl_.end_), - 0, - 1, - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto, _impl_.name_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto, _impl_.value_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto, _impl_.options_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto, _impl_.reserved_range_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto, _impl_.reserved_name_), - 0, - ~0u, - 1, - ~0u, - ~0u, - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto, _impl_.name_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto, _impl_.number_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto, _impl_.options_), - 0, - 2, - 1, - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto, _impl_.name_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto, _impl_.method_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto, _impl_.options_), - 0, - ~0u, - 1, - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto, _impl_.name_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto, _impl_.input_type_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto, _impl_.output_type_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto, _impl_.options_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto, _impl_.client_streaming_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto, _impl_.server_streaming_), - 0, - 1, - 2, - 3, - 4, - 5, - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _internal_metadata_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_._extensions_), - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.java_package_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.java_outer_classname_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.java_multiple_files_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.java_generate_equals_and_hash_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.java_string_check_utf8_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.optimize_for_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.go_package_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.cc_generic_services_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.java_generic_services_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.py_generic_services_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.php_generic_services_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.deprecated_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.cc_enable_arenas_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.objc_class_prefix_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.csharp_namespace_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.swift_prefix_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.php_class_prefix_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.php_namespace_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.php_metadata_namespace_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.ruby_package_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.uninterpreted_option_), - 0, - 1, - 10, - 11, - 12, - 18, - 2, - 13, - 14, - 15, - 16, - 17, - 19, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - ~0u, - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MessageOptions, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MessageOptions, _internal_metadata_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MessageOptions, _impl_._extensions_), - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MessageOptions, _impl_.message_set_wire_format_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MessageOptions, _impl_.no_standard_descriptor_accessor_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MessageOptions, _impl_.deprecated_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MessageOptions, _impl_.map_entry_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MessageOptions, _impl_.uninterpreted_option_), - 0, - 1, - 2, - 3, - ~0u, - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _internal_metadata_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_._extensions_), - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_.ctype_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_.packed_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_.jstype_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_.lazy_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_.unverified_lazy_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_.deprecated_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_.weak_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_.uninterpreted_option_), - 0, - 2, - 1, - 3, - 4, - 5, - 6, - ~0u, - ~0u, // no _has_bits_ - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::OneofOptions, _internal_metadata_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::OneofOptions, _impl_._extensions_), - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::OneofOptions, _impl_.uninterpreted_option_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumOptions, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumOptions, _internal_metadata_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumOptions, _impl_._extensions_), - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumOptions, _impl_.allow_alias_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumOptions, _impl_.deprecated_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumOptions, _impl_.uninterpreted_option_), - 0, - 1, - ~0u, - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueOptions, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueOptions, _internal_metadata_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueOptions, _impl_._extensions_), - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueOptions, _impl_.deprecated_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueOptions, _impl_.uninterpreted_option_), - 0, - ~0u, - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceOptions, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceOptions, _internal_metadata_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceOptions, _impl_._extensions_), - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceOptions, _impl_.deprecated_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceOptions, _impl_.uninterpreted_option_), - 0, - ~0u, - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodOptions, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodOptions, _internal_metadata_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodOptions, _impl_._extensions_), - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodOptions, _impl_.deprecated_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodOptions, _impl_.idempotency_level_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodOptions, _impl_.uninterpreted_option_), - 0, - 1, - ~0u, - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart, _impl_.name_part_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart, _impl_.is_extension_), - 0, - 1, - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, _impl_.name_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, _impl_.identifier_value_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, _impl_.positive_int_value_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, _impl_.negative_int_value_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, _impl_.double_value_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, _impl_.string_value_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, _impl_.aggregate_value_), - ~0u, - 0, - 3, - 4, - 5, - 1, - 2, - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location, _impl_.path_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location, _impl_.span_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location, _impl_.leading_comments_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location, _impl_.trailing_comments_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location, _impl_.leading_detached_comments_), - ~0u, - ~0u, - 0, - 1, - ~0u, - ~0u, // no _has_bits_ - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo, _impl_.location_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation, _impl_._has_bits_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation, _impl_.path_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation, _impl_.source_file_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation, _impl_.begin_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation, _impl_.end_), - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation, _impl_.semantic_), - ~0u, - 0, - 1, - 2, - 3, - ~0u, // no _has_bits_ - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo, _internal_metadata_), - ~0u, // no _extensions_ - ~0u, // no _oneof_case_ - ~0u, // no _weak_field_map_ - ~0u, // no _inlined_string_donated_ - ~0u, // no _split_ - ~0u, // no sizeof(Split) - PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo, _impl_.annotation_), +static constexpr const ::_pb::ServiceDescriptor** + file_level_service_descriptors_google_2fprotobuf_2fdescriptor_2eproto = nullptr; +const uint32_t TableStruct_google_2fprotobuf_2fdescriptor_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE( + protodesc_cold) = { + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorSet, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorSet, _impl_.file_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.name_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.package_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.dependency_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.public_dependency_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.weak_dependency_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.message_type_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.enum_type_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.service_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.extension_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.options_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.source_code_info_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.syntax_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto, _impl_.edition_), + 0, + 1, + ~0u, + ~0u, + ~0u, + ~0u, + ~0u, + ~0u, + ~0u, + 4, + 5, + 2, + 3, + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange, _impl_.start_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange, _impl_.end_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange, _impl_.options_), + 1, + 2, + 0, + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange, _impl_.start_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange, _impl_.end_), + 0, + 1, + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.name_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.field_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.extension_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.nested_type_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.enum_type_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.extension_range_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.oneof_decl_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.options_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.reserved_range_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::DescriptorProto, _impl_.reserved_name_), + 0, + ~0u, + ~0u, + ~0u, + ~0u, + ~0u, + ~0u, + 1, + ~0u, + ~0u, + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions, _internal_metadata_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions, _impl_._extensions_), + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions, _impl_.uninterpreted_option_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.name_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.number_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.label_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.type_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.type_name_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.extendee_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.default_value_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.oneof_index_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.json_name_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.options_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto, _impl_.proto3_optional_), + 0, + 6, + 9, + 10, + 2, + 1, + 3, + 7, + 4, + 5, + 8, + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto, _impl_.name_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto, _impl_.options_), + 0, + 1, + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange, _impl_.start_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange, _impl_.end_), + 0, + 1, + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto, _impl_.name_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto, _impl_.value_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto, _impl_.options_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto, _impl_.reserved_range_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto, _impl_.reserved_name_), + 0, + ~0u, + 1, + ~0u, + ~0u, + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto, _impl_.name_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto, _impl_.number_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto, _impl_.options_), + 0, + 2, + 1, + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto, _impl_.name_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto, _impl_.method_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto, _impl_.options_), + 0, + ~0u, + 1, + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto, _impl_.name_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto, _impl_.input_type_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto, _impl_.output_type_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto, _impl_.options_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto, _impl_.client_streaming_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto, _impl_.server_streaming_), + 0, + 1, + 2, + 3, + 4, + 5, + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _internal_metadata_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_._extensions_), + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.java_package_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.java_outer_classname_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.java_multiple_files_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.java_generate_equals_and_hash_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.java_string_check_utf8_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.optimize_for_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.go_package_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.cc_generic_services_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.java_generic_services_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.py_generic_services_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.php_generic_services_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.deprecated_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.cc_enable_arenas_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.objc_class_prefix_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.csharp_namespace_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.swift_prefix_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.php_class_prefix_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.php_namespace_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.php_metadata_namespace_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.ruby_package_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FileOptions, _impl_.uninterpreted_option_), + 0, + 1, + 10, + 11, + 12, + 18, + 2, + 13, + 14, + 15, + 16, + 17, + 19, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + ~0u, + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MessageOptions, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MessageOptions, _internal_metadata_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MessageOptions, _impl_._extensions_), + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MessageOptions, _impl_.message_set_wire_format_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MessageOptions, _impl_.no_standard_descriptor_accessor_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MessageOptions, _impl_.deprecated_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MessageOptions, _impl_.map_entry_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MessageOptions, _impl_.uninterpreted_option_), + 0, + 1, + 2, + 3, + ~0u, + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _internal_metadata_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_._extensions_), + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_.ctype_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_.packed_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_.jstype_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_.lazy_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_.unverified_lazy_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_.deprecated_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_.weak_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::FieldOptions, _impl_.uninterpreted_option_), + 0, + 2, + 1, + 3, + 4, + 5, + 6, + ~0u, + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::OneofOptions, _internal_metadata_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::OneofOptions, _impl_._extensions_), + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::OneofOptions, _impl_.uninterpreted_option_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumOptions, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumOptions, _internal_metadata_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumOptions, _impl_._extensions_), + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumOptions, _impl_.allow_alias_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumOptions, _impl_.deprecated_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumOptions, _impl_.uninterpreted_option_), + 0, + 1, + ~0u, + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueOptions, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueOptions, _internal_metadata_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueOptions, _impl_._extensions_), + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueOptions, _impl_.deprecated_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::EnumValueOptions, _impl_.uninterpreted_option_), + 0, + ~0u, + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceOptions, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceOptions, _internal_metadata_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceOptions, _impl_._extensions_), + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceOptions, _impl_.deprecated_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::ServiceOptions, _impl_.uninterpreted_option_), + 0, + ~0u, + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodOptions, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodOptions, _internal_metadata_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodOptions, _impl_._extensions_), + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodOptions, _impl_.deprecated_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodOptions, _impl_.idempotency_level_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::MethodOptions, _impl_.uninterpreted_option_), + 0, + 1, + ~0u, + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart, _impl_.name_part_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart, _impl_.is_extension_), + 0, + 1, + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, _impl_.name_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, _impl_.identifier_value_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, _impl_.positive_int_value_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, _impl_.negative_int_value_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, _impl_.double_value_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, _impl_.string_value_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::UninterpretedOption, _impl_.aggregate_value_), + ~0u, + 0, + 3, + 4, + 5, + 1, + 2, + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location, _impl_.path_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location, _impl_.span_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location, _impl_.leading_comments_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location, _impl_.trailing_comments_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location, _impl_.leading_detached_comments_), + ~0u, + ~0u, + 0, + 1, + ~0u, + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo, _impl_.location_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation, _impl_._has_bits_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation, _impl_.path_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation, _impl_.source_file_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation, _impl_.begin_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation, _impl_.end_), + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation, _impl_.semantic_), + ~0u, + 0, + 1, + 2, + 3, + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + ~0u, // no _split_ + ~0u, // no sizeof(Split) + PROTOBUF_FIELD_OFFSET(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo, _impl_.annotation_), }; -static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { - { 0, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::FileDescriptorSet)}, - { 9, 30, -1, sizeof(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto)}, - { 43, 54, -1, sizeof(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange)}, - { 57, 67, -1, sizeof(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange)}, - { 69, 87, -1, sizeof(::PROTOBUF_NAMESPACE_ID::DescriptorProto)}, - { 97, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions)}, - { 106, 125, -1, sizeof(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto)}, - { 136, 146, -1, sizeof(::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto)}, - { 148, 158, -1, sizeof(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange)}, - { 160, 173, -1, sizeof(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto)}, - { 178, 189, -1, sizeof(::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto)}, - { 192, 203, -1, sizeof(::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto)}, - { 206, 220, -1, sizeof(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto)}, - { 226, 255, -1, sizeof(::PROTOBUF_NAMESPACE_ID::FileOptions)}, - { 276, 289, -1, sizeof(::PROTOBUF_NAMESPACE_ID::MessageOptions)}, - { 294, 310, -1, sizeof(::PROTOBUF_NAMESPACE_ID::FieldOptions)}, - { 318, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::OneofOptions)}, - { 327, 338, -1, sizeof(::PROTOBUF_NAMESPACE_ID::EnumOptions)}, - { 341, 351, -1, sizeof(::PROTOBUF_NAMESPACE_ID::EnumValueOptions)}, - { 353, 363, -1, sizeof(::PROTOBUF_NAMESPACE_ID::ServiceOptions)}, - { 365, 376, -1, sizeof(::PROTOBUF_NAMESPACE_ID::MethodOptions)}, - { 379, 389, -1, sizeof(::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart)}, - { 391, 406, -1, sizeof(::PROTOBUF_NAMESPACE_ID::UninterpretedOption)}, - { 413, 426, -1, sizeof(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location)}, - { 431, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo)}, - { 440, 453, -1, sizeof(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation)}, - { 458, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo)}, + +static const ::_pbi::MigrationSchema + schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + { 0, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::FileDescriptorSet)}, + { 9, 30, -1, sizeof(::PROTOBUF_NAMESPACE_ID::FileDescriptorProto)}, + { 43, 54, -1, sizeof(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange)}, + { 57, 67, -1, sizeof(::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange)}, + { 69, 87, -1, sizeof(::PROTOBUF_NAMESPACE_ID::DescriptorProto)}, + { 97, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions)}, + { 106, 125, -1, sizeof(::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto)}, + { 136, 146, -1, sizeof(::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto)}, + { 148, 158, -1, sizeof(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange)}, + { 160, 173, -1, sizeof(::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto)}, + { 178, 189, -1, sizeof(::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto)}, + { 192, 203, -1, sizeof(::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto)}, + { 206, 220, -1, sizeof(::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto)}, + { 226, 255, -1, sizeof(::PROTOBUF_NAMESPACE_ID::FileOptions)}, + { 276, 289, -1, sizeof(::PROTOBUF_NAMESPACE_ID::MessageOptions)}, + { 294, 310, -1, sizeof(::PROTOBUF_NAMESPACE_ID::FieldOptions)}, + { 318, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::OneofOptions)}, + { 327, 338, -1, sizeof(::PROTOBUF_NAMESPACE_ID::EnumOptions)}, + { 341, 351, -1, sizeof(::PROTOBUF_NAMESPACE_ID::EnumValueOptions)}, + { 353, 363, -1, sizeof(::PROTOBUF_NAMESPACE_ID::ServiceOptions)}, + { 365, 376, -1, sizeof(::PROTOBUF_NAMESPACE_ID::MethodOptions)}, + { 379, 389, -1, sizeof(::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart)}, + { 391, 406, -1, sizeof(::PROTOBUF_NAMESPACE_ID::UninterpretedOption)}, + { 413, 426, -1, sizeof(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location)}, + { 431, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::SourceCodeInfo)}, + { 440, 453, -1, sizeof(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation)}, + { 458, -1, -1, sizeof(::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo)}, }; static const ::_pb::Message* const file_default_instances[] = { - &::PROTOBUF_NAMESPACE_ID::_FileDescriptorSet_default_instance_._instance, - &::PROTOBUF_NAMESPACE_ID::_FileDescriptorProto_default_instance_._instance, - &::PROTOBUF_NAMESPACE_ID::_DescriptorProto_ExtensionRange_default_instance_._instance, - &::PROTOBUF_NAMESPACE_ID::_DescriptorProto_ReservedRange_default_instance_._instance, - &::PROTOBUF_NAMESPACE_ID::_DescriptorProto_default_instance_._instance, - &::PROTOBUF_NAMESPACE_ID::_ExtensionRangeOptions_default_instance_._instance, - &::PROTOBUF_NAMESPACE_ID::_FieldDescriptorProto_default_instance_._instance, - &::PROTOBUF_NAMESPACE_ID::_OneofDescriptorProto_default_instance_._instance, - &::PROTOBUF_NAMESPACE_ID::_EnumDescriptorProto_EnumReservedRange_default_instance_._instance, - &::PROTOBUF_NAMESPACE_ID::_EnumDescriptorProto_default_instance_._instance, - &::PROTOBUF_NAMESPACE_ID::_EnumValueDescriptorProto_default_instance_._instance, - &::PROTOBUF_NAMESPACE_ID::_ServiceDescriptorProto_default_instance_._instance, - &::PROTOBUF_NAMESPACE_ID::_MethodDescriptorProto_default_instance_._instance, - &::PROTOBUF_NAMESPACE_ID::_FileOptions_default_instance_._instance, - &::PROTOBUF_NAMESPACE_ID::_MessageOptions_default_instance_._instance, - &::PROTOBUF_NAMESPACE_ID::_FieldOptions_default_instance_._instance, - &::PROTOBUF_NAMESPACE_ID::_OneofOptions_default_instance_._instance, - &::PROTOBUF_NAMESPACE_ID::_EnumOptions_default_instance_._instance, - &::PROTOBUF_NAMESPACE_ID::_EnumValueOptions_default_instance_._instance, - &::PROTOBUF_NAMESPACE_ID::_ServiceOptions_default_instance_._instance, - &::PROTOBUF_NAMESPACE_ID::_MethodOptions_default_instance_._instance, - &::PROTOBUF_NAMESPACE_ID::_UninterpretedOption_NamePart_default_instance_._instance, - &::PROTOBUF_NAMESPACE_ID::_UninterpretedOption_default_instance_._instance, - &::PROTOBUF_NAMESPACE_ID::_SourceCodeInfo_Location_default_instance_._instance, - &::PROTOBUF_NAMESPACE_ID::_SourceCodeInfo_default_instance_._instance, - &::PROTOBUF_NAMESPACE_ID::_GeneratedCodeInfo_Annotation_default_instance_._instance, - &::PROTOBUF_NAMESPACE_ID::_GeneratedCodeInfo_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_FileDescriptorSet_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_FileDescriptorProto_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_DescriptorProto_ExtensionRange_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_DescriptorProto_ReservedRange_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_DescriptorProto_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_ExtensionRangeOptions_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_FieldDescriptorProto_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_OneofDescriptorProto_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_EnumDescriptorProto_EnumReservedRange_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_EnumDescriptorProto_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_EnumValueDescriptorProto_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_ServiceDescriptorProto_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_MethodDescriptorProto_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_FileOptions_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_MessageOptions_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_FieldOptions_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_OneofOptions_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_EnumOptions_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_EnumValueOptions_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_ServiceOptions_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_MethodOptions_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_UninterpretedOption_NamePart_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_UninterpretedOption_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_SourceCodeInfo_Location_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_SourceCodeInfo_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_GeneratedCodeInfo_Annotation_default_instance_._instance, + &::PROTOBUF_NAMESPACE_ID::_GeneratedCodeInfo_default_instance_._instance, }; - -const char descriptor_table_protodef_google_2fprotobuf_2fdescriptor_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = - "\n google/protobuf/descriptor.proto\022\017goog" - "le.protobuf\"G\n\021FileDescriptorSet\0222\n\004file" - "\030\001 \003(\0132$.google.protobuf.FileDescriptorP" - "roto\"\354\003\n\023FileDescriptorProto\022\014\n\004name\030\001 \001" - "(\t\022\017\n\007package\030\002 \001(\t\022\022\n\ndependency\030\003 \003(\t\022" - "\031\n\021public_dependency\030\n \003(\005\022\027\n\017weak_depen" - "dency\030\013 \003(\005\0226\n\014message_type\030\004 \003(\0132 .goog" - "le.protobuf.DescriptorProto\0227\n\tenum_type" - "\030\005 \003(\0132$.google.protobuf.EnumDescriptorP" - "roto\0228\n\007service\030\006 \003(\0132\'.google.protobuf." - "ServiceDescriptorProto\0228\n\textension\030\007 \003(" - "\0132%.google.protobuf.FieldDescriptorProto" - "\022-\n\007options\030\010 \001(\0132\034.google.protobuf.File" - "Options\0229\n\020source_code_info\030\t \001(\0132\037.goog" - "le.protobuf.SourceCodeInfo\022\016\n\006syntax\030\014 \001" - "(\t\022\017\n\007edition\030\r \001(\t\"\251\005\n\017DescriptorProto\022" - "\014\n\004name\030\001 \001(\t\0224\n\005field\030\002 \003(\0132%.google.pr" - "otobuf.FieldDescriptorProto\0228\n\textension" - "\030\006 \003(\0132%.google.protobuf.FieldDescriptor" - "Proto\0225\n\013nested_type\030\003 \003(\0132 .google.prot" - "obuf.DescriptorProto\0227\n\tenum_type\030\004 \003(\0132" - "$.google.protobuf.EnumDescriptorProto\022H\n" - "\017extension_range\030\005 \003(\0132/.google.protobuf" - ".DescriptorProto.ExtensionRange\0229\n\noneof" - "_decl\030\010 \003(\0132%.google.protobuf.OneofDescr" - "iptorProto\0220\n\007options\030\007 \001(\0132\037.google.pro" - "tobuf.MessageOptions\022F\n\016reserved_range\030\t" - " \003(\0132..google.protobuf.DescriptorProto.R" - "eservedRange\022\025\n\rreserved_name\030\n \003(\t\032e\n\016E" - "xtensionRange\022\r\n\005start\030\001 \001(\005\022\013\n\003end\030\002 \001(" - "\005\0227\n\007options\030\003 \001(\0132&.google.protobuf.Ext" - "ensionRangeOptions\032+\n\rReservedRange\022\r\n\005s" - "tart\030\001 \001(\005\022\013\n\003end\030\002 \001(\005\"g\n\025ExtensionRang" - "eOptions\022C\n\024uninterpreted_option\030\347\007 \003(\0132" - "$.google.protobuf.UninterpretedOption*\t\010" - "\350\007\020\200\200\200\200\002\"\325\005\n\024FieldDescriptorProto\022\014\n\004nam" - "e\030\001 \001(\t\022\016\n\006number\030\003 \001(\005\022:\n\005label\030\004 \001(\0162+" - ".google.protobuf.FieldDescriptorProto.La" - "bel\0228\n\004type\030\005 \001(\0162*.google.protobuf.Fiel" - "dDescriptorProto.Type\022\021\n\ttype_name\030\006 \001(\t" - "\022\020\n\010extendee\030\002 \001(\t\022\025\n\rdefault_value\030\007 \001(" - "\t\022\023\n\013oneof_index\030\t \001(\005\022\021\n\tjson_name\030\n \001(" - "\t\022.\n\007options\030\010 \001(\0132\035.google.protobuf.Fie" - "ldOptions\022\027\n\017proto3_optional\030\021 \001(\010\"\266\002\n\004T" - "ype\022\017\n\013TYPE_DOUBLE\020\001\022\016\n\nTYPE_FLOAT\020\002\022\016\n\n" - "TYPE_INT64\020\003\022\017\n\013TYPE_UINT64\020\004\022\016\n\nTYPE_IN" - "T32\020\005\022\020\n\014TYPE_FIXED64\020\006\022\020\n\014TYPE_FIXED32\020" - "\007\022\r\n\tTYPE_BOOL\020\010\022\017\n\013TYPE_STRING\020\t\022\016\n\nTYP" - "E_GROUP\020\n\022\020\n\014TYPE_MESSAGE\020\013\022\016\n\nTYPE_BYTE" - "S\020\014\022\017\n\013TYPE_UINT32\020\r\022\r\n\tTYPE_ENUM\020\016\022\021\n\rT" - "YPE_SFIXED32\020\017\022\021\n\rTYPE_SFIXED64\020\020\022\017\n\013TYP" - "E_SINT32\020\021\022\017\n\013TYPE_SINT64\020\022\"C\n\005Label\022\022\n\016" - "LABEL_OPTIONAL\020\001\022\022\n\016LABEL_REQUIRED\020\002\022\022\n\016" - "LABEL_REPEATED\020\003\"T\n\024OneofDescriptorProto" - "\022\014\n\004name\030\001 \001(\t\022.\n\007options\030\002 \001(\0132\035.google" - ".protobuf.OneofOptions\"\244\002\n\023EnumDescripto" - "rProto\022\014\n\004name\030\001 \001(\t\0228\n\005value\030\002 \003(\0132).go" - "ogle.protobuf.EnumValueDescriptorProto\022-" - "\n\007options\030\003 \001(\0132\034.google.protobuf.EnumOp" - "tions\022N\n\016reserved_range\030\004 \003(\01326.google.p" - "rotobuf.EnumDescriptorProto.EnumReserved" - "Range\022\025\n\rreserved_name\030\005 \003(\t\032/\n\021EnumRese" - "rvedRange\022\r\n\005start\030\001 \001(\005\022\013\n\003end\030\002 \001(\005\"l\n" - "\030EnumValueDescriptorProto\022\014\n\004name\030\001 \001(\t\022" - "\016\n\006number\030\002 \001(\005\0222\n\007options\030\003 \001(\0132!.googl" - "e.protobuf.EnumValueOptions\"\220\001\n\026ServiceD" - "escriptorProto\022\014\n\004name\030\001 \001(\t\0226\n\006method\030\002" - " \003(\0132&.google.protobuf.MethodDescriptorP" - "roto\0220\n\007options\030\003 \001(\0132\037.google.protobuf." - "ServiceOptions\"\301\001\n\025MethodDescriptorProto" - "\022\014\n\004name\030\001 \001(\t\022\022\n\ninput_type\030\002 \001(\t\022\023\n\013ou" - "tput_type\030\003 \001(\t\022/\n\007options\030\004 \001(\0132\036.googl" - "e.protobuf.MethodOptions\022\037\n\020client_strea" - "ming\030\005 \001(\010:\005false\022\037\n\020server_streaming\030\006 " - "\001(\010:\005false\"\245\006\n\013FileOptions\022\024\n\014java_packa" - "ge\030\001 \001(\t\022\034\n\024java_outer_classname\030\010 \001(\t\022\"" - "\n\023java_multiple_files\030\n \001(\010:\005false\022)\n\035ja" - "va_generate_equals_and_hash\030\024 \001(\010B\002\030\001\022%\n" - "\026java_string_check_utf8\030\033 \001(\010:\005false\022F\n\014" - "optimize_for\030\t \001(\0162).google.protobuf.Fil" - "eOptions.OptimizeMode:\005SPEED\022\022\n\ngo_packa" - "ge\030\013 \001(\t\022\"\n\023cc_generic_services\030\020 \001(\010:\005f" - "alse\022$\n\025java_generic_services\030\021 \001(\010:\005fal" - "se\022\"\n\023py_generic_services\030\022 \001(\010:\005false\022#" - "\n\024php_generic_services\030* \001(\010:\005false\022\031\n\nd" - "eprecated\030\027 \001(\010:\005false\022\036\n\020cc_enable_aren" - "as\030\037 \001(\010:\004true\022\031\n\021objc_class_prefix\030$ \001(" - "\t\022\030\n\020csharp_namespace\030% \001(\t\022\024\n\014swift_pre" - "fix\030\' \001(\t\022\030\n\020php_class_prefix\030( \001(\t\022\025\n\rp" - "hp_namespace\030) \001(\t\022\036\n\026php_metadata_names" - "pace\030, \001(\t\022\024\n\014ruby_package\030- \001(\t\022C\n\024unin" - "terpreted_option\030\347\007 \003(\0132$.google.protobu" - "f.UninterpretedOption\":\n\014OptimizeMode\022\t\n" - "\005SPEED\020\001\022\r\n\tCODE_SIZE\020\002\022\020\n\014LITE_RUNTIME\020" - "\003*\t\010\350\007\020\200\200\200\200\002J\004\010&\020\'\"\204\002\n\016MessageOptions\022&\n" - "\027message_set_wire_format\030\001 \001(\010:\005false\022.\n" - "\037no_standard_descriptor_accessor\030\002 \001(\010:\005" - "false\022\031\n\ndeprecated\030\003 \001(\010:\005false\022\021\n\tmap_" - "entry\030\007 \001(\010\022C\n\024uninterpreted_option\030\347\007 \003" - "(\0132$.google.protobuf.UninterpretedOption" - "*\t\010\350\007\020\200\200\200\200\002J\004\010\004\020\005J\004\010\005\020\006J\004\010\006\020\007J\004\010\010\020\tJ\004\010\t\020" - "\n\"\276\003\n\014FieldOptions\022:\n\005ctype\030\001 \001(\0162#.goog" - "le.protobuf.FieldOptions.CType:\006STRING\022\016" - "\n\006packed\030\002 \001(\010\022\?\n\006jstype\030\006 \001(\0162$.google." - "protobuf.FieldOptions.JSType:\tJS_NORMAL\022" - "\023\n\004lazy\030\005 \001(\010:\005false\022\036\n\017unverified_lazy\030" - "\017 \001(\010:\005false\022\031\n\ndeprecated\030\003 \001(\010:\005false\022" - "\023\n\004weak\030\n \001(\010:\005false\022C\n\024uninterpreted_op" - "tion\030\347\007 \003(\0132$.google.protobuf.Uninterpre" - "tedOption\"/\n\005CType\022\n\n\006STRING\020\000\022\010\n\004CORD\020\001" - "\022\020\n\014STRING_PIECE\020\002\"5\n\006JSType\022\r\n\tJS_NORMA" - "L\020\000\022\r\n\tJS_STRING\020\001\022\r\n\tJS_NUMBER\020\002*\t\010\350\007\020\200" - "\200\200\200\002J\004\010\004\020\005\"^\n\014OneofOptions\022C\n\024uninterpre" - "ted_option\030\347\007 \003(\0132$.google.protobuf.Unin" - "terpretedOption*\t\010\350\007\020\200\200\200\200\002\"\223\001\n\013EnumOptio" - "ns\022\023\n\013allow_alias\030\002 \001(\010\022\031\n\ndeprecated\030\003 " - "\001(\010:\005false\022C\n\024uninterpreted_option\030\347\007 \003(" - "\0132$.google.protobuf.UninterpretedOption*" - "\t\010\350\007\020\200\200\200\200\002J\004\010\005\020\006\"}\n\020EnumValueOptions\022\031\n\n" - "deprecated\030\001 \001(\010:\005false\022C\n\024uninterpreted" - "_option\030\347\007 \003(\0132$.google.protobuf.Uninter" - "pretedOption*\t\010\350\007\020\200\200\200\200\002\"{\n\016ServiceOption" - "s\022\031\n\ndeprecated\030! \001(\010:\005false\022C\n\024uninterp" - "reted_option\030\347\007 \003(\0132$.google.protobuf.Un" - "interpretedOption*\t\010\350\007\020\200\200\200\200\002\"\255\002\n\rMethodO" - "ptions\022\031\n\ndeprecated\030! \001(\010:\005false\022_\n\021ide" - "mpotency_level\030\" \001(\0162/.google.protobuf.M" - "ethodOptions.IdempotencyLevel:\023IDEMPOTEN" - "CY_UNKNOWN\022C\n\024uninterpreted_option\030\347\007 \003(" - "\0132$.google.protobuf.UninterpretedOption\"" - "P\n\020IdempotencyLevel\022\027\n\023IDEMPOTENCY_UNKNO" - "WN\020\000\022\023\n\017NO_SIDE_EFFECTS\020\001\022\016\n\nIDEMPOTENT\020" - "\002*\t\010\350\007\020\200\200\200\200\002\"\236\002\n\023UninterpretedOption\022;\n\004" - "name\030\002 \003(\0132-.google.protobuf.Uninterpret" - "edOption.NamePart\022\030\n\020identifier_value\030\003 " - "\001(\t\022\032\n\022positive_int_value\030\004 \001(\004\022\032\n\022negat" - "ive_int_value\030\005 \001(\003\022\024\n\014double_value\030\006 \001(" - "\001\022\024\n\014string_value\030\007 \001(\014\022\027\n\017aggregate_val" - "ue\030\010 \001(\t\0323\n\010NamePart\022\021\n\tname_part\030\001 \002(\t\022" - "\024\n\014is_extension\030\002 \002(\010\"\325\001\n\016SourceCodeInfo" - "\022:\n\010location\030\001 \003(\0132(.google.protobuf.Sou" - "rceCodeInfo.Location\032\206\001\n\010Location\022\020\n\004pat" - "h\030\001 \003(\005B\002\020\001\022\020\n\004span\030\002 \003(\005B\002\020\001\022\030\n\020leading" - "_comments\030\003 \001(\t\022\031\n\021trailing_comments\030\004 \001" - "(\t\022!\n\031leading_detached_comments\030\006 \003(\t\"\234\002" - "\n\021GeneratedCodeInfo\022A\n\nannotation\030\001 \003(\0132" - "-.google.protobuf.GeneratedCodeInfo.Anno" - "tation\032\303\001\n\nAnnotation\022\020\n\004path\030\001 \003(\005B\002\020\001\022" - "\023\n\013source_file\030\002 \001(\t\022\r\n\005begin\030\003 \001(\005\022\013\n\003e" - "nd\030\004 \001(\005\022H\n\010semantic\030\005 \001(\01626.google.prot" - "obuf.GeneratedCodeInfo.Annotation.Semant" - "ic\"(\n\010Semantic\022\010\n\004NONE\020\000\022\007\n\003SET\020\001\022\t\n\005ALI" - "AS\020\002B~\n\023com.google.protobufB\020DescriptorP" - "rotosH\001Z-google.golang.org/protobuf/type" - "s/descriptorpb\370\001\001\242\002\003GPB\252\002\032Google.Protobu" - "f.Reflection" - ; +const char descriptor_table_protodef_google_2fprotobuf_2fdescriptor_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + "\n google/protobuf/descriptor.proto\022\017goog" + "le.protobuf\"G\n\021FileDescriptorSet\0222\n\004file" + "\030\001 \003(\0132$.google.protobuf.FileDescriptorP" + "roto\"\354\003\n\023FileDescriptorProto\022\014\n\004name\030\001 \001" + "(\t\022\017\n\007package\030\002 \001(\t\022\022\n\ndependency\030\003 \003(\t\022" + "\031\n\021public_dependency\030\n \003(\005\022\027\n\017weak_depen" + "dency\030\013 \003(\005\0226\n\014message_type\030\004 \003(\0132 .goog" + "le.protobuf.DescriptorProto\0227\n\tenum_type" + "\030\005 \003(\0132$.google.protobuf.EnumDescriptorP" + "roto\0228\n\007service\030\006 \003(\0132\'.google.protobuf." + "ServiceDescriptorProto\0228\n\textension\030\007 \003(" + "\0132%.google.protobuf.FieldDescriptorProto" + "\022-\n\007options\030\010 \001(\0132\034.google.protobuf.File" + "Options\0229\n\020source_code_info\030\t \001(\0132\037.goog" + "le.protobuf.SourceCodeInfo\022\016\n\006syntax\030\014 \001" + "(\t\022\017\n\007edition\030\r \001(\t\"\251\005\n\017DescriptorProto\022" + "\014\n\004name\030\001 \001(\t\0224\n\005field\030\002 \003(\0132%.google.pr" + "otobuf.FieldDescriptorProto\0228\n\textension" + "\030\006 \003(\0132%.google.protobuf.FieldDescriptor" + "Proto\0225\n\013nested_type\030\003 \003(\0132 .google.prot" + "obuf.DescriptorProto\0227\n\tenum_type\030\004 \003(\0132" + "$.google.protobuf.EnumDescriptorProto\022H\n" + "\017extension_range\030\005 \003(\0132/.google.protobuf" + ".DescriptorProto.ExtensionRange\0229\n\noneof" + "_decl\030\010 \003(\0132%.google.protobuf.OneofDescr" + "iptorProto\0220\n\007options\030\007 \001(\0132\037.google.pro" + "tobuf.MessageOptions\022F\n\016reserved_range\030\t" + " \003(\0132..google.protobuf.DescriptorProto.R" + "eservedRange\022\025\n\rreserved_name\030\n \003(\t\032e\n\016E" + "xtensionRange\022\r\n\005start\030\001 \001(\005\022\013\n\003end\030\002 \001(" + "\005\0227\n\007options\030\003 \001(\0132&.google.protobuf.Ext" + "ensionRangeOptions\032+\n\rReservedRange\022\r\n\005s" + "tart\030\001 \001(\005\022\013\n\003end\030\002 \001(\005\"g\n\025ExtensionRang" + "eOptions\022C\n\024uninterpreted_option\030\347\007 \003(\0132" + "$.google.protobuf.UninterpretedOption*\t\010" + "\350\007\020\200\200\200\200\002\"\325\005\n\024FieldDescriptorProto\022\014\n\004nam" + "e\030\001 \001(\t\022\016\n\006number\030\003 \001(\005\022:\n\005label\030\004 \001(\0162+" + ".google.protobuf.FieldDescriptorProto.La" + "bel\0228\n\004type\030\005 \001(\0162*.google.protobuf.Fiel" + "dDescriptorProto.Type\022\021\n\ttype_name\030\006 \001(\t" + "\022\020\n\010extendee\030\002 \001(\t\022\025\n\rdefault_value\030\007 \001(" + "\t\022\023\n\013oneof_index\030\t \001(\005\022\021\n\tjson_name\030\n \001(" + "\t\022.\n\007options\030\010 \001(\0132\035.google.protobuf.Fie" + "ldOptions\022\027\n\017proto3_optional\030\021 \001(\010\"\266\002\n\004T" + "ype\022\017\n\013TYPE_DOUBLE\020\001\022\016\n\nTYPE_FLOAT\020\002\022\016\n\n" + "TYPE_INT64\020\003\022\017\n\013TYPE_UINT64\020\004\022\016\n\nTYPE_IN" + "T32\020\005\022\020\n\014TYPE_FIXED64\020\006\022\020\n\014TYPE_FIXED32\020" + "\007\022\r\n\tTYPE_BOOL\020\010\022\017\n\013TYPE_STRING\020\t\022\016\n\nTYP" + "E_GROUP\020\n\022\020\n\014TYPE_MESSAGE\020\013\022\016\n\nTYPE_BYTE" + "S\020\014\022\017\n\013TYPE_UINT32\020\r\022\r\n\tTYPE_ENUM\020\016\022\021\n\rT" + "YPE_SFIXED32\020\017\022\021\n\rTYPE_SFIXED64\020\020\022\017\n\013TYP" + "E_SINT32\020\021\022\017\n\013TYPE_SINT64\020\022\"C\n\005Label\022\022\n\016" + "LABEL_OPTIONAL\020\001\022\022\n\016LABEL_REQUIRED\020\002\022\022\n\016" + "LABEL_REPEATED\020\003\"T\n\024OneofDescriptorProto" + "\022\014\n\004name\030\001 \001(\t\022.\n\007options\030\002 \001(\0132\035.google" + ".protobuf.OneofOptions\"\244\002\n\023EnumDescripto" + "rProto\022\014\n\004name\030\001 \001(\t\0228\n\005value\030\002 \003(\0132).go" + "ogle.protobuf.EnumValueDescriptorProto\022-" + "\n\007options\030\003 \001(\0132\034.google.protobuf.EnumOp" + "tions\022N\n\016reserved_range\030\004 \003(\01326.google.p" + "rotobuf.EnumDescriptorProto.EnumReserved" + "Range\022\025\n\rreserved_name\030\005 \003(\t\032/\n\021EnumRese" + "rvedRange\022\r\n\005start\030\001 \001(\005\022\013\n\003end\030\002 \001(\005\"l\n" + "\030EnumValueDescriptorProto\022\014\n\004name\030\001 \001(\t\022" + "\016\n\006number\030\002 \001(\005\0222\n\007options\030\003 \001(\0132!.googl" + "e.protobuf.EnumValueOptions\"\220\001\n\026ServiceD" + "escriptorProto\022\014\n\004name\030\001 \001(\t\0226\n\006method\030\002" + " \003(\0132&.google.protobuf.MethodDescriptorP" + "roto\0220\n\007options\030\003 \001(\0132\037.google.protobuf." + "ServiceOptions\"\301\001\n\025MethodDescriptorProto" + "\022\014\n\004name\030\001 \001(\t\022\022\n\ninput_type\030\002 \001(\t\022\023\n\013ou" + "tput_type\030\003 \001(\t\022/\n\007options\030\004 \001(\0132\036.googl" + "e.protobuf.MethodOptions\022\037\n\020client_strea" + "ming\030\005 \001(\010:\005false\022\037\n\020server_streaming\030\006 " + "\001(\010:\005false\"\245\006\n\013FileOptions\022\024\n\014java_packa" + "ge\030\001 \001(\t\022\034\n\024java_outer_classname\030\010 \001(\t\022\"" + "\n\023java_multiple_files\030\n \001(\010:\005false\022)\n\035ja" + "va_generate_equals_and_hash\030\024 \001(\010B\002\030\001\022%\n" + "\026java_string_check_utf8\030\033 \001(\010:\005false\022F\n\014" + "optimize_for\030\t \001(\0162).google.protobuf.Fil" + "eOptions.OptimizeMode:\005SPEED\022\022\n\ngo_packa" + "ge\030\013 \001(\t\022\"\n\023cc_generic_services\030\020 \001(\010:\005f" + "alse\022$\n\025java_generic_services\030\021 \001(\010:\005fal" + "se\022\"\n\023py_generic_services\030\022 \001(\010:\005false\022#" + "\n\024php_generic_services\030* \001(\010:\005false\022\031\n\nd" + "eprecated\030\027 \001(\010:\005false\022\036\n\020cc_enable_aren" + "as\030\037 \001(\010:\004true\022\031\n\021objc_class_prefix\030$ \001(" + "\t\022\030\n\020csharp_namespace\030% \001(\t\022\024\n\014swift_pre" + "fix\030\' \001(\t\022\030\n\020php_class_prefix\030( \001(\t\022\025\n\rp" + "hp_namespace\030) \001(\t\022\036\n\026php_metadata_names" + "pace\030, \001(\t\022\024\n\014ruby_package\030- \001(\t\022C\n\024unin" + "terpreted_option\030\347\007 \003(\0132$.google.protobu" + "f.UninterpretedOption\":\n\014OptimizeMode\022\t\n" + "\005SPEED\020\001\022\r\n\tCODE_SIZE\020\002\022\020\n\014LITE_RUNTIME\020" + "\003*\t\010\350\007\020\200\200\200\200\002J\004\010&\020\'\"\204\002\n\016MessageOptions\022&\n" + "\027message_set_wire_format\030\001 \001(\010:\005false\022.\n" + "\037no_standard_descriptor_accessor\030\002 \001(\010:\005" + "false\022\031\n\ndeprecated\030\003 \001(\010:\005false\022\021\n\tmap_" + "entry\030\007 \001(\010\022C\n\024uninterpreted_option\030\347\007 \003" + "(\0132$.google.protobuf.UninterpretedOption" + "*\t\010\350\007\020\200\200\200\200\002J\004\010\004\020\005J\004\010\005\020\006J\004\010\006\020\007J\004\010\010\020\tJ\004\010\t\020" + "\n\"\276\003\n\014FieldOptions\022:\n\005ctype\030\001 \001(\0162#.goog" + "le.protobuf.FieldOptions.CType:\006STRING\022\016" + "\n\006packed\030\002 \001(\010\022\?\n\006jstype\030\006 \001(\0162$.google." + "protobuf.FieldOptions.JSType:\tJS_NORMAL\022" + "\023\n\004lazy\030\005 \001(\010:\005false\022\036\n\017unverified_lazy\030" + "\017 \001(\010:\005false\022\031\n\ndeprecated\030\003 \001(\010:\005false\022" + "\023\n\004weak\030\n \001(\010:\005false\022C\n\024uninterpreted_op" + "tion\030\347\007 \003(\0132$.google.protobuf.Uninterpre" + "tedOption\"/\n\005CType\022\n\n\006STRING\020\000\022\010\n\004CORD\020\001" + "\022\020\n\014STRING_PIECE\020\002\"5\n\006JSType\022\r\n\tJS_NORMA" + "L\020\000\022\r\n\tJS_STRING\020\001\022\r\n\tJS_NUMBER\020\002*\t\010\350\007\020\200" + "\200\200\200\002J\004\010\004\020\005\"^\n\014OneofOptions\022C\n\024uninterpre" + "ted_option\030\347\007 \003(\0132$.google.protobuf.Unin" + "terpretedOption*\t\010\350\007\020\200\200\200\200\002\"\223\001\n\013EnumOptio" + "ns\022\023\n\013allow_alias\030\002 \001(\010\022\031\n\ndeprecated\030\003 " + "\001(\010:\005false\022C\n\024uninterpreted_option\030\347\007 \003(" + "\0132$.google.protobuf.UninterpretedOption*" + "\t\010\350\007\020\200\200\200\200\002J\004\010\005\020\006\"}\n\020EnumValueOptions\022\031\n\n" + "deprecated\030\001 \001(\010:\005false\022C\n\024uninterpreted" + "_option\030\347\007 \003(\0132$.google.protobuf.Uninter" + "pretedOption*\t\010\350\007\020\200\200\200\200\002\"{\n\016ServiceOption" + "s\022\031\n\ndeprecated\030! \001(\010:\005false\022C\n\024uninterp" + "reted_option\030\347\007 \003(\0132$.google.protobuf.Un" + "interpretedOption*\t\010\350\007\020\200\200\200\200\002\"\255\002\n\rMethodO" + "ptions\022\031\n\ndeprecated\030! \001(\010:\005false\022_\n\021ide" + "mpotency_level\030\" \001(\0162/.google.protobuf.M" + "ethodOptions.IdempotencyLevel:\023IDEMPOTEN" + "CY_UNKNOWN\022C\n\024uninterpreted_option\030\347\007 \003(" + "\0132$.google.protobuf.UninterpretedOption\"" + "P\n\020IdempotencyLevel\022\027\n\023IDEMPOTENCY_UNKNO" + "WN\020\000\022\023\n\017NO_SIDE_EFFECTS\020\001\022\016\n\nIDEMPOTENT\020" + "\002*\t\010\350\007\020\200\200\200\200\002\"\236\002\n\023UninterpretedOption\022;\n\004" + "name\030\002 \003(\0132-.google.protobuf.Uninterpret" + "edOption.NamePart\022\030\n\020identifier_value\030\003 " + "\001(\t\022\032\n\022positive_int_value\030\004 \001(\004\022\032\n\022negat" + "ive_int_value\030\005 \001(\003\022\024\n\014double_value\030\006 \001(" + "\001\022\024\n\014string_value\030\007 \001(\014\022\027\n\017aggregate_val" + "ue\030\010 \001(\t\0323\n\010NamePart\022\021\n\tname_part\030\001 \002(\t\022" + "\024\n\014is_extension\030\002 \002(\010\"\325\001\n\016SourceCodeInfo" + "\022:\n\010location\030\001 \003(\0132(.google.protobuf.Sou" + "rceCodeInfo.Location\032\206\001\n\010Location\022\020\n\004pat" + "h\030\001 \003(\005B\002\020\001\022\020\n\004span\030\002 \003(\005B\002\020\001\022\030\n\020leading" + "_comments\030\003 \001(\t\022\031\n\021trailing_comments\030\004 \001" + "(\t\022!\n\031leading_detached_comments\030\006 \003(\t\"\234\002" + "\n\021GeneratedCodeInfo\022A\n\nannotation\030\001 \003(\0132" + "-.google.protobuf.GeneratedCodeInfo.Anno" + "tation\032\303\001\n\nAnnotation\022\020\n\004path\030\001 \003(\005B\002\020\001\022" + "\023\n\013source_file\030\002 \001(\t\022\r\n\005begin\030\003 \001(\005\022\013\n\003e" + "nd\030\004 \001(\005\022H\n\010semantic\030\005 \001(\01626.google.prot" + "obuf.GeneratedCodeInfo.Annotation.Semant" + "ic\"(\n\010Semantic\022\010\n\004NONE\020\000\022\007\n\003SET\020\001\022\t\n\005ALI" + "AS\020\002B~\n\023com.google.protobufB\020DescriptorP" + "rotosH\001Z-google.golang.org/protobuf/type" + "s/descriptorpb\370\001\001\242\002\003GPB\252\002\032Google.Protobu" + "f.Reflection" +}; static ::absl::once_flag descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once; const ::_pbi::DescriptorTable descriptor_table_google_2fprotobuf_2fdescriptor_2eproto = { - false, false, 6212, descriptor_table_protodef_google_2fprotobuf_2fdescriptor_2eproto, + false, + false, + 6212, + descriptor_table_protodef_google_2fprotobuf_2fdescriptor_2eproto, "google/protobuf/descriptor.proto", - &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, nullptr, 0, 27, - schemas, file_default_instances, TableStruct_google_2fprotobuf_2fdescriptor_2eproto::offsets, - file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto, file_level_enum_descriptors_google_2fprotobuf_2fdescriptor_2eproto, + &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, + nullptr, + 0, + 27, + schemas, + file_default_instances, + TableStruct_google_2fprotobuf_2fdescriptor_2eproto::offsets, + file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto, + file_level_enum_descriptors_google_2fprotobuf_2fdescriptor_2eproto, file_level_service_descriptors_google_2fprotobuf_2fdescriptor_2eproto, }; + +// 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 of more than 35% of walltime for optimized builds. Without +// the weak attribute all the messages in the file, including all the +// vtables and everything they use become part of the same SCC through +// a cycle like: +// GetMetadata -> descriptor table -> default instances -> +// vtables -> GetMetadata +// By adding a weak function here we break the connection from the +// individual vtables back into the descriptor table. PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter() { return &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto; } - // Force running AddDescriptors() at dynamic initialization time. -PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2fdescriptor_2eproto(&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto); +PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 +static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_google_2fprotobuf_2fdescriptor_2eproto(&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto); PROTOBUF_NAMESPACE_OPEN const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* FieldDescriptorProto_Type_descriptor() { ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_google_2fprotobuf_2fdescriptor_2eproto); @@ -1406,7 +1454,6 @@ constexpr GeneratedCodeInfo_Annotation_Semantic GeneratedCodeInfo_Annotation::Semantic_MAX; constexpr int GeneratedCodeInfo_Annotation::Semantic_ARRAYSIZE; #endif // (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) - // =================================================================== class FileDescriptorSet::_Internal { @@ -1593,7 +1640,6 @@ &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[0]); } - // =================================================================== class FileDescriptorProto::_Internal { @@ -2349,7 +2395,6 @@ &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[1]); } - // =================================================================== class DescriptorProto_ExtensionRange::_Internal { @@ -2635,7 +2680,6 @@ &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[2]); } - // =================================================================== class DescriptorProto_ReservedRange::_Internal { @@ -2874,7 +2918,6 @@ &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[3]); } - // =================================================================== class DescriptorProto::_Internal { @@ -3442,7 +3485,6 @@ &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[4]); } - // =================================================================== class ExtensionRangeOptions::_Internal { @@ -3651,7 +3693,6 @@ &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[5]); } - // =================================================================== class FieldDescriptorProto::_Internal { @@ -4334,7 +4375,6 @@ &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[6]); } - // =================================================================== class OneofDescriptorProto::_Internal { @@ -4611,7 +4651,6 @@ &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[7]); } - // =================================================================== class EnumDescriptorProto_EnumReservedRange::_Internal { @@ -4850,7 +4889,6 @@ &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[8]); } - // =================================================================== class EnumDescriptorProto::_Internal { @@ -5238,7 +5276,6 @@ &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[9]); } - // =================================================================== class EnumValueDescriptorProto::_Internal { @@ -5551,7 +5588,6 @@ &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[10]); } - // =================================================================== class ServiceDescriptorProto::_Internal { @@ -5864,7 +5900,6 @@ &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[11]); } - // =================================================================== class MethodDescriptorProto::_Internal { @@ -6323,7 +6358,6 @@ &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[12]); } - // =================================================================== class FileOptions::_Internal { @@ -7444,7 +7478,6 @@ &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[13]); } - // =================================================================== class MessageOptions::_Internal { @@ -7794,7 +7827,6 @@ &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[14]); } - // =================================================================== class FieldOptions::_Internal { @@ -8243,7 +8275,6 @@ &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[15]); } - // =================================================================== class OneofOptions::_Internal { @@ -8452,7 +8483,6 @@ &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[16]); } - // =================================================================== class EnumOptions::_Internal { @@ -8746,7 +8776,6 @@ &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[17]); } - // =================================================================== class EnumValueOptions::_Internal { @@ -8997,7 +9026,6 @@ &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[18]); } - // =================================================================== class ServiceOptions::_Internal { @@ -9248,7 +9276,6 @@ &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[19]); } - // =================================================================== class MethodOptions::_Internal { @@ -9551,7 +9578,6 @@ &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[20]); } - // =================================================================== class UninterpretedOption_NamePart::_Internal { @@ -9829,7 +9855,6 @@ &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[21]); } - // =================================================================== class UninterpretedOption::_Internal { @@ -10300,7 +10325,6 @@ &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[22]); } - // =================================================================== class SourceCodeInfo_Location::_Internal { @@ -10709,7 +10733,6 @@ &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[23]); } - // =================================================================== class SourceCodeInfo::_Internal { @@ -10894,7 +10917,6 @@ &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[24]); } - // =================================================================== class GeneratedCodeInfo_Annotation::_Internal { @@ -11267,7 +11289,6 @@ &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[25]); } - // =================================================================== class GeneratedCodeInfo::_Internal { @@ -11452,7 +11473,6 @@ &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_getter, &descriptor_table_google_2fprotobuf_2fdescriptor_2eproto_once, file_level_metadata_google_2fprotobuf_2fdescriptor_2eproto[26]); } - // @@protoc_insertion_point(namespace_scope) PROTOBUF_NAMESPACE_CLOSE PROTOBUF_NAMESPACE_OPEN @@ -11565,6 +11585,5 @@ return Arena::CreateMessageInternal< ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo >(arena); } PROTOBUF_NAMESPACE_CLOSE - // @@protoc_insertion_point(global_scope) #include "google/protobuf/port_undef.inc"
diff --git a/src/google/protobuf/descriptor.pb.h b/src/google/protobuf/descriptor.pb.h index 902b8e7..834e9ac 100644 --- a/src/google/protobuf/descriptor.pb.h +++ b/src/google/protobuf/descriptor.pb.h
@@ -6,6 +6,7 @@ #include <limits> #include <string> +#include <type_traits> #include "google/protobuf/port_def.inc" #if PROTOBUF_VERSION < 3021000 @@ -19,6 +20,11 @@ #error regenerate this file with a newer version of protoc. #endif +#if 3021005 < PROTOBUF_MIN_PROTOC_VERSION +#error "This file was generated by an older version of protoc which is" +#error "incompatible with your Protocol Buffer headers. Please" +#error "regenerate this file with a newer version of protoc." +#endif // PROTOBUF_MIN_PROTOC_VERSION #include "google/protobuf/port_undef.inc" #include "google/protobuf/io/coded_stream.h" #include "google/protobuf/arena.h" @@ -32,8 +38,12 @@ #include "google/protobuf/generated_enum_reflection.h" #include "google/protobuf/unknown_field_set.h" // @@protoc_insertion_point(includes) + +// Must be included last. #include "google/protobuf/port_def.inc" + #define PROTOBUF_INTERNAL_EXPORT_google_2fprotobuf_2fdescriptor_2eproto PROTOBUF_EXPORT + PROTOBUF_NAMESPACE_OPEN namespace internal { class AnyMetadata; @@ -44,7 +54,8 @@ struct PROTOBUF_EXPORT TableStruct_google_2fprotobuf_2fdescriptor_2eproto { static const uint32_t offsets[]; }; -PROTOBUF_EXPORT extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_google_2fprotobuf_2fdescriptor_2eproto; +PROTOBUF_EXPORT extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable + descriptor_table_google_2fprotobuf_2fdescriptor_2eproto; PROTOBUF_NAMESPACE_OPEN class DescriptorProto; struct DescriptorProtoDefaultTypeInternal; @@ -127,38 +138,63 @@ class UninterpretedOption_NamePart; struct UninterpretedOption_NamePartDefaultTypeInternal; PROTOBUF_EXPORT extern UninterpretedOption_NamePartDefaultTypeInternal _UninterpretedOption_NamePart_default_instance_; +template <> +PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::DescriptorProto* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::DescriptorProto>(Arena*); +template <> +PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange>(Arena*); +template <> +PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange>(Arena*); +template <> +PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto>(Arena*); +template <> +PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange>(Arena*); +template <> +PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::EnumOptions* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::EnumOptions>(Arena*); +template <> +PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto>(Arena*); +template <> +PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::EnumValueOptions* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::EnumValueOptions>(Arena*); +template <> +PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions>(Arena*); +template <> +PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto>(Arena*); +template <> +PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::FieldOptions* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::FieldOptions>(Arena*); +template <> +PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::FileDescriptorProto>(Arena*); +template <> +PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::FileDescriptorSet* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::FileDescriptorSet>(Arena*); +template <> +PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::FileOptions* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::FileOptions>(Arena*); +template <> +PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo>(Arena*); +template <> +PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation>(Arena*); +template <> +PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::MessageOptions* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::MessageOptions>(Arena*); +template <> +PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto>(Arena*); +template <> +PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::MethodOptions* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::MethodOptions>(Arena*); +template <> +PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto>(Arena*); +template <> +PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::OneofOptions* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::OneofOptions>(Arena*); +template <> +PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto>(Arena*); +template <> +PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::ServiceOptions* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::ServiceOptions>(Arena*); +template <> +PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::SourceCodeInfo>(Arena*); +template <> +PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location>(Arena*); +template <> +PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::UninterpretedOption* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::UninterpretedOption>(Arena*); +template <> +PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart>(Arena*); PROTOBUF_NAMESPACE_CLOSE -PROTOBUF_NAMESPACE_OPEN -template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::DescriptorProto* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::DescriptorProto>(Arena*); -template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::DescriptorProto_ExtensionRange>(Arena*); -template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::DescriptorProto_ReservedRange>(Arena*); -template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto>(Arena*); -template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::EnumDescriptorProto_EnumReservedRange>(Arena*); -template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::EnumOptions* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::EnumOptions>(Arena*); -template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::EnumValueDescriptorProto>(Arena*); -template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::EnumValueOptions* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::EnumValueOptions>(Arena*); -template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::ExtensionRangeOptions>(Arena*); -template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto>(Arena*); -template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::FieldOptions* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::FieldOptions>(Arena*); -template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::FileDescriptorProto* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::FileDescriptorProto>(Arena*); -template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::FileDescriptorSet* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::FileDescriptorSet>(Arena*); -template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::FileOptions* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::FileOptions>(Arena*); -template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo>(Arena*); -template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::GeneratedCodeInfo_Annotation>(Arena*); -template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::MessageOptions* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::MessageOptions>(Arena*); -template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::MethodDescriptorProto>(Arena*); -template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::MethodOptions* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::MethodOptions>(Arena*); -template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::OneofDescriptorProto>(Arena*); -template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::OneofOptions* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::OneofOptions>(Arena*); -template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::ServiceDescriptorProto>(Arena*); -template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::ServiceOptions* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::ServiceOptions>(Arena*); -template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::SourceCodeInfo>(Arena*); -template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::SourceCodeInfo_Location>(Arena*); -template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::UninterpretedOption* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::UninterpretedOption>(Arena*); -template<> PROTOBUF_EXPORT ::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart* Arena::CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::UninterpretedOption_NamePart>(Arena*); -PROTOBUF_NAMESPACE_CLOSE -PROTOBUF_NAMESPACE_OPEN +PROTOBUF_NAMESPACE_OPEN enum FieldDescriptorProto_Type : int { FieldDescriptorProto_Type_TYPE_DOUBLE = 1, FieldDescriptorProto_Type_TYPE_FLOAT = 2, @@ -370,8 +406,12 @@ return ::PROTOBUF_NAMESPACE_ID::internal::ParseNamedEnum<GeneratedCodeInfo_Annotation_Semantic>( GeneratedCodeInfo_Annotation_Semantic_descriptor(), name, value); } + // =================================================================== + +// ------------------------------------------------------------------- + class PROTOBUF_EXPORT FileDescriptorSet final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FileDescriptorSet) */ { public: @@ -533,8 +573,7 @@ }; union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; -}; -// ------------------------------------------------------------------- +};// ------------------------------------------------------------------- class PROTOBUF_EXPORT FileDescriptorProto final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FileDescriptorProto) */ { @@ -952,8 +991,7 @@ }; union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; -}; -// ------------------------------------------------------------------- +};// ------------------------------------------------------------------- class PROTOBUF_EXPORT DescriptorProto_ExtensionRange final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.DescriptorProto.ExtensionRange) */ { @@ -1147,8 +1185,7 @@ }; union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; -}; -// ------------------------------------------------------------------- +};// ------------------------------------------------------------------- class PROTOBUF_EXPORT DescriptorProto_ReservedRange final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.DescriptorProto.ReservedRange) */ { @@ -1322,8 +1359,7 @@ }; union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; -}; -// ------------------------------------------------------------------- +};// ------------------------------------------------------------------- class PROTOBUF_EXPORT DescriptorProto final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.DescriptorProto) */ { @@ -1676,8 +1712,7 @@ }; union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; -}; -// ------------------------------------------------------------------- +};// ------------------------------------------------------------------- class PROTOBUF_EXPORT ExtensionRangeOptions final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.ExtensionRangeOptions) */ { @@ -2032,8 +2067,7 @@ }; union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; -}; -// ------------------------------------------------------------------- +};// ------------------------------------------------------------------- class PROTOBUF_EXPORT FieldDescriptorProto final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FieldDescriptorProto) */ { @@ -2466,8 +2500,7 @@ }; union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; -}; -// ------------------------------------------------------------------- +};// ------------------------------------------------------------------- class PROTOBUF_EXPORT OneofDescriptorProto final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.OneofDescriptorProto) */ { @@ -2651,8 +2684,7 @@ }; union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; -}; -// ------------------------------------------------------------------- +};// ------------------------------------------------------------------- class PROTOBUF_EXPORT EnumDescriptorProto_EnumReservedRange final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumDescriptorProto.EnumReservedRange) */ { @@ -2826,8 +2858,7 @@ }; union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; -}; -// ------------------------------------------------------------------- +};// ------------------------------------------------------------------- class PROTOBUF_EXPORT EnumDescriptorProto final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumDescriptorProto) */ { @@ -3079,8 +3110,7 @@ }; union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; -}; -// ------------------------------------------------------------------- +};// ------------------------------------------------------------------- class PROTOBUF_EXPORT EnumValueDescriptorProto final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumValueDescriptorProto) */ { @@ -3279,8 +3309,7 @@ }; union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; -}; -// ------------------------------------------------------------------- +};// ------------------------------------------------------------------- class PROTOBUF_EXPORT ServiceDescriptorProto final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.ServiceDescriptorProto) */ { @@ -3484,8 +3513,7 @@ }; union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; -}; -// ------------------------------------------------------------------- +};// ------------------------------------------------------------------- class PROTOBUF_EXPORT MethodDescriptorProto final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.MethodDescriptorProto) */ { @@ -3739,8 +3767,7 @@ }; union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; -}; -// ------------------------------------------------------------------- +};// ------------------------------------------------------------------- class PROTOBUF_EXPORT FileOptions final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FileOptions) */ { @@ -4478,8 +4505,7 @@ }; union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; -}; -// ------------------------------------------------------------------- +};// ------------------------------------------------------------------- class PROTOBUF_EXPORT MessageOptions final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.MessageOptions) */ { @@ -4895,8 +4921,7 @@ }; union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; -}; -// ------------------------------------------------------------------- +};// ------------------------------------------------------------------- class PROTOBUF_EXPORT FieldOptions final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FieldOptions) */ { @@ -5421,8 +5446,7 @@ }; union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; -}; -// ------------------------------------------------------------------- +};// ------------------------------------------------------------------- class PROTOBUF_EXPORT OneofOptions final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.OneofOptions) */ { @@ -5777,8 +5801,7 @@ }; union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; -}; -// ------------------------------------------------------------------- +};// ------------------------------------------------------------------- class PROTOBUF_EXPORT EnumOptions final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumOptions) */ { @@ -6164,8 +6187,7 @@ }; union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; -}; -// ------------------------------------------------------------------- +};// ------------------------------------------------------------------- class PROTOBUF_EXPORT EnumValueOptions final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumValueOptions) */ { @@ -6536,8 +6558,7 @@ }; union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; -}; -// ------------------------------------------------------------------- +};// ------------------------------------------------------------------- class PROTOBUF_EXPORT ServiceOptions final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.ServiceOptions) */ { @@ -6908,8 +6929,7 @@ }; union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; -}; -// ------------------------------------------------------------------- +};// ------------------------------------------------------------------- class PROTOBUF_EXPORT MethodOptions final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.MethodOptions) */ { @@ -7327,8 +7347,7 @@ }; union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; -}; -// ------------------------------------------------------------------- +};// ------------------------------------------------------------------- class PROTOBUF_EXPORT UninterpretedOption_NamePart final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.UninterpretedOption.NamePart) */ { @@ -7510,8 +7529,7 @@ }; union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; -}; -// ------------------------------------------------------------------- +};// ------------------------------------------------------------------- class PROTOBUF_EXPORT UninterpretedOption final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.UninterpretedOption) */ { @@ -7782,8 +7800,7 @@ }; union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; -}; -// ------------------------------------------------------------------- +};// ------------------------------------------------------------------- class PROTOBUF_EXPORT SourceCodeInfo_Location final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.SourceCodeInfo.Location) */ { @@ -8043,8 +8060,7 @@ }; union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; -}; -// ------------------------------------------------------------------- +};// ------------------------------------------------------------------- class PROTOBUF_EXPORT SourceCodeInfo final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.SourceCodeInfo) */ { @@ -8209,8 +8225,7 @@ }; union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; -}; -// ------------------------------------------------------------------- +};// ------------------------------------------------------------------- class PROTOBUF_EXPORT GeneratedCodeInfo_Annotation final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.GeneratedCodeInfo.Annotation) */ { @@ -8476,8 +8491,7 @@ }; union { Impl_ _impl_; }; friend struct ::TableStruct_google_2fprotobuf_2fdescriptor_2eproto; -}; -// ------------------------------------------------------------------- +};// ------------------------------------------------------------------- class PROTOBUF_EXPORT GeneratedCodeInfo final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:google.protobuf.GeneratedCodeInfo) */ { @@ -8646,12 +8660,17 @@ // =================================================================== + + // =================================================================== + #ifdef __GNUC__ - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wstrict-aliasing" +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstrict-aliasing" #endif // __GNUC__ +// ------------------------------------------------------------------- + // FileDescriptorSet // repeated .google.protobuf.FileDescriptorProto file = 1; @@ -14861,65 +14880,13 @@ } #ifdef __GNUC__ - #pragma GCC diagnostic pop +#pragma GCC diagnostic pop #endif // __GNUC__ -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - -// ------------------------------------------------------------------- - // @@protoc_insertion_point(namespace_scope) - PROTOBUF_NAMESPACE_CLOSE + PROTOBUF_NAMESPACE_OPEN template <> struct is_proto_enum< ::PROTOBUF_NAMESPACE_ID::FieldDescriptorProto_Type> : ::std::true_type {}; @@ -14963,4 +14930,5 @@ // @@protoc_insertion_point(global_scope) #include "google/protobuf/port_undef.inc" -#endif // GOOGLE_PROTOBUF_INCLUDED_GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fdescriptor_2eproto_2epb_2eh + +#endif // GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fdescriptor_2eproto_2epb_2eh
diff --git a/src/google/protobuf/descriptor_database.cc b/src/google/protobuf/descriptor_database.cc index 440bf9a..c024a77 100644 --- a/src/google/protobuf/descriptor_database.cc +++ b/src/google/protobuf/descriptor_database.cc
@@ -39,7 +39,7 @@ #include <utility> #include "absl/strings/ascii.h" -#include "google/protobuf/stubs/strutil.h" +#include "absl/strings/match.h" #include "absl/strings/str_replace.h" #include "google/protobuf/descriptor.pb.h" #include "google/protobuf/stubs/stl_util.h" @@ -190,7 +190,7 @@ // "foo.bar.baz", but not a parent of "foo.barbaz"). bool IsSubSymbol(absl::string_view sub_symbol, absl::string_view super_symbol) { return sub_symbol == super_symbol || - (HasPrefixString(super_symbol, sub_symbol) && + (absl::StartsWith(super_symbol, sub_symbol) && super_symbol[sub_symbol.size()] == '.'); }
diff --git a/src/google/protobuf/descriptor_unittest.cc b/src/google/protobuf/descriptor_unittest.cc index 8079a26..ef99f80 100644 --- a/src/google/protobuf/descriptor_unittest.cc +++ b/src/google/protobuf/descriptor_unittest.cc
@@ -43,6 +43,7 @@ #include "google/protobuf/compiler/parser.h" #include "google/protobuf/unittest.pb.h" #include "google/protobuf/unittest_custom_options.pb.h" +#include "google/protobuf/descriptor.pb.h" #include "google/protobuf/stubs/common.h" #include "google/protobuf/stubs/logging.h" #include "google/protobuf/stubs/stringprintf.h" @@ -553,6 +554,27 @@ } } +TEST_F(FileDescriptorTest, CopyHeadingTo) { + FileDescriptorProto proto; + proto.set_name("foo.proto"); + proto.set_package("foo.bar.baz"); + proto.set_syntax("proto3"); + + // Won't be copied. + proto.add_message_type()->set_name("Foo"); + + DescriptorPool pool; + const FileDescriptor* file = pool.BuildFile(proto); + ASSERT_NE(file, nullptr); + + FileDescriptorProto other; + file->CopyHeadingTo(&other); + EXPECT_EQ(other.name(), "foo.proto"); + EXPECT_EQ(other.package(), "foo.bar.baz"); + EXPECT_EQ(other.syntax(), "proto3"); + EXPECT_TRUE(other.message_type().empty()); +} + void ExtractDebugString( const FileDescriptor* file, std::set<std::string>* visited, std::vector<std::pair<std::string, std::string>>* debug_strings) { @@ -1063,6 +1085,34 @@ EXPECT_TRUE(baz_->is_repeated()); } +TEST_F(DescriptorTest, NeedsUtf8Check) { + EXPECT_FALSE(foo_->requires_utf8_validation()); + EXPECT_FALSE(bar_->requires_utf8_validation()); + + // Build a copy of the file in proto3. + FileDescriptorProto foo_file3; + foo_file_->CopyTo(&foo_file3); + foo_file3.set_syntax("proto3"); + + // Make this valid proto3 by removing `required` and the one group field. + for (auto& f : *foo_file3.mutable_message_type(1)->mutable_field()) { + f.clear_label(); + if (f.type() == FieldDescriptorProto::TYPE_GROUP) { + f.set_type(FieldDescriptorProto::TYPE_MESSAGE); + } + } + // Make this valid proto3 by making the first enum value be zero. + foo_file3.mutable_enum_type(0)->mutable_value(0)->set_number(0); + + DescriptorPool pool3; + const Descriptor* message3 = pool3.BuildFile(foo_file3)->message_type(1); + const FieldDescriptor* foo3 = message3->field(0); + const FieldDescriptor* bar3 = message3->field(1); + + EXPECT_TRUE(foo3->requires_utf8_validation()); + EXPECT_FALSE(bar3->requires_utf8_validation()); +} + TEST_F(DescriptorTest, IsMap) { EXPECT_TRUE(map_->is_map()); EXPECT_FALSE(baz_->is_map()); @@ -1535,6 +1585,23 @@ EXPECT_EQ(enum2_, baz2_->type()); } +TEST_F(EnumDescriptorTest, IsClosed) { + // enum_ is proto2. + EXPECT_TRUE(enum_->is_closed()); + + // Make a proto3 version of enum_. + FileDescriptorProto foo_file3; + foo_file_->CopyTo(&foo_file3); + foo_file3.set_syntax("proto3"); + + // Make this valid proto3 by making the first enum value be zero. + foo_file3.mutable_enum_type(0)->mutable_value(0)->set_number(0); + + DescriptorPool pool3; + const EnumDescriptor* enum3 = pool3.BuildFile(foo_file3)->enum_type(0); + EXPECT_FALSE(enum3->is_closed()); +} + // =================================================================== // Test service descriptors.
diff --git a/src/google/protobuf/extension_set_unittest.cc b/src/google/protobuf/extension_set_unittest.cc index 84da3c5..2db28c3 100644 --- a/src/google/protobuf/extension_set_unittest.cc +++ b/src/google/protobuf/extension_set_unittest.cc
@@ -49,6 +49,7 @@ #include "google/protobuf/testing/googletest.h" #include <gtest/gtest.h> #include "absl/base/casts.h" +#include "absl/strings/match.h" #include "google/protobuf/test_util.h" #include "google/protobuf/test_util2.h" #include "google/protobuf/stubs/stl_util.h" @@ -1234,7 +1235,7 @@ std::string prefix = "." + template_descriptor->full_name() + "."; if (extension->has_type_name()) { std::string* type_name = extension->mutable_type_name(); - if (HasPrefixString(*type_name, prefix)) { + if (absl::StartsWith(*type_name, prefix)) { type_name->replace(0, prefix.size(), ".dynamic_extensions."); } }
diff --git a/src/google/protobuf/io/gzip_stream.h b/src/google/protobuf/io/gzip_stream.h index c7ef132..eec111c 100644 --- a/src/google/protobuf/io/gzip_stream.h +++ b/src/google/protobuf/io/gzip_stream.h
@@ -76,7 +76,7 @@ Format format = AUTO, int buffer_size = -1); GzipInputStream(const GzipInputStream&) = delete; GzipInputStream& operator=(const GzipInputStream&) = delete; - virtual ~GzipInputStream(); + ~GzipInputStream() override; // Return last error message or NULL if no error. inline const char* ZlibErrorMessage() const { return zcontext_.msg; } @@ -144,7 +144,7 @@ GzipOutputStream(const GzipOutputStream&) = delete; GzipOutputStream& operator=(const GzipOutputStream&) = delete; - virtual ~GzipOutputStream(); + ~GzipOutputStream() override; // Return last error message or NULL if no error. inline const char* ZlibErrorMessage() const { return zcontext_.msg; }
diff --git a/src/google/protobuf/io/printer.cc b/src/google/protobuf/io/printer.cc index c4d1847..99dc5bd 100644 --- a/src/google/protobuf/io/printer.cc +++ b/src/google/protobuf/io/printer.cc
@@ -48,7 +48,7 @@ #include "google/protobuf/stubs/common.h" #include "absl/strings/ascii.h" #include "absl/strings/escaping.h" -#include "google/protobuf/stubs/strutil.h" +#include "absl/strings/match.h" #include "absl/strings/str_cat.h" #include "google/protobuf/stubs/stringprintf.h" #include "absl/strings/string_view.h" @@ -129,6 +129,16 @@ } } +absl::string_view Printer::LookupVar(absl::string_view var) { + LookupResult result = LookupInFrameStack(var, absl::MakeSpan(var_lookups_)); + GOOGLE_CHECK(result.has_value()) << "could not find " << var; + auto* view = absl::get_if<absl::string_view>(&*result); + GOOGLE_CHECK(view != nullptr) << "could not find " << var + << "; found callback instead"; + + return *view; +} + bool Printer::Validate(bool cond, Printer::PrintOptions opts, absl::FunctionRef<std::string()> message) { if (!cond) { @@ -614,10 +624,12 @@ // // }; // - // in many cases. We *also* do this if a ; follows the substitution, + // in many cases. We *also* do this if a ; or , follows the substitution, // because this helps clang-format keep its head on in many cases. // Users that need to keep the semi can write $foo$/**/; - absl::ConsumePrefix(&format, ";"); + if (!absl::ConsumePrefix(&format, ";")) { + absl::ConsumePrefix(&format, ","); + } absl::ConsumePrefix(&format, "\n"); indent_ = original_indent + ConsumeIndentForLine(raw_string_indent_len, format);
diff --git a/src/google/protobuf/io/printer.h b/src/google/protobuf/io/printer.h index 3c096a4..176f484 100644 --- a/src/google/protobuf/io/printer.h +++ b/src/google/protobuf/io/printer.h
@@ -495,6 +495,13 @@ return absl::MakeCleanup([this] { var_lookups_.pop_back(); }); } + // Looks up a variable set with WithVars(). + // + // Will crash if: + // - `var` is not present in the lookup frame table. + // - `var` is a callback, rather than a string. + absl::string_view LookupVar(absl::string_view var); + // Pushes a new annotation lookup frame that stores `vars` by reference. // // Returns an RAII object that pops the lookup frame.
diff --git a/src/google/protobuf/lite_unittest.cc b/src/google/protobuf/lite_unittest.cc index 529e7bd..3b615b7 100644 --- a/src/google/protobuf/lite_unittest.cc +++ b/src/google/protobuf/lite_unittest.cc
@@ -39,7 +39,7 @@ #include "google/protobuf/map_lite_unittest.pb.h" #include "google/protobuf/unittest_lite.pb.h" #include <gtest/gtest.h> -#include "google/protobuf/stubs/strutil.h" +#include "absl/strings/match.h" #include "absl/strings/string_view.h" #include "google/protobuf/arena_test_util.h" #include "google/protobuf/io/coded_stream.h" @@ -1144,8 +1144,8 @@ TEST(Lite, DebugString) { protobuf_unittest::TestAllTypesLite message1, message2; - EXPECT_TRUE(HasPrefixString(message1.DebugString(), "MessageLite at 0x")); - EXPECT_TRUE(HasPrefixString(message2.DebugString(), "MessageLite at 0x")); + EXPECT_TRUE(absl::StartsWith(message1.DebugString(), "MessageLite at 0x")); + EXPECT_TRUE(absl::StartsWith(message2.DebugString(), "MessageLite at 0x")); // DebugString() and ShortDebugString() are the same for now. EXPECT_EQ(message1.DebugString(), message1.ShortDebugString());
diff --git a/src/google/protobuf/message_lite.cc b/src/google/protobuf/message_lite.cc index 7cae7be..defc815 100644 --- a/src/google/protobuf/message_lite.cc +++ b/src/google/protobuf/message_lite.cc
@@ -63,6 +63,10 @@ namespace google { namespace protobuf { +MessageLite::~MessageLite(){ +// Defined out of line to save code space +} + std::string MessageLite::InitializationErrorString() const { return "(cannot determine missing fields for lite message)"; }
diff --git a/src/google/protobuf/message_lite.h b/src/google/protobuf/message_lite.h index f4bca9c..92e5b73 100644 --- a/src/google/protobuf/message_lite.h +++ b/src/google/protobuf/message_lite.h
@@ -171,7 +171,7 @@ constexpr MessageLite() {} MessageLite(const MessageLite&) = delete; MessageLite& operator=(const MessageLite&) = delete; - virtual ~MessageLite() = default; + virtual ~MessageLite(); // Basic Operations ------------------------------------------------
diff --git a/src/google/protobuf/parse_context.h b/src/google/protobuf/parse_context.h index 3dbdf3e..12d51f5 100644 --- a/src/google/protobuf/parse_context.h +++ b/src/google/protobuf/parse_context.h
@@ -337,7 +337,7 @@ template <typename A> const char* AppendSize(const char* ptr, int size, const A& append) { - int chunk_size = buffer_end_ + kSlopBytes - ptr; + int chunk_size = static_cast<int>(buffer_end_ + kSlopBytes - ptr); do { GOOGLE_DCHECK(size > chunk_size); if (next_chunk_ == nullptr) return nullptr; @@ -351,7 +351,7 @@ ptr = Next(); if (ptr == nullptr) return nullptr; // passed the limit ptr += kSlopBytes; - chunk_size = buffer_end_ + kSlopBytes - ptr; + chunk_size = static_cast<int>(buffer_end_ + kSlopBytes - ptr); } while (size > chunk_size); append(ptr, size); return ptr + size; @@ -880,7 +880,7 @@ const char* EpsCopyInputStream::ReadPackedFixed(const char* ptr, int size, RepeatedField<T>* out) { GOOGLE_PROTOBUF_PARSER_ASSERT(ptr); - int nbytes = buffer_end_ + kSlopBytes - ptr; + int nbytes = static_cast<int>(buffer_end_ + kSlopBytes - ptr); while (size > nbytes) { int num = nbytes / sizeof(T); int old_entries = out->size(); @@ -898,7 +898,7 @@ ptr = Next(); if (ptr == nullptr) return nullptr; ptr += kSlopBytes - (nbytes - block_size); - nbytes = buffer_end_ + kSlopBytes - ptr; + nbytes = static_cast<int>(buffer_end_ + kSlopBytes - ptr); } int num = size / sizeof(T); int old_entries = out->size(); @@ -930,11 +930,11 @@ const char* EpsCopyInputStream::ReadPackedVarint(const char* ptr, Add add) { int size = ReadSize(&ptr); GOOGLE_PROTOBUF_PARSER_ASSERT(ptr); - int chunk_size = buffer_end_ - ptr; + int chunk_size = static_cast<int>(buffer_end_ - ptr); while (size > chunk_size) { ptr = ReadPackedVarintArray(ptr, buffer_end_, add); if (ptr == nullptr) return nullptr; - int overrun = ptr - buffer_end_; + int overrun = static_cast<int>(ptr - buffer_end_); GOOGLE_DCHECK(overrun >= 0 && overrun <= kSlopBytes); if (size - chunk_size <= kSlopBytes) { // The current buffer contains all the information needed, we don't need @@ -955,7 +955,7 @@ ptr = Next(); if (ptr == nullptr) return nullptr; ptr += overrun; - chunk_size = buffer_end_ - ptr; + chunk_size = static_cast<int>(buffer_end_ - ptr); } auto end = ptr + size; ptr = ReadPackedVarintArray(ptr, end, add);
diff --git a/src/google/protobuf/proto3_arena_unittest.cc b/src/google/protobuf/proto3_arena_unittest.cc index 175c6e9..0f55865 100644 --- a/src/google/protobuf/proto3_arena_unittest.cc +++ b/src/google/protobuf/proto3_arena_unittest.cc
@@ -38,7 +38,7 @@ #include "google/protobuf/arena.h" #include "google/protobuf/text_format.h" #include <gtest/gtest.h> -#include "google/protobuf/stubs/strutil.h" +#include "absl/strings/match.h" #include "google/protobuf/test_util.h" // Must be included last. @@ -296,7 +296,7 @@ for (int i = 0; i < d->field_count(); i++) { const FieldDescriptor* f = d->field(i); - if (HasPrefixString(f->name(), "singular")) { + if (absl::StartsWith(f->name(), "singular")) { EXPECT_FALSE(f->has_optional_keyword()) << f->full_name(); EXPECT_FALSE(f->has_presence()) << f->full_name(); EXPECT_FALSE(f->containing_oneof()) << f->full_name();
diff --git a/src/google/protobuf/stubs/common_unittest.cc b/src/google/protobuf/stubs/common_unittest.cc index eb43fd2..7c86204 100644 --- a/src/google/protobuf/stubs/common_unittest.cc +++ b/src/google/protobuf/stubs/common_unittest.cc
@@ -95,11 +95,14 @@ GOOGLE_LOG(ERROR ) << "An error."; std::string text = GetCapturedTestStderr(); - EXPECT_EQ( - "[libprotobuf INFO " __FILE__ ":" + SimpleItoa(line + 1) + "] A message.\n" - "[libprotobuf WARNING " __FILE__ ":" + SimpleItoa(line + 2) + "] A warning.\n" - "[libprotobuf ERROR " __FILE__ ":" + SimpleItoa(line + 3) + "] An error.\n", - text); + EXPECT_EQ(absl::StrCat("[libprotobuf INFO " __FILE__ ":", line + 1, + "] A message.\n" + "[libprotobuf WARNING " __FILE__ ":", + line + 2, + "] A warning.\n" + "[libprotobuf ERROR " __FILE__ ":", + line + 3, "] An error.\n"), + text); } TEST(LoggingTest, NullLogging) { @@ -128,12 +131,10 @@ EXPECT_TRUE(SetLogHandler(old_handler) == &CaptureLog); ASSERT_EQ(2, captured_messages_.size()); - EXPECT_EQ( - "2 " __FILE__ ":" + SimpleItoa(start_line + 1) + ": An error.", - captured_messages_[0]); - EXPECT_EQ( - "1 " __FILE__ ":" + SimpleItoa(start_line + 2) + ": A warning.", - captured_messages_[1]); + EXPECT_EQ(absl::StrCat("2 " __FILE__ ":", start_line + 1, ": An error."), + captured_messages_[0]); + EXPECT_EQ(absl::StrCat("1 " __FILE__ ":", start_line + 2, ": A warning."), + captured_messages_[1]); } TEST(LoggingTest, SilenceLogging) { @@ -154,12 +155,10 @@ EXPECT_TRUE(SetLogHandler(old_handler) == &CaptureLog); ASSERT_EQ(2, captured_messages_.size()); - EXPECT_EQ( - "0 " __FILE__ ":" + SimpleItoa(line1) + ": Visible1", - captured_messages_[0]); - EXPECT_EQ( - "0 " __FILE__ ":" + SimpleItoa(line2) + ": Visible2", - captured_messages_[1]); + EXPECT_EQ(absl::StrCat("0 " __FILE__ ":", line1, ": Visible1"), + captured_messages_[0]); + EXPECT_EQ(absl::StrCat("0 " __FILE__ ":", line2, ": Visible2"), + captured_messages_[1]); } class ClosureTest : public testing::Test {
diff --git a/src/google/protobuf/stubs/strutil.cc b/src/google/protobuf/stubs/strutil.cc index b6d2049..720c6fc 100644 --- a/src/google/protobuf/stubs/strutil.cc +++ b/src/google/protobuf/stubs/strutil.cc
@@ -63,75 +63,7 @@ namespace google { namespace protobuf { -// These are defined as macros on some platforms. #undef them so that we can -// redefine them. -#undef isxdigit -#undef isprint - -// The definitions of these in ctype.h change based on locale. Since our -// string manipulation is all in relation to the protocol buffer and C++ -// languages, we always want to use the C locale. So, we re-define these -// exactly as we want them. -inline bool isxdigit(char c) { - return ('0' <= c && c <= '9') || - ('a' <= c && c <= 'f') || - ('A' <= c && c <= 'F'); -} - -inline bool isprint(char c) { - return c >= 0x20 && c <= 0x7E; -} - -// ---------------------------------------------------------------------- -// ReplaceCharacters -// Replaces any occurrence of the character 'remove' (or the characters -// in 'remove') with the character 'replacewith'. -// ---------------------------------------------------------------------- -void ReplaceCharacters(std::string *s, const char *remove, char replacewith) { - const char *str_start = s->c_str(); - const char *str = str_start; - for (str = strpbrk(str, remove); - str != nullptr; - str = strpbrk(str + 1, remove)) { - (*s)[str - str_start] = replacewith; - } -} - -void StripWhitespace(std::string *str) { - int str_length = str->length(); - - // Strip off leading whitespace. - int first = 0; - while (first < str_length && absl::ascii_isspace(str->at(first))) { - ++first; - } - // If entire string is white space. - if (first == str_length) { - str->clear(); - return; - } - if (first > 0) { - str->erase(0, first); - str_length -= first; - } - - // Strip off trailing whitespace. - int last = str_length - 1; - while (last >= 0 && absl::ascii_isspace(str->at(last))) { - --last; - } - if (last != (str_length - 1) && last >= 0) { - str->erase(last + 1, std::string::npos); - } -} - -// ---------------------------------------------------------------------- -// StringReplace() -// Replace the "old" pattern with the "new" pattern in a string, -// and append the result to "res". If replace_all is false, -// it only replaces the first instance of "old." -// ---------------------------------------------------------------------- - +namespace { void StringReplace(const std::string &s, const std::string &oldsub, const std::string &newsub, bool replace_all, std::string *res) { @@ -153,6 +85,7 @@ } while (replace_all); res->append(s, start_pos, s.length() - start_pos); } +} // namespace // ---------------------------------------------------------------------- // StringReplace() @@ -171,91 +104,6 @@ } // ---------------------------------------------------------------------- -// SplitStringUsing() -// Split a string using a character delimiter. Append the components -// to 'result'. -// -// Note: For multi-character delimiters, this routine will split on *ANY* of -// the characters in the string, not the entire string as a single delimiter. -// ---------------------------------------------------------------------- -template <typename ITR> -static inline void SplitStringToIteratorUsing(absl::string_view full, - const char *delim, ITR &result) { - // Optimize the common case where delim is a single character. - if (delim[0] != '\0' && delim[1] == '\0') { - char c = delim[0]; - const char* p = full.data(); - const char* end = p + full.size(); - while (p != end) { - if (*p == c) { - ++p; - } else { - const char* start = p; - while (++p != end && *p != c); - *result++ = std::string(start, p - start); - } - } - return; - } - - std::string::size_type begin_index, end_index; - begin_index = full.find_first_not_of(delim); - while (begin_index != std::string::npos) { - end_index = full.find_first_of(delim, begin_index); - if (end_index == std::string::npos) { - *result++ = std::string(full.substr(begin_index)); - return; - } - *result++ = - std::string(full.substr(begin_index, (end_index - begin_index))); - begin_index = full.find_first_not_of(delim, end_index); - } -} - -void SplitStringUsing(absl::string_view full, const char *delim, - std::vector<std::string> *result) { - std::back_insert_iterator<std::vector<std::string> > it(*result); - SplitStringToIteratorUsing(full, delim, it); -} - -// Split a string using a character delimiter. Append the components -// to 'result'. If there are consecutive delimiters, this function -// will return corresponding empty strings. The string is split into -// at most the specified number of pieces greedily. This means that the -// last piece may possibly be split further. To split into as many pieces -// as possible, specify 0 as the number of pieces. -// -// If "full" is the empty string, yields an empty string as the only value. -// -// If "pieces" is negative for some reason, it returns the whole string -// ---------------------------------------------------------------------- -template <typename ITR> -static inline void SplitStringToIteratorAllowEmpty(absl::string_view full, - const char *delim, - int pieces, ITR &result) { - std::string::size_type begin_index, end_index; - begin_index = 0; - - for (int i = 0; (i < pieces-1) || (pieces == 0); i++) { - end_index = full.find_first_of(delim, begin_index); - if (end_index == std::string::npos) { - *result++ = std::string(full.substr(begin_index)); - return; - } - *result++ = - std::string(full.substr(begin_index, (end_index - begin_index))); - begin_index = end_index + 1; - } - *result++ = std::string(full.substr(begin_index)); -} - -void SplitStringAllowEmpty(absl::string_view full, const char *delim, - std::vector<std::string> *result) { - std::back_insert_iterator<std::vector<std::string> > it(*result); - SplitStringToIteratorAllowEmpty(full, delim, 0, it); -} - -// ---------------------------------------------------------------------- // strto32_adaptor() // strtou32_adaptor() // Implementation of strto[u]l replacements that have identical @@ -424,377 +272,8 @@ } // ---------------------------------------------------------------------- -// FastIntToBuffer() -// FastInt64ToBuffer() -// FastHexToBuffer() -// FastHex64ToBuffer() -// FastHex32ToBuffer() -// ---------------------------------------------------------------------- - -// Offset into buffer where FastInt64ToBuffer places the end of string -// null character. Also used by FastInt64ToBufferLeft. -static const int kFastInt64ToBufferOffset = 21; - -char *FastInt64ToBuffer(int64_t i, char* buffer) { - // We could collapse the positive and negative sections, but that - // would be slightly slower for positive numbers... - // 22 bytes is enough to store -2**64, -18446744073709551616. - char* p = buffer + kFastInt64ToBufferOffset; - *p-- = '\0'; - if (i >= 0) { - do { - *p-- = '0' + i % 10; - i /= 10; - } while (i > 0); - return p + 1; - } else { - // On different platforms, % and / have different behaviors for - // negative numbers, so we need to jump through hoops to make sure - // we don't divide negative numbers. - if (i > -10) { - i = -i; - *p-- = '0' + i; - *p = '-'; - return p; - } else { - // Make sure we aren't at MIN_INT, in which case we can't say i = -i - i = i + 10; - i = -i; - *p-- = '0' + i % 10; - // Undo what we did a moment ago - i = i / 10 + 1; - do { - *p-- = '0' + i % 10; - i /= 10; - } while (i > 0); - *p = '-'; - return p; - } - } -} - -// Offset into buffer where FastInt32ToBuffer places the end of string -// null character. Also used by FastInt32ToBufferLeft -static const int kFastInt32ToBufferOffset = 11; - -// Yes, this is a duplicate of FastInt64ToBuffer. But, we need this for the -// compiler to generate 32 bit arithmetic instructions. It's much faster, at -// least with 32 bit binaries. -char *FastInt32ToBuffer(int32_t i, char* buffer) { - // We could collapse the positive and negative sections, but that - // would be slightly slower for positive numbers... - // 12 bytes is enough to store -2**32, -4294967296. - char* p = buffer + kFastInt32ToBufferOffset; - *p-- = '\0'; - if (i >= 0) { - do { - *p-- = '0' + i % 10; - i /= 10; - } while (i > 0); - return p + 1; - } else { - // On different platforms, % and / have different behaviors for - // negative numbers, so we need to jump through hoops to make sure - // we don't divide negative numbers. - if (i > -10) { - i = -i; - *p-- = '0' + i; - *p = '-'; - return p; - } else { - // Make sure we aren't at MIN_INT, in which case we can't say i = -i - i = i + 10; - i = -i; - *p-- = '0' + i % 10; - // Undo what we did a moment ago - i = i / 10 + 1; - do { - *p-- = '0' + i % 10; - i /= 10; - } while (i > 0); - *p = '-'; - return p; - } - } -} - -char *FastHexToBuffer(int i, char* buffer) { - GOOGLE_CHECK(i >= 0) << "FastHexToBuffer() wants non-negative integers, not " << i; - - static const char *hexdigits = "0123456789abcdef"; - char *p = buffer + 21; - *p-- = '\0'; - do { - *p-- = hexdigits[i & 15]; // mod by 16 - i >>= 4; // divide by 16 - } while (i > 0); - return p + 1; -} - -char *InternalFastHexToBuffer(uint64_t value, char* buffer, int num_byte) { - static const char *hexdigits = "0123456789abcdef"; - buffer[num_byte] = '\0'; - for (int i = num_byte - 1; i >= 0; i--) { -#ifdef _M_X64 - // MSVC x64 platform has a bug optimizing the uint32(value) in the #else - // block. Given that the uint32 cast was to improve performance on 32-bit - // platforms, we use 64-bit '&' directly. - buffer[i] = hexdigits[value & 0xf]; -#else - buffer[i] = hexdigits[uint32_t(value) & 0xf]; -#endif - value >>= 4; - } - return buffer; -} - -char *FastHex64ToBuffer(uint64_t value, char* buffer) { - return InternalFastHexToBuffer(value, buffer, 16); -} - -char *FastHex32ToBuffer(uint32_t value, char* buffer) { - return InternalFastHexToBuffer(value, buffer, 8); -} - -// ---------------------------------------------------------------------- -// FastInt32ToBufferLeft() -// FastUInt32ToBufferLeft() -// FastInt64ToBufferLeft() -// FastUInt64ToBufferLeft() -// -// Like the Fast*ToBuffer() functions above, these are intended for speed. -// Unlike the Fast*ToBuffer() functions, however, these functions write -// their output to the beginning of the buffer (hence the name, as the -// output is left-aligned). The caller is responsible for ensuring that -// the buffer has enough space to hold the output. -// -// Returns a pointer to the end of the string (i.e. the null character -// terminating the string). -// ---------------------------------------------------------------------- - -static const char two_ASCII_digits[100][2] = { - {'0','0'}, {'0','1'}, {'0','2'}, {'0','3'}, {'0','4'}, - {'0','5'}, {'0','6'}, {'0','7'}, {'0','8'}, {'0','9'}, - {'1','0'}, {'1','1'}, {'1','2'}, {'1','3'}, {'1','4'}, - {'1','5'}, {'1','6'}, {'1','7'}, {'1','8'}, {'1','9'}, - {'2','0'}, {'2','1'}, {'2','2'}, {'2','3'}, {'2','4'}, - {'2','5'}, {'2','6'}, {'2','7'}, {'2','8'}, {'2','9'}, - {'3','0'}, {'3','1'}, {'3','2'}, {'3','3'}, {'3','4'}, - {'3','5'}, {'3','6'}, {'3','7'}, {'3','8'}, {'3','9'}, - {'4','0'}, {'4','1'}, {'4','2'}, {'4','3'}, {'4','4'}, - {'4','5'}, {'4','6'}, {'4','7'}, {'4','8'}, {'4','9'}, - {'5','0'}, {'5','1'}, {'5','2'}, {'5','3'}, {'5','4'}, - {'5','5'}, {'5','6'}, {'5','7'}, {'5','8'}, {'5','9'}, - {'6','0'}, {'6','1'}, {'6','2'}, {'6','3'}, {'6','4'}, - {'6','5'}, {'6','6'}, {'6','7'}, {'6','8'}, {'6','9'}, - {'7','0'}, {'7','1'}, {'7','2'}, {'7','3'}, {'7','4'}, - {'7','5'}, {'7','6'}, {'7','7'}, {'7','8'}, {'7','9'}, - {'8','0'}, {'8','1'}, {'8','2'}, {'8','3'}, {'8','4'}, - {'8','5'}, {'8','6'}, {'8','7'}, {'8','8'}, {'8','9'}, - {'9','0'}, {'9','1'}, {'9','2'}, {'9','3'}, {'9','4'}, - {'9','5'}, {'9','6'}, {'9','7'}, {'9','8'}, {'9','9'} -}; - -char* FastUInt32ToBufferLeft(uint32_t u, char* buffer) { - uint32_t digits; - const char *ASCII_digits = nullptr; - // The idea of this implementation is to trim the number of divides to as few - // as possible by using multiplication and subtraction rather than mod (%), - // and by outputting two digits at a time rather than one. - // The huge-number case is first, in the hopes that the compiler will output - // that case in one branch-free block of code, and only output conditional - // branches into it from below. - if (u >= 1000000000) { // >= 1,000,000,000 - digits = u / 100000000; // 100,000,000 - ASCII_digits = two_ASCII_digits[digits]; - buffer[0] = ASCII_digits[0]; - buffer[1] = ASCII_digits[1]; - buffer += 2; -sublt100_000_000: - u -= digits * 100000000; // 100,000,000 -lt100_000_000: - digits = u / 1000000; // 1,000,000 - ASCII_digits = two_ASCII_digits[digits]; - buffer[0] = ASCII_digits[0]; - buffer[1] = ASCII_digits[1]; - buffer += 2; -sublt1_000_000: - u -= digits * 1000000; // 1,000,000 -lt1_000_000: - digits = u / 10000; // 10,000 - ASCII_digits = two_ASCII_digits[digits]; - buffer[0] = ASCII_digits[0]; - buffer[1] = ASCII_digits[1]; - buffer += 2; -sublt10_000: - u -= digits * 10000; // 10,000 -lt10_000: - digits = u / 100; - ASCII_digits = two_ASCII_digits[digits]; - buffer[0] = ASCII_digits[0]; - buffer[1] = ASCII_digits[1]; - buffer += 2; -sublt100: - u -= digits * 100; -lt100: - digits = u; - ASCII_digits = two_ASCII_digits[digits]; - buffer[0] = ASCII_digits[0]; - buffer[1] = ASCII_digits[1]; - buffer += 2; -done: - *buffer = 0; - return buffer; - } - - if (u < 100) { - digits = u; - if (u >= 10) goto lt100; - *buffer++ = '0' + digits; - goto done; - } - if (u < 10000) { // 10,000 - if (u >= 1000) goto lt10_000; - digits = u / 100; - *buffer++ = '0' + digits; - goto sublt100; - } - if (u < 1000000) { // 1,000,000 - if (u >= 100000) goto lt1_000_000; - digits = u / 10000; // 10,000 - *buffer++ = '0' + digits; - goto sublt10_000; - } - if (u < 100000000) { // 100,000,000 - if (u >= 10000000) goto lt100_000_000; - digits = u / 1000000; // 1,000,000 - *buffer++ = '0' + digits; - goto sublt1_000_000; - } - // we already know that u < 1,000,000,000 - digits = u / 100000000; // 100,000,000 - *buffer++ = '0' + digits; - goto sublt100_000_000; -} - -char* FastInt32ToBufferLeft(int32_t i, char* buffer) { - uint32_t u = 0; - if (i < 0) { - *buffer++ = '-'; - u -= i; - } else { - u = i; - } - return FastUInt32ToBufferLeft(u, buffer); -} - -char* FastUInt64ToBufferLeft(uint64_t u64, char* buffer) { - int digits; - const char *ASCII_digits = nullptr; - - uint32_t u = static_cast<uint32_t>(u64); - if (u == u64) return FastUInt32ToBufferLeft(u, buffer); - - uint64_t top_11_digits = u64 / 1000000000; - buffer = FastUInt64ToBufferLeft(top_11_digits, buffer); - u = u64 - (top_11_digits * 1000000000); - - digits = u / 10000000; // 10,000,000 - GOOGLE_DCHECK_LT(digits, 100); - ASCII_digits = two_ASCII_digits[digits]; - buffer[0] = ASCII_digits[0]; - buffer[1] = ASCII_digits[1]; - buffer += 2; - u -= digits * 10000000; // 10,000,000 - digits = u / 100000; // 100,000 - ASCII_digits = two_ASCII_digits[digits]; - buffer[0] = ASCII_digits[0]; - buffer[1] = ASCII_digits[1]; - buffer += 2; - u -= digits * 100000; // 100,000 - digits = u / 1000; // 1,000 - ASCII_digits = two_ASCII_digits[digits]; - buffer[0] = ASCII_digits[0]; - buffer[1] = ASCII_digits[1]; - buffer += 2; - u -= digits * 1000; // 1,000 - digits = u / 10; - ASCII_digits = two_ASCII_digits[digits]; - buffer[0] = ASCII_digits[0]; - buffer[1] = ASCII_digits[1]; - buffer += 2; - u -= digits * 10; - digits = u; - *buffer++ = '0' + digits; - *buffer = 0; - return buffer; -} - -char* FastInt64ToBufferLeft(int64_t i, char* buffer) { - uint64_t u = 0; - if (i < 0) { - *buffer++ = '-'; - u -= i; - } else { - u = i; - } - return FastUInt64ToBufferLeft(u, buffer); -} - -// ---------------------------------------------------------------------- -// SimpleItoa() -// Description: converts an integer to a string. -// -// Return value: string -// ---------------------------------------------------------------------- - -std::string SimpleItoa(int i) { - char buffer[kFastToBufferSize]; - return (sizeof(i) == 4) ? - FastInt32ToBuffer(i, buffer) : - FastInt64ToBuffer(i, buffer); -} - -std::string SimpleItoa(unsigned int i) { - char buffer[kFastToBufferSize]; - return std::string(buffer, (sizeof(i) == 4) - ? FastUInt32ToBufferLeft(i, buffer) - : FastUInt64ToBufferLeft(i, buffer)); -} - -std::string SimpleItoa(long i) { - char buffer[kFastToBufferSize]; - return (sizeof(i) == 4) ? - FastInt32ToBuffer(i, buffer) : - FastInt64ToBuffer(i, buffer); -} - -std::string SimpleItoa(unsigned long i) { - char buffer[kFastToBufferSize]; - return std::string(buffer, (sizeof(i) == 4) - ? FastUInt32ToBufferLeft(i, buffer) - : FastUInt64ToBufferLeft(i, buffer)); -} - -std::string SimpleItoa(long long i) { - char buffer[kFastToBufferSize]; - return (sizeof(i) == 4) ? - FastInt32ToBuffer(i, buffer) : - FastInt64ToBuffer(i, buffer); -} - -std::string SimpleItoa(unsigned long long i) { - char buffer[kFastToBufferSize]; - return std::string(buffer, (sizeof(i) == 4) - ? FastUInt32ToBufferLeft(i, buffer) - : FastUInt64ToBufferLeft(i, buffer)); -} - -// ---------------------------------------------------------------------- // SimpleDtoa() // SimpleFtoa() -// DoubleToBuffer() -// FloatToBuffer() // We want to print the value without losing precision, but we also do // not want to print more digits than necessary. This turns out to be // trickier than it sounds. Numbers like 0.2 cannot be represented @@ -831,23 +310,18 @@ // implementation. // ---------------------------------------------------------------------- -std::string SimpleDtoa(double value) { - char buffer[kDoubleToBufferSize]; - return DoubleToBuffer(value, buffer); -} - -std::string SimpleFtoa(float value) { - char buffer[kFloatToBufferSize]; - return FloatToBuffer(value, buffer); -} +namespace { +// In practice, doubles should never need more than 24 bytes and floats +// should never need more than 14 (including null terminators), but we +// overestimate to be safe. +constexpr int kDoubleToBufferSize = 32; +constexpr int kFloatToBufferSize = 24; static inline bool IsValidFloatChar(char c) { - return ('0' <= c && c <= '9') || - c == 'e' || c == 'E' || - c == '+' || c == '-'; + return ('0' <= c && c <= '9') || c == 'e' || c == 'E' || c == '+' || c == '-'; } -void DelocalizeRadix(char* buffer) { +void DelocalizeRadix(char *buffer) { // Fast check: if the buffer has a normal decimal point, assume no // translation is needed. if (strchr(buffer, '.') != nullptr) return; @@ -868,12 +342,52 @@ if (!IsValidFloatChar(*buffer) && *buffer != '\0') { // It appears the radix was a multi-byte character. We need to remove the // extra bytes. - char* target = buffer; - do { ++buffer; } while (!IsValidFloatChar(*buffer) && *buffer != '\0'); + char *target = buffer; + do { + ++buffer; + } while (!IsValidFloatChar(*buffer) && *buffer != '\0'); memmove(target, buffer, strlen(buffer) + 1); } } +char *FloatToBuffer(float value, char *buffer) { + // FLT_DIG is 6 for IEEE-754 floats, which are used on almost all + // platforms these days. Just in case some system exists where FLT_DIG + // is significantly larger -- and risks overflowing our buffer -- we have + // this assert. + static_assert(FLT_DIG < 10, "FLT_DIG_is_too_big"); + + if (value == std::numeric_limits<double>::infinity()) { + strcpy(buffer, "inf"); + return buffer; + } else if (value == -std::numeric_limits<double>::infinity()) { + strcpy(buffer, "-inf"); + return buffer; + } else if (std::isnan(value)) { + strcpy(buffer, "nan"); + return buffer; + } + + int snprintf_result = + snprintf(buffer, kFloatToBufferSize, "%.*g", FLT_DIG, value); + + // The snprintf should never overflow because the buffer is significantly + // larger than the precision we asked for. + GOOGLE_DCHECK(snprintf_result > 0 && snprintf_result < kFloatToBufferSize); + + float parsed_value; + if (!safe_strtof(buffer, &parsed_value) || parsed_value != value) { + snprintf_result = + snprintf(buffer, kFloatToBufferSize, "%.*g", FLT_DIG + 3, value); + + // Should never overflow; see above. + GOOGLE_DCHECK(snprintf_result > 0 && snprintf_result < kFloatToBufferSize); + } + + DelocalizeRadix(buffer); + return buffer; +} + char* DoubleToBuffer(double value, char* buffer) { // DBL_DIG is 15 for IEEE-754 doubles, which are used on almost all // platforms these days. Just in case some system exists where DBL_DIG @@ -917,6 +431,17 @@ DelocalizeRadix(buffer); return buffer; } +} // namespace + +std::string SimpleDtoa(double value) { + char buffer[kDoubleToBufferSize]; + return DoubleToBuffer(value, buffer); +} + +std::string SimpleFtoa(float value) { + char buffer[kFloatToBufferSize]; + return FloatToBuffer(value, buffer); +} static int memcasecmp(const char *s1, const char *s2, size_t len) { const unsigned char *us1 = reinterpret_cast<const unsigned char *>(s1); @@ -994,72 +519,6 @@ return safe_uint_internal(str, value); } -char* FloatToBuffer(float value, char* buffer) { - // FLT_DIG is 6 for IEEE-754 floats, which are used on almost all - // platforms these days. Just in case some system exists where FLT_DIG - // is significantly larger -- and risks overflowing our buffer -- we have - // this assert. - static_assert(FLT_DIG < 10, "FLT_DIG_is_too_big"); - - if (value == std::numeric_limits<double>::infinity()) { - strcpy(buffer, "inf"); - return buffer; - } else if (value == -std::numeric_limits<double>::infinity()) { - strcpy(buffer, "-inf"); - return buffer; - } else if (std::isnan(value)) { - strcpy(buffer, "nan"); - return buffer; - } - - int snprintf_result = - snprintf(buffer, kFloatToBufferSize, "%.*g", FLT_DIG, value); - - // The snprintf should never overflow because the buffer is significantly - // larger than the precision we asked for. - GOOGLE_DCHECK(snprintf_result > 0 && snprintf_result < kFloatToBufferSize); - - float parsed_value; - if (!safe_strtof(buffer, &parsed_value) || parsed_value != value) { - snprintf_result = - snprintf(buffer, kFloatToBufferSize, "%.*g", FLT_DIG + 3, value); - - // Should never overflow; see above. - GOOGLE_DCHECK(snprintf_result > 0 && snprintf_result < kFloatToBufferSize); - } - - DelocalizeRadix(buffer); - return buffer; -} - -int GlobalReplaceSubstring(const std::string &substring, - const std::string &replacement, std::string *s) { - GOOGLE_CHECK(s != nullptr); - if (s->empty() || substring.empty()) - return 0; - std::string tmp; - int num_replacements = 0; - int pos = 0; - for (absl::string_view::size_type match_pos = - s->find(substring.data(), pos, substring.length()); - match_pos != std::string::npos; pos = match_pos + substring.length(), - match_pos = s->find(substring.data(), pos, - substring.length())) { - ++num_replacements; - // Append the original content before the match. - tmp.append(*s, pos, match_pos - pos); - // Append the replacement for the match. - tmp.append(replacement.begin(), replacement.end()); - } - // Append the content after the last match. If no replacements were made, the - // original string is left untouched. - if (num_replacements > 0) { - tmp.append(*s, pos, s->length() - pos); - s->swap(tmp); - } - return num_replacements; -} - namespace { int CalculateBase64EscapedLen(int input_len, bool do_padding) { // Base64 encodes three bytes of input at a time. If the input is not
diff --git a/src/google/protobuf/stubs/strutil.h b/src/google/protobuf/stubs/strutil.h index 2aa522d..1e64d7b 100644 --- a/src/google/protobuf/stubs/strutil.h +++ b/src/google/protobuf/stubs/strutil.h
@@ -68,99 +68,6 @@ } // ---------------------------------------------------------------------- -// HasPrefixString() -// Check if a string begins with a given prefix. -// StripPrefixString() -// Given a string and a putative prefix, returns the string minus the -// prefix string if the prefix matches, otherwise the original -// string. -// ---------------------------------------------------------------------- -inline bool HasPrefixString(absl::string_view str, absl::string_view prefix) { - return str.size() >= prefix.size() && - memcmp(str.data(), prefix.data(), prefix.size()) == 0; -} - -inline std::string StripPrefixString(const std::string& str, - const std::string& prefix) { - if (HasPrefixString(str, prefix)) { - return str.substr(prefix.size()); - } else { - return str; - } -} - -// ---------------------------------------------------------------------- -// HasSuffixString() -// Return true if str ends in suffix. -// StripSuffixString() -// Given a string and a putative suffix, returns the string minus the -// suffix string if the suffix matches, otherwise the original -// string. -// ---------------------------------------------------------------------- -inline bool HasSuffixString(absl::string_view str, absl::string_view suffix) { - return str.size() >= suffix.size() && - memcmp(str.data() + str.size() - suffix.size(), suffix.data(), - suffix.size()) == 0; -} - -inline std::string StripSuffixString(const std::string& str, - const std::string& suffix) { - if (HasSuffixString(str, suffix)) { - return str.substr(0, str.size() - suffix.size()); - } else { - return str; - } -} - -// ---------------------------------------------------------------------- -// ReplaceCharacters -// Replaces any occurrence of the character 'remove' (or the characters -// in 'remove') with the character 'replacewith'. -// Good for keeping html characters or protocol characters (\t) out -// of places where they might cause a problem. -// StripWhitespace -// Removes whitespaces from both ends of the given string. -// ---------------------------------------------------------------------- -PROTOBUF_EXPORT void ReplaceCharacters(std::string* s, const char* remove, - char replacewith); - -PROTOBUF_EXPORT void StripWhitespace(std::string* s); - -// ---------------------------------------------------------------------- -// LowerString() -// UpperString() -// ToUpper() -// Convert the characters in "s" to lowercase or uppercase. ASCII-only: -// these functions intentionally ignore locale because they are applied to -// identifiers used in the Protocol Buffer language, not to natural-language -// strings. -// ---------------------------------------------------------------------- - -inline void LowerString(std::string* s) { - std::string::iterator end = s->end(); - for (std::string::iterator i = s->begin(); i != end; ++i) { - // tolower() changes based on locale. We don't want this! - if ('A' <= *i && *i <= 'Z') *i += 'a' - 'A'; - } -} - -inline void UpperString(std::string* s) { - std::string::iterator end = s->end(); - for (std::string::iterator i = s->begin(); i != end; ++i) { - // toupper() changes based on locale. We don't want this! - if ('a' <= *i && *i <= 'z') *i += 'A' - 'a'; - } -} - -inline void ToUpper(std::string* s) { UpperString(s); } - -inline std::string ToUpper(const std::string& s) { - std::string out = s; - UpperString(&out); - return out; -} - -// ---------------------------------------------------------------------- // StringReplace() // Give me a string and two patterns "old" and "new", and I replace // the first instance of "old" in the string with "new", if it @@ -273,134 +180,19 @@ } // ---------------------------------------------------------------------- -// FastIntToBuffer() -// FastHexToBuffer() -// FastHex64ToBuffer() -// FastHex32ToBuffer() -// FastTimeToBuffer() -// These are intended for speed. FastIntToBuffer() assumes the -// integer is non-negative. FastHexToBuffer() puts output in -// hex rather than decimal. FastTimeToBuffer() puts the output -// into RFC822 format. -// -// FastHex64ToBuffer() puts a 64-bit unsigned value in hex-format, -// padded to exactly 16 bytes (plus one byte for '\0') -// -// FastHex32ToBuffer() puts a 32-bit unsigned value in hex-format, -// padded to exactly 8 bytes (plus one byte for '\0') -// -// All functions take the output buffer as an arg. -// They all return a pointer to the beginning of the output, -// which may not be the beginning of the input buffer. -// ---------------------------------------------------------------------- - -// Suggested buffer size for FastToBuffer functions. Also works with -// DoubleToBuffer() and FloatToBuffer(). -static const int kFastToBufferSize = 32; - -PROTOBUF_EXPORT char* FastInt32ToBuffer(int32_t i, char* buffer); -PROTOBUF_EXPORT char* FastInt64ToBuffer(int64_t i, char* buffer); -char* FastUInt32ToBuffer(uint32_t i, char* buffer); // inline below -char* FastUInt64ToBuffer(uint64_t i, char* buffer); // inline below -PROTOBUF_EXPORT char* FastHexToBuffer(int i, char* buffer); -PROTOBUF_EXPORT char* FastHex64ToBuffer(uint64_t i, char* buffer); -PROTOBUF_EXPORT char* FastHex32ToBuffer(uint32_t i, char* buffer); - -// at least 22 bytes long -inline char* FastIntToBuffer(int i, char* buffer) { - return (sizeof(i) == 4 ? - FastInt32ToBuffer(i, buffer) : FastInt64ToBuffer(i, buffer)); -} -inline char* FastUIntToBuffer(unsigned int i, char* buffer) { - return (sizeof(i) == 4 ? - FastUInt32ToBuffer(i, buffer) : FastUInt64ToBuffer(i, buffer)); -} -inline char* FastLongToBuffer(long i, char* buffer) { - return (sizeof(i) == 4 ? - FastInt32ToBuffer(i, buffer) : FastInt64ToBuffer(i, buffer)); -} -inline char* FastULongToBuffer(unsigned long i, char* buffer) { - return (sizeof(i) == 4 ? - FastUInt32ToBuffer(i, buffer) : FastUInt64ToBuffer(i, buffer)); -} - -// ---------------------------------------------------------------------- -// FastInt32ToBufferLeft() -// FastUInt32ToBufferLeft() -// FastInt64ToBufferLeft() -// FastUInt64ToBufferLeft() -// -// Like the Fast*ToBuffer() functions above, these are intended for speed. -// Unlike the Fast*ToBuffer() functions, however, these functions write -// their output to the beginning of the buffer (hence the name, as the -// output is left-aligned). The caller is responsible for ensuring that -// the buffer has enough space to hold the output. -// -// Returns a pointer to the end of the string (i.e. the null character -// terminating the string). -// ---------------------------------------------------------------------- - -PROTOBUF_EXPORT char* FastInt32ToBufferLeft(int32_t i, char* buffer); -PROTOBUF_EXPORT char* FastUInt32ToBufferLeft(uint32_t i, char* buffer); -PROTOBUF_EXPORT char* FastInt64ToBufferLeft(int64_t i, char* buffer); -PROTOBUF_EXPORT char* FastUInt64ToBufferLeft(uint64_t i, char* buffer); - -// Just define these in terms of the above. -inline char* FastUInt32ToBuffer(uint32_t i, char* buffer) { - FastUInt32ToBufferLeft(i, buffer); - return buffer; -} -inline char* FastUInt64ToBuffer(uint64_t i, char* buffer) { - FastUInt64ToBufferLeft(i, buffer); - return buffer; -} - -inline std::string SimpleBtoa(bool value) { return value ? "true" : "false"; } - -// ---------------------------------------------------------------------- -// SimpleItoa() -// Description: converts an integer to a string. -// -// Return value: string -// ---------------------------------------------------------------------- -PROTOBUF_EXPORT std::string SimpleItoa(int i); -PROTOBUF_EXPORT std::string SimpleItoa(unsigned int i); -PROTOBUF_EXPORT std::string SimpleItoa(long i); -PROTOBUF_EXPORT std::string SimpleItoa(unsigned long i); -PROTOBUF_EXPORT std::string SimpleItoa(long long i); -PROTOBUF_EXPORT std::string SimpleItoa(unsigned long long i); - -// ---------------------------------------------------------------------- // SimpleDtoa() // SimpleFtoa() -// DoubleToBuffer() -// FloatToBuffer() // Description: converts a double or float to a string which, if // passed to NoLocaleStrtod(), will produce the exact same original double // (except in case of NaN; all NaNs are considered the same value). // We try to keep the string short but it's not guaranteed to be as // short as possible. // -// DoubleToBuffer() and FloatToBuffer() write the text to the given -// buffer and return it. The buffer must be at least -// kDoubleToBufferSize bytes for doubles and kFloatToBufferSize -// bytes for floats. kFastToBufferSize is also guaranteed to be large -// enough to hold either. -// // Return value: string // ---------------------------------------------------------------------- PROTOBUF_EXPORT std::string SimpleDtoa(double value); PROTOBUF_EXPORT std::string SimpleFtoa(float value); -PROTOBUF_EXPORT char* DoubleToBuffer(double i, char* buffer); -PROTOBUF_EXPORT char* FloatToBuffer(float i, char* buffer); - -// In practice, doubles should never need more than 24 bytes and floats -// should never need more than 14 (including null terminators), but we -// overestimate to be safe. -static const int kDoubleToBufferSize = 32; -static const int kFloatToBufferSize = 24; - namespace strings { using Hex = absl::Hex; @@ -413,17 +205,6 @@ // ---------------------------------------------------------------------- PROTOBUF_EXPORT std::string ToHex(uint64_t num); -// ---------------------------------------------------------------------- -// GlobalReplaceSubstring() -// Replaces all instances of a substring in a string. Does nothing -// if 'substring' is empty. Returns the number of replacements. -// -// NOTE: The string pieces must not overlap s. -// ---------------------------------------------------------------------- -PROTOBUF_EXPORT int GlobalReplaceSubstring(const std::string& substring, - const std::string& replacement, - std::string* s); - namespace strings { // Encode src into dest web-safely with padding. PROTOBUF_EXPORT void WebSafeBase64EscapeWithPadding(absl::string_view src, @@ -452,15 +233,6 @@ // ---------------------------------------------------------------------- PROTOBUF_EXPORT int UTF8FirstLetterNumBytes(const char* src, int len); -namespace strings { -inline bool EndsWith(absl::string_view text, absl::string_view suffix) { - return suffix.empty() || - (text.size() >= suffix.size() && - memcmp(text.data() + (text.size() - suffix.size()), suffix.data(), - suffix.size()) == 0); -} -} // namespace strings - namespace internal { // A locale-independent version of the standard strtod(), which always
diff --git a/src/google/protobuf/stubs/strutil_unittest.cc b/src/google/protobuf/stubs/strutil_unittest.cc index d657579..71e60e6 100644 --- a/src/google/protobuf/stubs/strutil_unittest.cc +++ b/src/google/protobuf/stubs/strutil_unittest.cc
@@ -74,62 +74,6 @@ setlocale(LC_NUMERIC, old_locale.c_str()); } -class ReplaceChars - : public ::testing::TestWithParam< - std::tuple<std::string, std::string, const char*, char>> {}; - -TEST_P(ReplaceChars, ReplacesAllOccurencesOfAnyCharInReplaceWithAReplaceChar) { - std::string expected = std::get<0>(GetParam()); - std::string string_to_replace_in = std::get<1>(GetParam()); - const char* what_to_replace = std::get<2>(GetParam()); - char replacement = std::get<3>(GetParam()); - ReplaceCharacters(&string_to_replace_in, what_to_replace, replacement); - ASSERT_EQ(expected, string_to_replace_in); -} - -INSTANTIATE_TEST_CASE_P( - Replace, ReplaceChars, - ::testing::Values( - std::make_tuple("", "", "", '_'), // empty string should remain empty - std::make_tuple(" ", " ", "", '_'), // no replacement string - std::make_tuple(" ", " ", "_-abcedf", - '*'), // replacement character not in string - std::make_tuple("replace", "Replace", "R", - 'r'), // replace one character - std::make_tuple("not_spaces__", "not\nspaces\t ", " \t\r\n", - '_'), // replace some special characters - std::make_tuple("c++", "cxx", "x", - '+'), // same character multiple times - std::make_tuple("qvvvvvng v T", "queueing a T", "aeiou", - 'v'))); // replace all voewls - -class StripWs - : public ::testing::TestWithParam<std::tuple<std::string, std::string>> {}; - -TEST_P(StripWs, AlwaysStripsLeadingAndTrailingWhitespace) { - std::string expected = std::get<0>(GetParam()); - std::string string_to_strip = std::get<1>(GetParam()); - StripWhitespace(&string_to_strip); - ASSERT_EQ(expected, string_to_strip); -} - -INSTANTIATE_TEST_CASE_P( - Strip, StripWs, - ::testing::Values( - std::make_tuple("", ""), // empty string should remain empty - std::make_tuple("", " "), // only ws should become empty - std::make_tuple("no whitespace", - " no whitespace"), // leading ws removed - std::make_tuple("no whitespace", - "no whitespace "), // trailing ws removed - std::make_tuple("no whitespace", - " no whitespace "), // same nb. of leading and trailing - std::make_tuple( - "no whitespace", - " no whitespace "), // different nb. of leading/trailing - std::make_tuple("no whitespace", - " no whitespace "))); // more trailing than leading - } // anonymous namespace } // namespace protobuf } // namespace google
diff --git a/src/google/protobuf/testing/googletest.cc b/src/google/protobuf/testing/googletest.cc index 350f9a9..5f6a4fb 100644 --- a/src/google/protobuf/testing/googletest.cc +++ b/src/google/protobuf/testing/googletest.cc
@@ -38,6 +38,7 @@ #include <sys/stat.h> #include <sys/types.h> +#include "absl/strings/match.h" #include "absl/strings/str_replace.h" #include "google/protobuf/io/io_win32.h" #include "google/protobuf/stubs/strutil.h" @@ -147,7 +148,7 @@ } // On Win32, tmpnam() returns a file prefixed with '\', but which is supposed // to be used in the current working directory. WTF? - if (HasPrefixString(result, "\\")) { + if (absl::StartsWith(result, "\\")) { result.erase(0, 1); } // The Win32 API accepts forward slashes as a path delimiter as long as the
diff --git a/src/google/protobuf/util/internal/datapiece.cc b/src/google/protobuf/util/internal/datapiece.cc index 5148329..7daed3f 100644 --- a/src/google/protobuf/util/internal/datapiece.cc +++ b/src/google/protobuf/util/internal/datapiece.cc
@@ -43,6 +43,7 @@ #include "absl/strings/str_cat.h" #include "google/protobuf/util/internal/utility.h" #include "google/protobuf/stubs/strutil.h" +#include "absl/strings/match.h" #include "google/protobuf/stubs/mathutil.h" namespace google { @@ -263,7 +264,7 @@ case TYPE_FLOAT: return FloatAsString(float_); case TYPE_BOOL: - return SimpleBtoa(bool_); + return bool_ ? "true" : "false"; case TYPE_STRING: return absl::StrCat("\"", str_, "\""); case TYPE_BYTES: { @@ -397,7 +398,7 @@ absl::WebSafeBase64Escape(*dest, &encoded); // Remove trailing padding '=' characters before comparison. absl::string_view src_no_padding = absl::string_view(src).substr( - 0, HasSuffixString(src, "=") ? src.find_last_not_of('=') + 1 + 0, absl::EndsWith(src, "=") ? src.find_last_not_of('=') + 1 : src.length()); return encoded == src_no_padding; } @@ -409,7 +410,7 @@ std::string encoded; strings::LegacyBase64EscapeWithoutPadding(*dest, &encoded); absl::string_view src_no_padding = absl::string_view(src).substr( - 0, HasSuffixString(src, "=") ? src.find_last_not_of('=') + 1 + 0, absl::EndsWith(src, "=") ? src.find_last_not_of('=') + 1 : src.length()); return encoded == src_no_padding; }
diff --git a/src/google/protobuf/util/internal/field_mask_utility.cc b/src/google/protobuf/util/internal/field_mask_utility.cc index e0ffe13..5cdc29d 100644 --- a/src/google/protobuf/util/internal/field_mask_utility.cc +++ b/src/google/protobuf/util/internal/field_mask_utility.cc
@@ -31,7 +31,7 @@ #include "google/protobuf/util/internal/field_mask_utility.h" #include "absl/status/status.h" -#include "google/protobuf/stubs/strutil.h" +#include "absl/strings/match.h" #include "absl/strings/str_cat.h" #include "google/protobuf/util/internal/utility.h" #include "google/protobuf/stubs/status_macros.h" @@ -56,7 +56,7 @@ return std::string(prefix); } // If the segment is a map key, appends it to the prefix without the ".". - if (HasPrefixString(segment, "[\"")) { + if (absl::StartsWith(segment, "[\"")) { return absl::StrCat(prefix, segment); } return absl::StrCat(prefix, ".", segment);
diff --git a/src/google/protobuf/util/internal/json_stream_parser.cc b/src/google/protobuf/util/internal/json_stream_parser.cc index eccedb9..c294009 100644 --- a/src/google/protobuf/util/internal/json_stream_parser.cc +++ b/src/google/protobuf/util/internal/json_stream_parser.cc
@@ -43,6 +43,7 @@ #include "absl/status/status.h" #include "absl/strings/ascii.h" #include "absl/strings/escaping.h" +#include "absl/strings/match.h" #include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" #include "google/protobuf/util/internal/object_writer.h" @@ -966,15 +967,15 @@ return BEGIN_NUMBER; } if (size >= kKeywordTrue.length() && - HasPrefixString(data_view, kKeywordTrue)) { + absl::StartsWith(data_view, kKeywordTrue)) { return BEGIN_TRUE; } if (size >= kKeywordFalse.length() && - HasPrefixString(data_view, kKeywordFalse)) { + absl::StartsWith(data_view, kKeywordFalse)) { return BEGIN_FALSE; } if (size >= kKeywordNull.length() && - HasPrefixString(data_view, kKeywordNull)) { + absl::StartsWith(data_view, kKeywordNull)) { return BEGIN_NULL; } if (*data == '{') return BEGIN_OBJECT;
diff --git a/src/google/protobuf/util/internal/protostream_objectwriter.cc b/src/google/protobuf/util/internal/protostream_objectwriter.cc index 677647e..2c4d5ef 100644 --- a/src/google/protobuf/util/internal/protostream_objectwriter.cc +++ b/src/google/protobuf/util/internal/protostream_objectwriter.cc
@@ -41,6 +41,7 @@ #include "absl/base/call_once.h" #include "absl/status/status.h" #include "absl/status/statusor.h" +#include "absl/strings/match.h" #include "absl/strings/str_cat.h" #include "absl/strings/strip.h" #include "absl/time/time.h" @@ -1048,7 +1049,7 @@ absl::string_view value(data.str()); int timezone_offset_seconds = 0; - if (HasSuffixString(value, "Z")) { + if (absl::EndsWith(value, "Z")) { value = value.substr(0, value.size() - 1); } else { size_t pos = value.find_last_of("+-"); @@ -1123,13 +1124,13 @@ absl::string_view value(data.str()); - if (!HasSuffixString(value, "s")) { + if (!absl::EndsWith(value, "s")) { return absl::InvalidArgumentError( "Illegal duration format; duration must end with 's'"); } value = value.substr(0, value.size() - 1); int sign = 1; - if (HasPrefixString(value, "-")) { + if (absl::StartsWith(value, "-")) { sign = -1; value = value.substr(1); }
diff --git a/src/google/protobuf/util/internal/utility.cc b/src/google/protobuf/util/internal/utility.cc index f8054ca..c2488e8 100644 --- a/src/google/protobuf/util/internal/utility.cc +++ b/src/google/protobuf/util/internal/utility.cc
@@ -45,6 +45,7 @@ #include "google/protobuf/stubs/strutil.h" #include "absl/container/flat_hash_set.h" #include "absl/strings/ascii.h" +#include "absl/strings/match.h" #include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" #include "google/protobuf/util/internal/constants.h"
diff --git a/src/google/protobuf/util/json_util.cc b/src/google/protobuf/util/json_util.cc index 8df4733..2942eeb 100644 --- a/src/google/protobuf/util/json_util.cc +++ b/src/google/protobuf/util/json_util.cc
@@ -32,6 +32,7 @@ #include "absl/base/call_once.h" #include "absl/status/status.h" +#include "absl/strings/ascii.h" #include "google/protobuf/stubs/bytestream.h" #include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" @@ -141,7 +142,7 @@ std::string GetLocString(const converter::LocationTrackerInterface& loc) { std::string loc_string = loc.ToString(); - StripWhitespace(&loc_string); + absl::StripAsciiWhitespace(&loc_string); if (!loc_string.empty()) { loc_string = absl::StrCat("(", loc_string, ")"); }
diff --git a/src/google/protobuf/util/json_util_test.cc b/src/google/protobuf/util/json_util_test.cc index 3f18431..3b582c4 100644 --- a/src/google/protobuf/util/json_util_test.cc +++ b/src/google/protobuf/util/json_util_test.cc
@@ -509,6 +509,32 @@ IsOkAndHolds("[0.99000000953674316,0.87999999523162842]")); } +TEST_P(JsonTest, FloatMinMaxValue) { + // 3.4028235e38 is FLT_MAX to 8-significant-digits. The final digit (5) + // is rounded up; that means that when parsing this as a 64-bit FP number, + // the value ends up higher than FLT_MAX. We still want to accept it though, + // as a reasonable representation of FLT_MAX. + auto m = ToProto<TestMessage>(R"json( + { + "repeatedFloatValue": [3.4028235e38, -3.4028235e38], + } + )json"); + ASSERT_OK(m); + EXPECT_THAT(m->repeated_float_value(), ElementsAre(FLT_MAX, -FLT_MAX)); +} + +TEST_P(JsonTest, FloatOutOfRange) { + // Check that the slightly-lenient parsing demonstrated in FloatMinMaxValue + // doesn't mean we allow all values. The value being parsed differs only + // in the least significant (represented) digit. + auto m = ToProto<TestMessage>(R"json( + { + "floatValue": 3.4028236e38 + } + )json"); + EXPECT_THAT(m, StatusIs(absl::StatusCode::kInvalidArgument)); +} + TEST_P(JsonTest, ParseLegacySingleRepeatedField) { auto m = ToProto<TestMessage>(R"json({ "repeatedInt32Value": 1997,
diff --git a/src/google/protobuf/util/message_differencer.cc b/src/google/protobuf/util/message_differencer.cc index 51b2bea..ba4db19 100644 --- a/src/google/protobuf/util/message_differencer.cc +++ b/src/google/protobuf/util/message_differencer.cc
@@ -57,6 +57,7 @@ #include "google/protobuf/stubs/strutil.h" #include "absl/container/fixed_array.h" #include "absl/strings/escaping.h" +#include "absl/strings/match.h" #include "absl/strings/str_cat.h" #include "google/protobuf/stubs/stringprintf.h" #include "google/protobuf/util/field_comparator.h"
diff --git a/src/google/protobuf/wire_format_unittest.inc b/src/google/protobuf/wire_format_unittest.inc index 5653be7..6224ae7 100644 --- a/src/google/protobuf/wire_format_unittest.inc +++ b/src/google/protobuf/wire_format_unittest.inc
@@ -45,7 +45,7 @@ #include <gtest/gtest.h> #include "absl/base/casts.h" #include "google/protobuf/stubs/logging.h" -#include "google/protobuf/stubs/strutil.h" +#include "absl/strings/match.h" #include "google/protobuf/dynamic_message.h" #include "google/protobuf/test_util2.h" #include "google/protobuf/stubs/stl_util.h" @@ -1560,7 +1560,7 @@ #ifdef GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED ASSERT_EQ(1, errors.size()); EXPECT_TRUE( - HasPrefixString(errors[0], + absl::StartsWith(errors[0], "String field contains invalid UTF-8 data when " "serializing a protocol buffer. Use the " "'bytes' type if you intend to send raw bytes."));