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.
This commit is contained in:
Ilya Lipnitskiy 2021-03-21 18:10:26 -07:00
parent 1b4e45e445
commit 4f39ca6e0c
No known key found for this signature in database
GPG Key ID: 435C02AAE7CF2014
2 changed files with 4 additions and 4 deletions

View File

@ -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) {

View File

@ -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");