diff options
author | alexnick <alexnick@yandex-team.ru> | 2022-02-10 16:47:45 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:47:45 +0300 |
commit | b609303efcd1218868ca0eca806ea3cea2e01a8b (patch) | |
tree | c0748b5dcbade83af788c0abfa89c0383d6b779c /contrib/tools/protoc | |
parent | 80ba7327fdd90a6281bcec18f03e84ff856c3559 (diff) | |
download | ydb-b609303efcd1218868ca0eca806ea3cea2e01a8b.tar.gz |
Restoring authorship annotation for <alexnick@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/tools/protoc')
-rw-r--r-- | contrib/tools/protoc/plugins/cpp_styleguide/cpp_styleguide.cpp | 100 |
1 files changed, 50 insertions, 50 deletions
diff --git a/contrib/tools/protoc/plugins/cpp_styleguide/cpp_styleguide.cpp b/contrib/tools/protoc/plugins/cpp_styleguide/cpp_styleguide.cpp index 03c3d8ab46..cd96aa0565 100644 --- a/contrib/tools/protoc/plugins/cpp_styleguide/cpp_styleguide.cpp +++ b/contrib/tools/protoc/plugins/cpp_styleguide/cpp_styleguide.cpp @@ -20,23 +20,23 @@ namespace NPlugins { typedef std::map<TProtoStringType, TProtoStringType> TVariables; - bool GenerateYaStyle(const FileDescriptor* fileDescriptor) { - const auto& extension = fileDescriptor->FindExtensionByName("GenerateYaStyle"); - return extension; - } - - bool GenerateYaStyle(const FieldDescriptor* descriptor) { - const auto& fileDescriptor = descriptor->file(); - return GenerateYaStyle(fileDescriptor); - } - - + bool GenerateYaStyle(const FileDescriptor* fileDescriptor) { + const auto& extension = fileDescriptor->FindExtensionByName("GenerateYaStyle"); + return extension; + } + + bool GenerateYaStyle(const FieldDescriptor* descriptor) { + const auto& fileDescriptor = descriptor->file(); + return GenerateYaStyle(fileDescriptor); + } + + void SetCommonFieldVariables(const FieldDescriptor* descriptor, TVariables* variables) { - const auto& name = descriptor->name(); - if (GenerateYaStyle(descriptor)) - (*variables)["rname"] = UnderscoresToCamelCase(name, true); - else - (*variables)["rname"] = name; + const auto& name = descriptor->name(); + if (GenerateYaStyle(descriptor)) + (*variables)["rname"] = UnderscoresToCamelCase(name, true); + else + (*variables)["rname"] = name; (*variables)["name"] = FieldName(descriptor); } @@ -596,11 +596,11 @@ namespace NPlugins { 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"); - } + + 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: @@ -699,15 +699,15 @@ namespace NPlugins { } } - void GenerateTypedefOutputExtension(bool nested) { - GenerateTypedefOutput(nested); - + void GenerateTypedefOutputExtension(bool nested) { + GenerateTypedefOutput(nested); + for (auto& nestedGenerator: NestedGenerators_) { nestedGenerator.GenerateTypedefOutputExtension(true); - } - } - - + } + } + + void GenerateClassExtension() { GenerateDebugStringImplementation(); for (auto& nestedGenerator: NestedGenerators_) { @@ -901,29 +901,29 @@ namespace NPlugins { } } - void GenerateTypedefOutput(bool nested) { - if (!GenerateYaStyle(Descriptor_->file())) - return; - TProtoStringType fileName = HeaderFileName(Descriptor_->file()); - TProtoStringType scope = nested ? "class_scope:" + Descriptor_->full_name().substr(0, - Descriptor_->full_name().size() - Descriptor_->name().size() - 1) - : "namespace_scope"; + void GenerateTypedefOutput(bool nested) { + if (!GenerateYaStyle(Descriptor_->file())) + return; + TProtoStringType fileName = HeaderFileName(Descriptor_->file()); + TProtoStringType scope = nested ? "class_scope:" + Descriptor_->full_name().substr(0, + Descriptor_->full_name().size() - Descriptor_->name().size() - 1) + : "namespace_scope"; std::unique_ptr<io::ZeroCopyOutputStream> output( - OutputDirectory_->OpenForInsert(fileName, scope)); - io::Printer printer(output.get(), '$'); - TString name = Descriptor_->name(); - bool isOk = name.size() >= 2 && name[0] == 'T' && name[1] >= 'A' && name[1] <= 'Z'; - if (!isOk) { - printer.Print("// Yandex typedef extension\n"); - TVariables vars; - vars["class"] = name; - vars["base_class"] = ClassName(Descriptor_, true); - printer.Print(vars, "typedef $base_class$ T$class$;\n"); - printer.Print("// End of Yandex typedef extension\n"); - } - } - - + OutputDirectory_->OpenForInsert(fileName, scope)); + io::Printer printer(output.get(), '$'); + TString name = Descriptor_->name(); + bool isOk = name.size() >= 2 && name[0] == 'T' && name[1] >= 'A' && name[1] <= 'Z'; + if (!isOk) { + printer.Print("// Yandex typedef extension\n"); + TVariables vars; + vars["class"] = name; + vars["base_class"] = ClassName(Descriptor_, true); + printer.Print(vars, "typedef $base_class$ T$class$;\n"); + printer.Print("// End of Yandex typedef extension\n"); + } + } + + private: const Descriptor* Descriptor_; TProtoStringType Classname_; |