diff options
| author | heretic <[email protected]> | 2022-06-14 13:29:31 +0300 |
|---|---|---|
| committer | heretic <[email protected]> | 2022-06-14 13:29:31 +0300 |
| commit | 16f8be4f481c275c34795233c18f8d078382fcb3 (patch) | |
| tree | 2363f1306ce2e17e72c0a48614256acd046990e6 /contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_helpers.cc | |
| parent | 647dc68b78e469e5ab416e9b62885c9846fd511d (diff) | |
Update protobuf to 3.18.1
ref:4846abb21711ea0dc148d4c5df7b5edd3d1bdc69
Diffstat (limited to 'contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_helpers.cc')
| -rw-r--r-- | contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_helpers.cc | 75 |
1 files changed, 34 insertions, 41 deletions
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_helpers.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_helpers.cc index 0f9660d2374..736b73a3ea9 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_helpers.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_helpers.cc @@ -169,30 +169,6 @@ static std::unordered_set<TProtoStringType>* MakeKeywordsMap() { static std::unordered_set<TProtoStringType>& kKeywords = *MakeKeywordsMap(); -// Encode [0..63] as 'A'-'Z', 'a'-'z', '0'-'9', '_' -char Base63Char(int value) { - GOOGLE_CHECK_GE(value, 0); - if (value < 26) return 'A' + value; - value -= 26; - if (value < 26) return 'a' + value; - value -= 26; - if (value < 10) return '0' + value; - GOOGLE_CHECK_EQ(value, 10); - return '_'; -} - -// Given a c identifier has 63 legal characters we can't implement base64 -// encoding. So we return the k least significant "digits" in base 63. -template <typename I> -TProtoStringType Base63(I n, int k) { - TProtoStringType res; - while (k-- > 0) { - res += Base63Char(static_cast<int>(n % 63)); - n /= 63; - } - return res; -} - TProtoStringType IntTypeName(const Options& options, const TProtoStringType& type) { if (options.opensource_runtime) { return "::PROTOBUF_NAMESPACE_ID::" + type; @@ -400,7 +376,7 @@ TProtoStringType Namespace(const FileDescriptor* d, const Options& options) { ret = StringReplace(ret, "::google::" "protobuf", - "PROTOBUF_NAMESPACE_ID", false); + "::PROTOBUF_NAMESPACE_ID", false); } return ret; } @@ -454,9 +430,14 @@ TProtoStringType FileDllExport(const FileDescriptor* file, const Options& option TProtoStringType SuperClassName(const Descriptor* descriptor, const Options& options) { - return "::" + ProtobufNamespace(options) + - (HasDescriptorMethods(descriptor->file(), options) ? "::Message" - : "::MessageLite"); + if (!HasDescriptorMethods(descriptor->file(), options)) { + return "::" + ProtobufNamespace(options) + "::MessageLite"; + } + auto simple_base = SimpleBaseClass(descriptor, options); + if (simple_base.empty()) { + return "::" + ProtobufNamespace(options) + "::Message"; + } + return "::" + ProtobufNamespace(options) + "::internal::" + simple_base; } TProtoStringType ResolveKeyword(const TProtoStringType& name) { @@ -796,6 +777,11 @@ TProtoStringType SafeFunctionName(const Descriptor* descriptor, return function_name; } +bool IsStringInlined(const FieldDescriptor* /* descriptor */, + const Options& /* options */) { + return false; +} + static bool HasLazyFields(const Descriptor* descriptor, const Options& options, MessageSCCAnalyzer* scc_analyzer) { for (int field_idx = 0; field_idx < descriptor->field_count(); field_idx++) { @@ -953,6 +939,18 @@ bool HasEnumDefinitions(const FileDescriptor* file) { return false; } +bool ShouldVerify(const Descriptor* /* descriptor */, + const Options& /* options */, + MessageSCCAnalyzer* /* scc_analyzer */) { + return false; +} + +bool ShouldVerify(const FileDescriptor* /* file */, + const Options& /* options */, + MessageSCCAnalyzer* /* scc_analyzer */) { + return false; +} + bool IsStringOrMessage(const FieldDescriptor* field) { switch (field->cpp_type()) { case FieldDescriptor::CPPTYPE_INT32: @@ -1099,21 +1097,12 @@ void GenerateUtf8CheckCodeForCord(const FieldDescriptor* field, "VerifyUTF8CordNamedField", format); } -namespace { - -void Flatten(const Descriptor* descriptor, - std::vector<const Descriptor*>* flatten) { - for (int i = 0; i < descriptor->nested_type_count(); i++) - Flatten(descriptor->nested_type(i), flatten); - flatten->push_back(descriptor); -} - -} // namespace - void FlattenMessagesInFile(const FileDescriptor* file, std::vector<const Descriptor*>* result) { for (int i = 0; i < file->message_type_count(); i++) { - Flatten(file->message_type(i), result); + ForEachMessage(file->message_type(i), [&](const Descriptor* descriptor) { + result->push_back(descriptor); + }); } } @@ -1154,7 +1143,7 @@ bool IsImplicitWeakField(const FieldDescriptor* field, const Options& options, MessageAnalysis MessageSCCAnalyzer::GetSCCAnalysis(const SCC* scc) { if (analysis_cache_.count(scc)) return analysis_cache_[scc]; - MessageAnalysis result{}; + MessageAnalysis result; if (UsingImplicitWeakFields(scc->GetFile(), options_)) { result.contains_weak = true; } @@ -1481,6 +1470,10 @@ FileOptions_OptimizeMode GetOptimizeFor(const FileDescriptor* file, return FileOptions::SPEED; } +bool EnableMessageOwnedArena(const Descriptor* /* desc */) { + return false; +} + } // namespace cpp } // namespace compiler } // namespace protobuf |
