|
@@ -20,23 +20,23 @@ namespace NPlugins {
|
|
|
|
|
|
typedef std::map<TProtoStringType, TProtoStringType> TVariables;
|
|
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) {
|
|
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);
|
|
(*variables)["name"] = FieldName(descriptor);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -596,11 +596,11 @@ namespace NPlugins {
|
|
void GenerateDeclarations(io::Printer* printer) const {
|
|
void GenerateDeclarations(io::Printer* printer) const {
|
|
printer->Print(Variables_, "$camel_oneof_name$Case Get$rname$Case() const { return $rname$_case(); }\n");
|
|
printer->Print(Variables_, "$camel_oneof_name$Case Get$rname$Case() const { return $rname$_case(); }\n");
|
|
printer->Print(Variables_, "void Clear$rname$() { clear_$rname$(); }\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:
|
|
private:
|
|
@@ -699,15 +699,15 @@ namespace NPlugins {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- void GenerateTypedefOutputExtension(bool nested) {
|
|
|
|
- GenerateTypedefOutput(nested);
|
|
|
|
-
|
|
|
|
|
|
+ void GenerateTypedefOutputExtension(bool nested) {
|
|
|
|
+ GenerateTypedefOutput(nested);
|
|
|
|
+
|
|
for (auto& nestedGenerator: NestedGenerators_) {
|
|
for (auto& nestedGenerator: NestedGenerators_) {
|
|
nestedGenerator.GenerateTypedefOutputExtension(true);
|
|
nestedGenerator.GenerateTypedefOutputExtension(true);
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
void GenerateClassExtension() {
|
|
void GenerateClassExtension() {
|
|
GenerateDebugStringImplementation();
|
|
GenerateDebugStringImplementation();
|
|
for (auto& nestedGenerator: NestedGenerators_) {
|
|
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(
|
|
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:
|
|
private:
|
|
const Descriptor* Descriptor_;
|
|
const Descriptor* Descriptor_;
|
|
TProtoStringType Classname_;
|
|
TProtoStringType Classname_;
|