From 71dbf95b181a039cca97fd380d9549934f4a87b6 Mon Sep 17 00:00:00 2001 From: Protobuf Team Bot Date: Thu, 4 Jan 2024 07:12:01 -0800 Subject: [PATCH] Fix lowerCamelCase to UpperCamelCase (per Cpp style guide) PiperOrigin-RevId: 595695805 --- src/google/protobuf/compiler/rust/enum.cc | 8 ++++---- src/google/protobuf/compiler/rust/oneof.cc | 22 +++++++++++----------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/google/protobuf/compiler/rust/enum.cc b/src/google/protobuf/compiler/rust/enum.cc index 4871a34f46bf0..de9382a99aea1 100644 --- a/src/google/protobuf/compiler/rust/enum.cc +++ b/src/google/protobuf/compiler/rust/enum.cc @@ -35,12 +35,12 @@ namespace rust { namespace { -std::string enumName(const EnumDescriptor& desc) { +std::string EnumName(const EnumDescriptor& desc) { return cpp::UnderscoresToCamelCase(desc.name(), /*cap first letter=*/true); } // Constructs input for `EnumValues` from an enum descriptor. -std::vector> enumValuesInput( +std::vector> EnumValuesInput( const EnumDescriptor& desc) { std::vector> result; result.reserve(static_cast(desc.value_count())); @@ -165,10 +165,10 @@ std::string ScreamingSnakeToUpperCamelCase(absl::string_view input) { } void GenerateEnumDefinition(Context& ctx, const EnumDescriptor& desc) { - std::string name = enumName(desc); + std::string name = EnumName(desc); ABSL_CHECK(desc.value_count() > 0); std::vector values = - EnumValues(desc.name(), enumValuesInput(desc)); + EnumValues(desc.name(), EnumValuesInput(desc)); ABSL_CHECK(!values.empty()); ctx.Emit( diff --git a/src/google/protobuf/compiler/rust/oneof.cc b/src/google/protobuf/compiler/rust/oneof.cc index a2d4ca86e404a..4b08f4571c54d 100644 --- a/src/google/protobuf/compiler/rust/oneof.cc +++ b/src/google/protobuf/compiler/rust/oneof.cc @@ -78,15 +78,15 @@ std::string ToCamelCase(absl::string_view name) { return cpp::UnderscoresToCamelCase(name, /* upper initial letter */ true); } -std::string oneofViewEnumRsName(const OneofDescriptor& oneof) { +std::string OneofViewEnumRsName(const OneofDescriptor& oneof) { return ToCamelCase(oneof.name()); } -std::string oneofMutEnumRsName(const OneofDescriptor& oneof) { +std::string OneofMutEnumRsName(const OneofDescriptor& oneof) { return ToCamelCase(oneof.name()) + "Mut"; } -std::string oneofCaseEnumName(const OneofDescriptor& oneof) { +std::string OneofCaseEnumName(const OneofDescriptor& oneof) { // Note: This is the name used for the cpp Case enum, we use it for both // the Rust Case enum as well as for the cpp case enum in the cpp thunk. return ToCamelCase(oneof.name()) + "Case"; @@ -167,8 +167,8 @@ std::string RsTypeNameMut(Context& ctx, const FieldDescriptor& field) { void GenerateOneofDefinition(Context& ctx, const OneofDescriptor& oneof) { ctx.Emit( - {{"view_enum_name", oneofViewEnumRsName(oneof)}, - {"mut_enum_name", oneofMutEnumRsName(oneof)}, + {{"view_enum_name", OneofViewEnumRsName(oneof)}, + {"mut_enum_name", OneofMutEnumRsName(oneof)}, {"view_fields", [&] { for (int i = 0; i < oneof.field_count(); ++i) { @@ -230,7 +230,7 @@ void GenerateOneofDefinition(Context& ctx, const OneofDescriptor& oneof) { // Note: This enum is used as the Thunk return type for getting which case is // used: it exactly matches the generate case enum that both cpp and upb use. - ctx.Emit({{"case_enum_name", oneofCaseEnumName(oneof)}, + ctx.Emit({{"case_enum_name", OneofCaseEnumName(oneof)}, {"cases", [&] { for (int i = 0; i < oneof.field_count(); ++i) { @@ -258,9 +258,9 @@ void GenerateOneofDefinition(Context& ctx, const OneofDescriptor& oneof) { void GenerateOneofAccessors(Context& ctx, const OneofDescriptor& oneof) { ctx.Emit( {{"oneof_name", oneof.name()}, - {"view_enum_name", oneofViewEnumRsName(oneof)}, - {"mut_enum_name", oneofMutEnumRsName(oneof)}, - {"case_enum_name", oneofCaseEnumName(oneof)}, + {"view_enum_name", OneofViewEnumRsName(oneof)}, + {"mut_enum_name", OneofMutEnumRsName(oneof)}, + {"case_enum_name", OneofCaseEnumName(oneof)}, {"view_cases", [&] { for (int i = 0; i < oneof.field_count(); ++i) { @@ -341,7 +341,7 @@ void GenerateOneofAccessors(Context& ctx, const OneofDescriptor& oneof) { void GenerateOneofExternC(Context& ctx, const OneofDescriptor& oneof) { ctx.Emit( { - {"case_enum_rs_name", oneofCaseEnumName(oneof)}, + {"case_enum_rs_name", OneofCaseEnumName(oneof)}, {"case_thunk", ThunkName(ctx, oneof, "case")}, }, R"rs( @@ -353,7 +353,7 @@ void GenerateOneofThunkCc(Context& ctx, const OneofDescriptor& oneof) { ctx.Emit( { {"oneof_name", oneof.name()}, - {"case_enum_name", oneofCaseEnumName(oneof)}, + {"case_enum_name", OneofCaseEnumName(oneof)}, {"case_thunk", ThunkName(ctx, oneof, "case")}, {"QualifiedMsg", cpp::QualifiedClassName(oneof.containing_type())}, },