aboutsummaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
authorarcadia-devtools <arcadia-devtools@yandex-team.ru>2022-02-21 11:21:51 +0300
committerarcadia-devtools <arcadia-devtools@yandex-team.ru>2022-02-21 11:21:51 +0300
commit67b4967b48ae8d719e6f8ca4b950bb8a41bce391 (patch)
tree4fe6abeda61440c1bd8446ee1d0910b96fea3abe /contrib
parent7be9f9cee9ebe6b5f0c2c9084810df68bd5731b2 (diff)
downloadydb-67b4967b48ae8d719e6f8ca4b950bb8a41bce391.tar.gz
intermediate changes
ref:229d43ca0aced50dac62d8f0f61cbe9795239cb5
Diffstat (limited to 'contrib')
-rw-r--r--contrib/tools/protoc/plugins/cpp_styleguide/cpp_styleguide.cpp105
1 files changed, 10 insertions, 95 deletions
diff --git a/contrib/tools/protoc/plugins/cpp_styleguide/cpp_styleguide.cpp b/contrib/tools/protoc/plugins/cpp_styleguide/cpp_styleguide.cpp
index cd96aa0565..56b49fa6ed 100644
--- a/contrib/tools/protoc/plugins/cpp_styleguide/cpp_styleguide.cpp
+++ b/contrib/tools/protoc/plugins/cpp_styleguide/cpp_styleguide.cpp
@@ -104,16 +104,12 @@ namespace NPlugins {
{
}
- void GenerateAccessorDeclarations(io::Printer* printer) {
+ void GenerateAccessorDeclarations(io::Printer* printer) override {
Variables_["type"] = QualifiedClassName(Field_->message_type());
printer->Print(Variables_,
"inline const $type$& Get$rname$() const { return $name$(); }\n"
"inline $type$* Mutable$rname$() { return mutable_$name$(); }\n");
- if (Variables_.end() != Variables_.find("RName"))
- printer->Print(Variables_,
- "inline const $type$& Get$RName$() const { return $name$(); }\n"
- "inline $type$* Mutable$RName$() { return mutable_$name$(); }\n");
}
void GenerateJSONPrinting(io::Printer* printer) override {
@@ -146,10 +142,6 @@ namespace NPlugins {
printer->Print(Variables_,
"inline const ::google::protobuf::Map<$key_cpp$, $val_cpp$>& Get$rname$() const { return $name$(); }\n"
"inline ::google::protobuf::Map<$key_cpp$, $val_cpp$>* Mutable$rname$() { return mutable_$name$(); }\n");
- if (Variables_.end() != Variables_.find("RName"))
- printer->Print(Variables_,
- "inline const ::google::protobuf::Map<$key_cpp$, $val_cpp$>& Get$RName$() const { return $name$(); }\n"
- "inline ::google::protobuf::Map<$key_cpp$, $val_cpp$>* Mutable$RName$() { return mutable_$name$(); }\n");
}
void GenerateKeyValuePrinting(io::Printer* printer, const char* scopeName, bool isKey) {
@@ -204,7 +196,7 @@ namespace NPlugins {
{
}
- void GenerateAccessorDeclarations(io::Printer* printer) {
+ void GenerateAccessorDeclarations(io::Printer* printer) override {
Variables_["type"] = QualifiedClassName(Field_->message_type());
printer->Print(Variables_,
@@ -219,16 +211,6 @@ namespace NPlugins {
"inline ::google::protobuf::RepeatedPtrField< $type$ >*\n"
" Mutable$rname$() { return mutable_$name$(); }\n");
- if (Variables_.end() != Variables_.find("RName"))
- printer->Print(Variables_,
- "inline const $type$& Get$RName$(size_t _index) const {Y_ASSERT(_index < static_cast<size_t>(::Max<int>())); return $name$(int(_index)); }\n"
- "inline $type$* Mutable$RName$(size_t _index) {Y_ASSERT(_index < static_cast<size_t>(::Max<int>())); return mutable_$name$(int(_index)); }\n"
- "inline $type$* Add$RName$() { return add_$name$(); }\n"
- "inline const ::google::protobuf::RepeatedPtrField< $type$ >&\n"
- " Get$RName$() const { return $name$(); }\n"
- "inline ::google::protobuf::RepeatedPtrField< $type$ >*\n"
- " Mutable$RName$() { return mutable_$name$(); }\n"
- );
}
void GenerateJSONPrinting(io::Printer* printer) override {
@@ -243,7 +225,7 @@ namespace NPlugins {
{
}
- void GenerateAccessorDeclarations(io::Printer* printer) {
+ void GenerateAccessorDeclarations(io::Printer* printer) override {
Variables_["pointer_type"] = Field_->type() == FieldDescriptor::TYPE_BYTES ? "void" : "char";
if (Field_->options().ctype() != FieldOptions::STRING) {
@@ -262,16 +244,6 @@ namespace NPlugins {
"inline void Set$rname$(const $pointer_type$* value, size_t size) { set_$name$(value, size); }\n"
"inline TProtoStringType* Mutable$rname$() { return mutable_$name$(); }\n");
- if (Variables_.end() != Variables_.find("RName"))
- printer->Print(Variables_,
- "inline const TProtoStringType& Get$RName$() const { return $name$(); }\n"
- "inline void Set$RName$(const TProtoStringType& value) { set_$name$(value); }\n"
- "inline void Set$RName$(TProtoStringType&& value) { set_$name$(std::move(value)); }\n"
- "inline void Set$RName$(const char* value) { set_$name$(value); }\n"
- "inline void Set$RName$(const $pointer_type$* value, size_t size) { set_$name$(value, size); }\n"
- "inline TProtoStringType* Mutable$RName$() { return mutable_$name$(); }\n"
- );
-
if (Field_->options().ctype() != FieldOptions::STRING) {
printer->Outdent();
printer->Print(" public:\n");
@@ -292,7 +264,7 @@ namespace NPlugins {
{
}
- void GenerateAccessorDeclarations(io::Printer* printer) {
+ void GenerateAccessorDeclarations(io::Printer* printer) override {
Variables_["pointer_type"] = Field_->type() == FieldDescriptor::TYPE_BYTES ? "void" : "char";
if (Field_->options().ctype() != FieldOptions::STRING) {
@@ -323,25 +295,6 @@ namespace NPlugins {
"inline ::google::protobuf::RepeatedPtrField<TProtoStringType>* Mutable$rname$()"
"{ return mutable_$name$(); }\n");
- if (Variables_.end() != Variables_.find("RName"))
- printer->Print(Variables_,
- "inline const TProtoStringType& Get$RName$(size_t _index) const {Y_ASSERT(_index < static_cast<size_t>(::Max<int>())); return $name$(_index); }\n"
- "inline TProtoStringType* Mutable$RName$(size_t _index) {Y_ASSERT(_index < static_cast<size_t>(::Max<int>())); return mutable_$name$(_index); }\n"
- "inline void Set$RName$(size_t _index, const TProtoStringType& value) {Y_ASSERT(_index < static_cast<size_t>(::Max<int>())); set_$name$(_index, value); }\n"
- "inline void Set$RName$(size_t _index, TProtoStringType&& value) {Y_ASSERT(_index < static_cast<size_t>(::Max<int>())); set_$name$(_index, std::move(value)); }\n"
- "inline void Set$RName$(size_t _index, const char* value) {Y_ASSERT(_index < static_cast<size_t>(::Max<int>())); set_$name$(_index, value); }\n"
- "inline void Set$RName$(size_t _index, const $pointer_type$* value, size_t size) {Y_ASSERT(_index < static_cast<size_t>(::Max<int>())); set_$name$(_index, value, size); }\n"
- "inline TProtoStringType* Add$RName$() { return add_$name$(); }\n"
- "inline void Add$RName$(const TProtoStringType& value) { add_$name$(value); }\n"
- "inline void Add$RName$(TProtoStringType&& value) { add_$name$(std::move(value)); }\n"
- "inline void Add$RName$(const char* value) { add_$name$(value); }\n"
- "inline void Add$RName$(const $pointer_type$* value, size_t size) { add_$name$(value, size); }\n"
- "inline const ::google::protobuf::RepeatedPtrField<TProtoStringType>& Get$RName$() const"
- "{ return $name$(); }\n"
- "inline ::google::protobuf::RepeatedPtrField<TProtoStringType>* Mutable$RName$()"
- "{ return mutable_$name$(); }\n"
- );
-
if (Field_->options().ctype() != FieldOptions::STRING) {
printer->Outdent();
printer->Print(" public:\n");
@@ -364,18 +317,13 @@ namespace NPlugins {
{
}
- void GenerateAccessorDeclarations(io::Printer* printer) {
+ void GenerateAccessorDeclarations(io::Printer* printer) override {
Variables_["type"] = ClassName(Field_->enum_type(), true);
printer->Print(Variables_,
"inline $type$ Get$rname$() const { return $name$(); }\n"
"inline void Set$rname$($type$ value) { set_$name$(value); }\n");
- if (Variables_.end() != Variables_.find("RName"))
- printer->Print(Variables_,
- "inline $type$ Get$RName$() const { return $name$(); } \n"
- "inline void Set$RName$($type$ value) { set_$name$(value); }\n"
- );
}
void GenerateJSONPrinting(io::Printer* printer) override {
@@ -390,7 +338,7 @@ namespace NPlugins {
{
}
- void GenerateAccessorDeclarations(io::Printer* printer) {
+ void GenerateAccessorDeclarations(io::Printer* printer) override {
Variables_["type"] = ClassName(Field_->enum_type(), true);
printer->Print(Variables_,
@@ -401,14 +349,6 @@ namespace NPlugins {
"inline const ::google::protobuf::RepeatedField<int>& get_arr_$name$() const { return $name$(); }\n"
"inline const ::google::protobuf::RepeatedField<int>& Get$rname$() const { return $name$(); }\n"
"inline ::google::protobuf::RepeatedField<int>* Mutable$rname$() { return mutable_$name$(); }\n");
- if (Variables_.end() != Variables_.find("RName"))
- printer->Print(Variables_,
- "inline $type$ Get$RName$(size_t _index) const {Y_ASSERT(_index < static_cast<size_t>(::Max<int>())); return $name$(_index); }\n"
- "inline void Set$RName$(size_t _index, $type$ value) {Y_ASSERT(_index < static_cast<size_t>(::Max<int>())); set_$name$(_index, value); }\n"
- "inline void Add$RName$($type$ value) { add_$name$(value); }\n"
- "inline const ::google::protobuf::RepeatedField<int>& Get$RName$() const { return $name$(); }\n"
- "inline ::google::protobuf::RepeatedField<int>* Mutable$RName$() { return mutable_$name$(); }\n"
- );
}
void GenerateJSONPrinting(io::Printer* printer) override {
@@ -423,17 +363,12 @@ namespace NPlugins {
{
}
- void GenerateAccessorDeclarations(io::Printer* printer) {
+ void GenerateAccessorDeclarations(io::Printer* printer) override {
Variables_["type"] = PrimitiveTypeName(Field_->cpp_type());
printer->Print(Variables_,
"inline $type$ Get$rname$() const { return $name$();}\n"
"inline void Set$rname$($type$ value) { set_$name$(value); }\n");
- if (Variables_.end() != Variables_.find("RName"))
- printer->Print(Variables_,
- "inline $type$ Get$RName$() const { return $name$();}\n"
- "inline void Set$RName$($type$ value) { set_$name$(value); }\n"
- );
}
void GenerateJSONPrinting(io::Printer* printer) override {
@@ -448,7 +383,7 @@ namespace NPlugins {
{
}
- void GenerateAccessorDeclarations(io::Printer* printer) {
+ void GenerateAccessorDeclarations(io::Printer* printer) override {
Variables_["type"] = PrimitiveTypeName(Field_->cpp_type());
printer->Print(Variables_,
@@ -462,16 +397,6 @@ namespace NPlugins {
" Get$rname$() const { return $name$(); }\n"
"inline ::google::protobuf::RepeatedField< $type$ >*\n"
" Mutable$rname$() { return mutable_$name$(); }\n");
- if (Variables_.end() != Variables_.find("RName"))
- printer->Print(Variables_,
- "inline $type$ Get$RName$(size_t _index) const {Y_ASSERT(_index < static_cast<size_t>(::Max<int>())); return $name$(_index); }\n"
- "inline void Set$RName$(size_t _index, $type$ value) {Y_ASSERT(_index < static_cast<size_t>(::Max<int>())); set_$name$(_index, value); }\n"
- "inline void Add$RName$($type$ value) { add_$name$(value); }\n"
- "inline const ::google::protobuf::RepeatedField< $type$ >&\n"
- " Get$RName$() const { return $name$(); }\n"
- "inline ::google::protobuf::RepeatedField< $type$ >*\n"
- " Mutable$RName$() { return mutable_$name$(); }\n"
- );
}
void GenerateJSONPrinting(io::Printer* printer) override {
@@ -660,7 +585,7 @@ namespace NPlugins {
, Classname_(ClassName(descriptor, false))
, OutputDirectory_(outputDirectory)
{
- for (int i = 0, idx = 0; i < descriptor->nested_type_count(); i++) {
+ for (int i = 0; i < descriptor->nested_type_count(); i++) {
if (!IsAutogeneratedNestedType(descriptor->nested_type(i))) {
NestedGenerators_.emplace_back(descriptor->nested_type(i), OutputDirectory_);
}
@@ -744,25 +669,15 @@ namespace NPlugins {
TVariables vars;
SetCommonFieldVariables(field, &vars);
- const bool hasRName = (vars.end() != vars.find("RName"));
if (field->is_repeated()) {
printer.Print(vars,
"inline size_t $rname$Size() const { return (size_t)$name$_size(); }\n");
- if (hasRName)
- printer.Print(vars,
- "inline size_t $RName$Size() const { return (size_t)$name$_size(); }\n");
} else if (field->has_presence()) {
printer.Print(vars,
"inline bool Has$rname$() const { return has_$name$(); }\n");
- if (hasRName)
- printer.Print(vars,
- "inline bool Has$RName$() const { return has_$name$(); }\n");
}
printer.Print(vars, "inline void Clear$rname$() { clear_$name$(); }\n");
- if (hasRName)
- printer.Print(vars,
- "inline void Clear$RName$() { clear_$name$(); }\n");
// Generate type-specific accessor declarations.
FieldGenerators_[i]->GenerateAccessorDeclarations(&printer);
@@ -941,7 +856,7 @@ namespace NPlugins {
, OutputDirectory_(output_directory)
{
MessageGenerators_.reserve(file->message_type_count());
- for (size_t i = 0; i < file->message_type_count(); i++) {
+ for (int i = 0; i < file->message_type_count(); i++) {
MessageGenerators_.emplace_back(file->message_type(i), OutputDirectory_);
}
}