From 4f39ca6e0c6b531c47948057304f978b2cde1d65 Mon Sep 17 00:00:00 2001 From: Ilya Lipnitskiy Date: Sun, 21 Mar 2021 18:10:26 -0700 Subject: [PATCH] protoc-c: don't use FullName helpers for non-full names FullName* methods are designed to split a full name based on '.' in the name. name() does not have '.' separators, so call CamelToLower and CamelToUpper in place of FullNameToLower and FullNameToUpper. --- protoc-c/c_field.cc | 2 +- protoc-c/c_message.cc | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/protoc-c/c_field.cc b/protoc-c/c_field.cc index 8eda7d2..75afa39 100644 --- a/protoc-c/c_field.cc +++ b/protoc-c/c_field.cc @@ -119,7 +119,7 @@ void FieldGenerator::GenerateDescriptorInitializerGeneric(io::Printer* printer, variables["descriptor_addr"] = descriptor_addr; variables["value"] = SimpleItoa(descriptor_->number()); if (oneof != NULL) - variables["oneofname"] = FullNameToLower(oneof->name()); + variables["oneofname"] = CamelToLower(oneof->name()); if (FieldSyntax(descriptor_) == 3 && descriptor_->label() == FieldDescriptor::LABEL_OPTIONAL) { diff --git a/protoc-c/c_message.cc b/protoc-c/c_message.cc index e738f5e..0f96688 100755 --- a/protoc-c/c_message.cc +++ b/protoc-c/c_message.cc @@ -153,7 +153,7 @@ GenerateStructDefinition(io::Printer* printer) { const OneofDescriptor *oneof = descriptor_->oneof_decl(i); vars["opt_comma"] = ","; - vars["oneofname"] = FullNameToUpper(oneof->name()); + vars["oneofname"] = CamelToUpper(oneof->name()); vars["foneofname"] = FullNameToC(oneof->full_name()); printer->Print("typedef enum {\n"); @@ -161,7 +161,7 @@ GenerateStructDefinition(io::Printer* printer) { printer->Print(vars, "$ucclassname$__$oneofname$__NOT_SET = 0,\n"); for (int j = 0; j < oneof->field_count(); j++) { const FieldDescriptor *field = oneof->field(j); - vars["fieldname"] = FullNameToUpper(field->name()); + vars["fieldname"] = CamelToUpper(field->name()); vars["fieldnum"] = SimpleItoa(field->number()); bool isLast = j == oneof->field_count() - 1; if (isLast) { @@ -204,7 +204,7 @@ GenerateStructDefinition(io::Printer* printer) { // Generate unions from oneofs. for (int i = 0; i < descriptor_->oneof_decl_count(); i++) { const OneofDescriptor *oneof = descriptor_->oneof_decl(i); - vars["oneofname"] = FullNameToLower(oneof->name()); + vars["oneofname"] = CamelToLower(oneof->name()); vars["foneofname"] = FullNameToC(oneof->full_name()); printer->Print(vars, "$foneofname$Case $oneofname$_case;\n");