diff options
author | akastornov <akastornov@yandex-team.ru> | 2022-02-10 16:46:03 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:03 +0300 |
commit | 8d3a5ed3a188a34167eaee54f1691ce5c9edf2f3 (patch) | |
tree | 1a2c5ffcf89eb53ecd79dbc9bc0a195c27404d0c /contrib/tools | |
parent | 3a2de774d91ca8d7325aaf81c200b1d2047725e6 (diff) | |
download | ydb-8d3a5ed3a188a34167eaee54f1691ce5c9edf2f3.tar.gz |
Restoring authorship annotation for <akastornov@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/tools')
-rw-r--r-- | contrib/tools/protoc/plugins/cpp_styleguide/cpp_styleguide.cpp | 252 | ||||
-rw-r--r-- | contrib/tools/protoc/plugins/grpc_python/ya.make | 4 | ||||
-rw-r--r-- | contrib/tools/ya.make | 2 |
3 files changed, 129 insertions, 129 deletions
diff --git a/contrib/tools/protoc/plugins/cpp_styleguide/cpp_styleguide.cpp b/contrib/tools/protoc/plugins/cpp_styleguide/cpp_styleguide.cpp index 43107caf1d..cd96aa0565 100644 --- a/contrib/tools/protoc/plugins/cpp_styleguide/cpp_styleguide.cpp +++ b/contrib/tools/protoc/plugins/cpp_styleguide/cpp_styleguide.cpp @@ -50,14 +50,14 @@ namespace NPlugins { return basename.append(".pb.cc"); } - bool IsLiteRuntimeMessage(const Descriptor* desc) { - return desc->file() != NULL && desc->file()->options().optimize_for() == google::protobuf::FileOptions::LITE_RUNTIME; - } - - bool IsAutogeneratedNestedType(const Descriptor* desc) { - return desc->options().map_entry(); - } - + bool IsLiteRuntimeMessage(const Descriptor* desc) { + return desc->file() != NULL && desc->file()->options().optimize_for() == google::protobuf::FileOptions::LITE_RUNTIME; + } + + bool IsAutogeneratedNestedType(const Descriptor* desc) { + return desc->options().map_entry(); + } + class TFieldExtGenerator { public: TFieldExtGenerator(const FieldDescriptor* field) @@ -121,82 +121,82 @@ namespace NPlugins { } }; - class TMapFieldExtGenerator: public TFieldExtGenerator { - public: - TMapFieldExtGenerator(const FieldDescriptor* field) - : TFieldExtGenerator(field) - , Key_(field->message_type()->FindFieldByName("key")) - , Val_(field->message_type()->FindFieldByName("value")) - { - Variables_["key_cpp"] = PrimitiveTypeName(Key_->cpp_type()); - - switch (Val_->cpp_type()) { - case FieldDescriptor::CPPTYPE_MESSAGE: + class TMapFieldExtGenerator: public TFieldExtGenerator { + public: + TMapFieldExtGenerator(const FieldDescriptor* field) + : TFieldExtGenerator(field) + , Key_(field->message_type()->FindFieldByName("key")) + , Val_(field->message_type()->FindFieldByName("value")) + { + Variables_["key_cpp"] = PrimitiveTypeName(Key_->cpp_type()); + + switch (Val_->cpp_type()) { + case FieldDescriptor::CPPTYPE_MESSAGE: Variables_["val_cpp"] = QualifiedClassName(Val_->message_type()); - break; - case FieldDescriptor::CPPTYPE_ENUM: - Variables_["val_cpp"] = ClassName(Val_->enum_type(), true); - break; - default: - Variables_["val_cpp"] = PrimitiveTypeName(Val_->cpp_type()); - } - } - - void GenerateAccessorDeclarations(io::Printer* printer) { - printer->Print(Variables_, + break; + case FieldDescriptor::CPPTYPE_ENUM: + Variables_["val_cpp"] = ClassName(Val_->enum_type(), true); + break; + default: + Variables_["val_cpp"] = PrimitiveTypeName(Val_->cpp_type()); + } + } + + void GenerateAccessorDeclarations(io::Printer* printer) { + 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_, + 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) { - const FieldDescriptor* desc = isKey ? Key_ : Val_; - - switch(desc->cpp_type()) { - case FieldDescriptor::CPPTYPE_STRING: + } + + void GenerateKeyValuePrinting(io::Printer* printer, const char* scopeName, bool isKey) { + const FieldDescriptor* desc = isKey ? Key_ : Val_; + + switch(desc->cpp_type()) { + case FieldDescriptor::CPPTYPE_STRING: printer->Print(TString::Join("::google::protobuf::io::PrintJSONString(out, ", scopeName , ");\n").data()); - break; - case FieldDescriptor::CPPTYPE_ENUM: + break; + case FieldDescriptor::CPPTYPE_ENUM: printer->Print(TString::Join("out << int(", scopeName, ");\n").data()); - break; - case FieldDescriptor::CPPTYPE_MESSAGE: + break; + case FieldDescriptor::CPPTYPE_MESSAGE: printer->Print(TString::Join(scopeName, ".PrintJSON(out);\n").data()); - break; - default: - if (isKey) { + break; + default: + if (isKey) { printer->Print(TString::Join("out << '\"' << ", scopeName, " << '\"';\n").data()); - } else { + } else { printer->Print(TString::Join("out << ", scopeName, ";\n").data()); - } - } - } - - void GenerateJSONPrinting(io::Printer* printer) { - printer->Print(Variables_, - "out << '{';\n" - "const ::google::protobuf::Map<$key_cpp$, $val_cpp$>& map = Get$rname$();\n" - "for (auto it = map.begin(); it != map.end(); ++it) {\n" - ); - printer->Indent(); - printer->Print("if (it != map.begin()) { out << ','; }\n"); - - GenerateKeyValuePrinting(printer, "it->first", true); - printer->Print("out << ':';\n"); - GenerateKeyValuePrinting(printer, "it->second", false); - - printer->Outdent(); - printer->Print("}\n"); - printer->Print("out << '}';\n"); - } - - private: - const FieldDescriptor* Key_; - const FieldDescriptor* Val_; - }; - + } + } + } + + void GenerateJSONPrinting(io::Printer* printer) { + printer->Print(Variables_, + "out << '{';\n" + "const ::google::protobuf::Map<$key_cpp$, $val_cpp$>& map = Get$rname$();\n" + "for (auto it = map.begin(); it != map.end(); ++it) {\n" + ); + printer->Indent(); + printer->Print("if (it != map.begin()) { out << ','; }\n"); + + GenerateKeyValuePrinting(printer, "it->first", true); + printer->Print("out << ':';\n"); + GenerateKeyValuePrinting(printer, "it->second", false); + + printer->Outdent(); + printer->Print("}\n"); + printer->Print("out << '}';\n"); + } + + private: + const FieldDescriptor* Key_; + const FieldDescriptor* Val_; + }; + class TRepeatedMessageFieldExtGenerator: public TFieldExtGenerator { public: TRepeatedMessageFieldExtGenerator(const FieldDescriptor* field) @@ -584,37 +584,37 @@ namespace NPlugins { TProtoStringType type_traits_; }; - class TOneofGenerator { - public: - TOneofGenerator(const OneofDescriptor* Descriptor_) - : Descriptor_(Descriptor_) - { - Variables_["camel_oneof_name"] = UnderscoresToCamelCase(Descriptor_->name(), true); - Variables_["rname"] = Descriptor_->name(); - } - - void GenerateDeclarations(io::Printer* printer) const { - printer->Print(Variables_, "$camel_oneof_name$Case Get$rname$Case() const { return $rname$_case(); }\n"); - printer->Print(Variables_, "void Clear$rname$() { clear_$rname$(); }\n"); + class TOneofGenerator { + public: + TOneofGenerator(const OneofDescriptor* Descriptor_) + : Descriptor_(Descriptor_) + { + Variables_["camel_oneof_name"] = UnderscoresToCamelCase(Descriptor_->name(), true); + Variables_["rname"] = Descriptor_->name(); + } + + void GenerateDeclarations(io::Printer* printer) const { + printer->Print(Variables_, "$camel_oneof_name$Case Get$rname$Case() const { return $rname$_case(); }\n"); + printer->Print(Variables_, "void Clear$rname$() { clear_$rname$(); }\n"); if (Descriptor_->name() != UnderscoresToCamelCase(Descriptor_->name(), true)) { printer->Print(Variables_, "$camel_oneof_name$Case Get$camel_oneof_name$Case() const { return $rname$_case(); }\n"); printer->Print(Variables_, "void Clear$camel_oneof_name$() { clear_$rname$(); }\n"); } - } - - private: - const OneofDescriptor* Descriptor_; - TVariables Variables_; - }; - + } + + private: + const OneofDescriptor* Descriptor_; + TVariables Variables_; + }; + TFieldExtGenerator* MakeGenerator(const FieldDescriptor* field) { if (field->is_repeated()) { switch (field->cpp_type()) { case FieldDescriptor::CPPTYPE_MESSAGE: - if (field->is_map()) { - return new TMapFieldExtGenerator(field); - } + if (field->is_map()) { + return new TMapFieldExtGenerator(field); + } return new TRepeatedMessageFieldExtGenerator(field); case FieldDescriptor::CPPTYPE_BOOL: return new TRepeatedBoolFieldExtGenerator(field); @@ -660,10 +660,10 @@ namespace NPlugins { , Classname_(ClassName(descriptor, false)) , OutputDirectory_(outputDirectory) { - for (int i = 0, idx = 0; i < descriptor->nested_type_count(); i++) { - if (!IsAutogeneratedNestedType(descriptor->nested_type(i))) { + for (int i = 0, idx = 0; i < descriptor->nested_type_count(); i++) { + if (!IsAutogeneratedNestedType(descriptor->nested_type(i))) { NestedGenerators_.emplace_back(descriptor->nested_type(i), OutputDirectory_); - } + } } FieldGenerators_.reserve(descriptor->field_count()); @@ -675,11 +675,11 @@ namespace NPlugins { for (int i = 0; i < descriptor->extension_count(); i++) { ExtensionGenerators_.emplace_back(descriptor->extension(i)); } - + OneofGenerators_.reserve(descriptor->real_oneof_decl_count()); for (int i = 0; i < descriptor->real_oneof_decl_count(); i++) { OneofGenerators_.emplace_back(descriptor->oneof_decl(i)); - } + } } void GenerateClassDefinitionExtension() { @@ -774,11 +774,11 @@ namespace NPlugins { } for (auto& oneofGenerator: OneofGenerators_) { oneofGenerator.GenerateDeclarations(&printer); - } + } TVariables vars; vars["class"] = ClassName(Descriptor_, false); - if (!IsLiteRuntimeMessage(Descriptor_)) { - printer.Print("TProtoStringType ShortUtf8DebugString() const;\n"); + if (!IsLiteRuntimeMessage(Descriptor_)) { + printer.Print("TProtoStringType ShortUtf8DebugString() const;\n"); printer.Print("void PrintJSON(IOutputStream&) const override;\n"); printer.Print(vars, "::google::protobuf::io::TAsJSON<$class$> AsJSON() const {\n"); @@ -821,13 +821,13 @@ namespace NPlugins { TVariables vars; vars["class"] = Classname_; - if (!IsLiteRuntimeMessage(Descriptor_)) { - printer.Print("// Yandex-specific extension\n"); - printer.Print(vars, "TProtoStringType $class$::ShortUtf8DebugString() const {\n"); - printer.Print(" return ::ShortUtf8DebugString(*this);\n"); - printer.Print("}\n"); - printer.Print("// End of Yandex-specific extension\n"); - } + if (!IsLiteRuntimeMessage(Descriptor_)) { + printer.Print("// Yandex-specific extension\n"); + printer.Print(vars, "TProtoStringType $class$::ShortUtf8DebugString() const {\n"); + printer.Print(" return ::ShortUtf8DebugString(*this);\n"); + printer.Print("}\n"); + printer.Print("// End of Yandex-specific extension\n"); + } } void GenerateJSONImplementation() { @@ -857,15 +857,15 @@ namespace NPlugins { SetCommonFieldVariables(field, &vars); if (field->is_repeated()) { - // map or repeated field in both proto3 and proto2 syntax + // map or repeated field in both proto3 and proto2 syntax printer.Print(vars, "if ($rname$Size() > 0) {\n"); } else if (field->has_presence()) { - // any optional or required field in proto2 syntax - // message-field or any oneof field in proto3 syntax - printer.Print(vars, "if (Has$rname$()) {\n"); + // any optional or required field in proto2 syntax + // message-field or any oneof field in proto3 syntax + printer.Print(vars, "if (Has$rname$()) {\n"); } else { - // string, enum or primitive field in proto3 syntax - printer.Print(vars, "if (Get$rname$()) {\n"); + // string, enum or primitive field in proto3 syntax + printer.Print(vars, "if (Get$rname$()) {\n"); } printer.Indent(); @@ -889,16 +889,16 @@ namespace NPlugins { std::unique_ptr<io::ZeroCopyOutputStream> output( OutputDirectory_->OpenForInsert(fileName, scope)); io::Printer printer(output.get(), '$'); - if (!IsLiteRuntimeMessage(Descriptor_)) { - printer.Print("// Yandex debug output extension\n"); - TVariables vars; - vars["class"] = ClassName(Descriptor_, true); - printer.Print("template<>\n"); + if (!IsLiteRuntimeMessage(Descriptor_)) { + printer.Print("// Yandex debug output extension\n"); + TVariables vars; + vars["class"] = ClassName(Descriptor_, true); + printer.Print("template<>\n"); printer.Print(vars, "void Out< $class$>(IOutputStream& out, const $class$& msg) {\n"); - printer.Print(" out << \"{ \" << msg.ShortUtf8DebugString() << \" }\";\n"); - printer.Print("}\n"); - printer.Print("// End of Yandex debug output extension\n"); - } + printer.Print(" out << \"{ \" << msg.ShortUtf8DebugString() << \" }\";\n"); + printer.Print("}\n"); + printer.Print("// End of Yandex debug output extension\n"); + } } void GenerateTypedefOutput(bool nested) { diff --git a/contrib/tools/protoc/plugins/grpc_python/ya.make b/contrib/tools/protoc/plugins/grpc_python/ya.make index 73d60e7846..1852d8b6fd 100644 --- a/contrib/tools/protoc/plugins/grpc_python/ya.make +++ b/contrib/tools/protoc/plugins/grpc_python/ya.make @@ -2,7 +2,7 @@ # Generated by devtools/yamaker. OWNER(akastornov g:contrib g:cpp-contrib) - + IF (USE_PREBUILT_TOOLS) INCLUDE(${ARCADIA_ROOT}/build/prebuilt/contrib/tools/protoc/plugins/grpc_python/ya.make.prebuilt) ENDIF() @@ -10,7 +10,7 @@ ENDIF() IF (NOT PREBUILT) INCLUDE(${ARCADIA_ROOT}/contrib/tools/protoc/plugins/grpc_python/bin/ya.make) ENDIF() - + RECURSE( bin ) diff --git a/contrib/tools/ya.make b/contrib/tools/ya.make index a209734c49..750911c587 100644 --- a/contrib/tools/ya.make +++ b/contrib/tools/ya.make @@ -51,7 +51,7 @@ RECURSE( yasm ycmd zookeeper - jdk + jdk jdk/test xmllint ) |