From 3c2af99960cc4c5973e7bbf726143202c96e2f99 Mon Sep 17 00:00:00 2001 From: Thomas Van Lenten Date: Tue, 11 Jul 2023 09:09:27 -0700 Subject: [PATCH] Clearify that ExtensionGenerator gets a message or root class. PiperOrigin-RevId: 547207538 --- .../protobuf/compiler/objectivec/extension.cc | 17 +++++++++-------- .../protobuf/compiler/objectivec/extension.h | 4 ++-- .../protobuf/compiler/objectivec/message.h | 1 - 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/google/protobuf/compiler/objectivec/extension.cc b/src/google/protobuf/compiler/objectivec/extension.cc index ad3511647c..9f0f3c925b 100644 --- a/src/google/protobuf/compiler/objectivec/extension.cc +++ b/src/google/protobuf/compiler/objectivec/extension.cc @@ -45,11 +45,12 @@ namespace protobuf { namespace compiler { namespace objectivec { -ExtensionGenerator::ExtensionGenerator(absl::string_view root_class_name, - const FieldDescriptor* descriptor) +ExtensionGenerator::ExtensionGenerator( + absl::string_view root_or_message_class_name, + const FieldDescriptor* descriptor) : method_name_(ExtensionMethodName(descriptor)), - root_class_and_method_name_( - absl::StrCat(root_class_name, "_", method_name_)), + full_method_name_( + absl::StrCat(root_or_message_class_name, "_", method_name_)), descriptor_(descriptor) { ABSL_CHECK(!descriptor->is_map()) << "error: Extension is a map<>!" @@ -98,14 +99,14 @@ void ExtensionGenerator::GenerateStaticVariablesInitialization( absl::StrCat("GPBDataType", GetCapitalizedType(descriptor_))}, {"number", descriptor_->number()}, {"options", BuildFlagsString(FLAGTYPE_EXTENSION, options)}, - {"root_class_and_method_name", root_class_and_method_name_}, + {"full_method_name", full_method_name_}, {"type", objc_type == OBJECTIVECTYPE_MESSAGE ? ObjCClass(ClassName(descriptor_->message_type())) : "Nil"}}, R"objc( { .defaultValue.$default_name$ = $default$, - .singletonName = GPBStringifySymbol($root_class_and_method_name$), + .singletonName = GPBStringifySymbol($full_method_name$), .extendedClass.clazz = $extended_type$, .messageOrGroupClass.clazz = $type$, .enumDescriptorFunc = $enum_desc_func_name$, @@ -129,9 +130,9 @@ void ExtensionGenerator::DetermineObjectiveCClassDefinitions( void ExtensionGenerator::GenerateRegistrationSource( io::Printer* printer) const { - printer->Emit({{"root_class_and_method_name", root_class_and_method_name_}}, + printer->Emit({{"full_method_name", full_method_name_}}, R"objc( - [registry addExtension:$root_class_and_method_name$]; + [registry addExtension:$full_method_name$]; )objc"); } diff --git a/src/google/protobuf/compiler/objectivec/extension.h b/src/google/protobuf/compiler/objectivec/extension.h index 42fc173014..a2fd8f7644 100644 --- a/src/google/protobuf/compiler/objectivec/extension.h +++ b/src/google/protobuf/compiler/objectivec/extension.h @@ -44,7 +44,7 @@ namespace objectivec { class ExtensionGenerator { public: - ExtensionGenerator(absl::string_view root_class_name, + ExtensionGenerator(absl::string_view root_or_message_class_name, const FieldDescriptor* descriptor); ~ExtensionGenerator() = default; @@ -59,7 +59,7 @@ class ExtensionGenerator { private: std::string method_name_; - std::string root_class_and_method_name_; + std::string full_method_name_; const FieldDescriptor* descriptor_; }; diff --git a/src/google/protobuf/compiler/objectivec/message.h b/src/google/protobuf/compiler/objectivec/message.h index e05642b3e1..3bc018fdf2 100644 --- a/src/google/protobuf/compiler/objectivec/message.h +++ b/src/google/protobuf/compiler/objectivec/message.h @@ -72,7 +72,6 @@ class MessageGenerator { bool IncludesOneOfDefinition() const { return !oneof_generators_.empty(); } private: - const std::string root_classname_; const std::string file_description_name_; const Descriptor* descriptor_; FieldGeneratorMap field_generators_;