summaryrefslogtreecommitdiffstats
path: root/contrib/libs/protoc/src/google/protobuf/compiler/cpp/extension.cc
diff options
context:
space:
mode:
authornechda <[email protected]>2024-08-29 23:50:27 +0300
committernechda <[email protected]>2024-08-30 00:05:25 +0300
commite10d6638f07a82edae3ea8197b9f5c0affcc07ea (patch)
tree571c38cec05813766a1ad290c9d51ce7ace52919 /contrib/libs/protoc/src/google/protobuf/compiler/cpp/extension.cc
parente79b38f2bbbf78d295d1901d2a79f898022d5224 (diff)
Update cpp-protobuf to 22.5
Привет!\ Этот PR переключат cpp & python библиотеки protobuf на версию 22.5 Если у вас возникли проблемы после влития этого PR: 1. Если начали падать канон тесты, то проведите их переканонизацию 2. Прочитайте <https://wiki.yandex-team.ru/users/nechda/obnovlenie-cpp-protobuf-22.5/> страничку с основными изменениями 3. Если страничка в вики не помогла, то пишите в [DEVTOOLSSUPPORT](https://st.yandex-team.ru/DEVTOOLSSUPPORT) 7fecade616c20a841b9e9af7b7998bdfc8d2807d
Diffstat (limited to 'contrib/libs/protoc/src/google/protobuf/compiler/cpp/extension.cc')
-rw-r--r--contrib/libs/protoc/src/google/protobuf/compiler/cpp/extension.cc37
1 files changed, 20 insertions, 17 deletions
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/extension.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/extension.cc
index ed85f75960a..60ef25c1356 100644
--- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/extension.cc
+++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/extension.cc
@@ -32,14 +32,13 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
-#include <google/protobuf/compiler/cpp/extension.h>
+#include "google/protobuf/compiler/cpp/extension.h"
-#include <map>
-
-#include <google/protobuf/io/printer.h>
-#include <google/protobuf/stubs/strutil.h>
-#include <google/protobuf/compiler/cpp/helpers.h>
-#include <google/protobuf/descriptor.pb.h>
+#include "y_absl/strings/str_cat.h"
+#include "y_absl/strings/str_replace.h"
+#include "google/protobuf/compiler/cpp/helpers.h"
+#include "google/protobuf/descriptor.pb.h"
+#include "google/protobuf/io/printer.h"
namespace google {
namespace protobuf {
@@ -77,7 +76,6 @@ ExtensionGenerator::ExtensionGenerator(const FieldDescriptor* descriptor,
type_traits_.append(" >");
break;
}
- SetCommonVars(options, &variables_);
SetCommonMessageDataVariables(descriptor_->containing_type(), &variables_);
variables_["extendee"] =
QualifiedClassName(descriptor_->containing_type(), options_);
@@ -86,14 +84,18 @@ ExtensionGenerator::ExtensionGenerator(const FieldDescriptor* descriptor,
variables_["name"] = ResolveKeyword(name);
variables_["constant_name"] = FieldConstantName(descriptor_);
variables_["field_type"] =
- StrCat(static_cast<int>(descriptor_->type()));
+ y_absl::StrCat(static_cast<int>(descriptor_->type()));
variables_["packed"] = descriptor_->is_packed() ? "true" : "false";
- TProtoStringType scope =
- IsScoped() ? ClassName(descriptor_->extension_scope(), false) + "::" : "";
+ TProtoStringType scope;
+ if (IsScoped()) {
+ scope =
+ y_absl::StrCat(ClassName(descriptor_->extension_scope(), false), "::");
+ }
+
variables_["scope"] = scope;
variables_["scoped_name"] = ExtensionName(descriptor_);
- variables_["number"] = StrCat(descriptor_->number());
+ variables_["number"] = y_absl::StrCat(descriptor_->number());
bool add_verify_fn =
// Only verify msgs.
@@ -104,7 +106,7 @@ ExtensionGenerator::ExtensionGenerator(const FieldDescriptor* descriptor,
variables_["verify_fn"] =
add_verify_fn
- ? StrCat("&", FieldMessageTypeName(descriptor_, options_),
+ ? y_absl::StrCat("&", FieldMessageTypeName(descriptor_, options_),
"::InternalVerify")
: "nullptr";
}
@@ -125,7 +127,7 @@ void ExtensionGenerator::GenerateDeclaration(io::Printer* printer) const {
if (!IsScoped()) {
qualifier = "extern";
if (!options_.dllexport_decl.empty()) {
- qualifier = options_.dllexport_decl + " " + qualifier;
+ qualifier = y_absl::StrCat(options_.dllexport_decl, " ", qualifier);
}
} else {
qualifier = "static";
@@ -159,14 +161,15 @@ void ExtensionGenerator::GenerateDefinition(io::Printer* printer) {
// it in the header which would be annoying for other reasons. So we
// replace :: with _ in the name and declare it as a global.
default_str =
- StringReplace(variables_["scoped_name"], "::", "_", true) + "_default";
+ y_absl::StrReplaceAll(variables_["scoped_name"], {{"::", "_"}}) +
+ "_default";
format("const TProtoStringType $1$($2$);\n", default_str,
DefaultValue(options_, descriptor_));
} else if (descriptor_->message_type()) {
// We have to initialize the default instance for extensions at registration
// time.
- default_str =
- FieldMessageTypeName(descriptor_, options_) + "::default_instance()";
+ default_str = y_absl::StrCat(FieldMessageTypeName(descriptor_, options_),
+ "::default_instance()");
} else {
default_str = DefaultValue(options_, descriptor_);
}