From 7a2b37f77de879f99cfc0f946e9d9f04b021b082 Mon Sep 17 00:00:00 2001 From: Hong Shin Date: Tue, 9 Jul 2024 15:42:34 -0700 Subject: [PATCH] Update hpb generator plugin namespace protos -> hpb PiperOrigin-RevId: 650780819 --- hpb_generator/gen_accessors.cc | 5 +++-- hpb_generator/gen_accessors.h | 5 +++-- hpb_generator/gen_enums.cc | 5 +++-- hpb_generator/gen_enums.h | 5 +++-- hpb_generator/gen_extensions.cc | 5 +++-- hpb_generator/gen_extensions.h | 5 +++-- hpb_generator/gen_messages.cc | 5 +++-- hpb_generator/gen_messages.h | 5 +++-- hpb_generator/gen_repeated_fields.cc | 6 ++++-- hpb_generator/gen_repeated_fields.h | 6 ++++-- hpb_generator/gen_utils.cc | 5 +++-- hpb_generator/gen_utils.h | 5 +++-- hpb_generator/names.cc | 6 +++--- hpb_generator/names.h | 7 ++++--- hpb_generator/output.cc | 5 +++-- hpb_generator/output.h | 5 +++-- hpb_generator/protoc-gen-upb-protos.cc | 7 ++++--- hpb_generator/tests/test_generated.cc | 2 +- 18 files changed, 56 insertions(+), 38 deletions(-) diff --git a/hpb_generator/gen_accessors.cc b/hpb_generator/gen_accessors.cc index e70be76bf2..048efcd3df 100644 --- a/hpb_generator/gen_accessors.cc +++ b/hpb_generator/gen_accessors.cc @@ -22,7 +22,7 @@ #include "upb_generator/keywords.h" #include "upb_generator/names.h" -namespace protos_generator { +namespace google::protobuf::hpb_generator { namespace protobuf = ::proto2; @@ -566,4 +566,5 @@ std::string ResolveFieldName(const protobuf::FieldDescriptor* field, return upb::generator::ResolveKeywordConflict(std::string(field_name)); } -} // namespace protos_generator +} // namespace protobuf +} // namespace google::hpb_generator diff --git a/hpb_generator/gen_accessors.h b/hpb_generator/gen_accessors.h index cad3d2a634..61729bb8db 100644 --- a/hpb_generator/gen_accessors.h +++ b/hpb_generator/gen_accessors.h @@ -12,7 +12,7 @@ #include "google/protobuf/compiler/hpb/gen_utils.h" #include "google/protobuf/compiler/hpb/output.h" -namespace protos_generator { +namespace google::protobuf::hpb_generator { namespace protobuf = ::proto2; @@ -23,6 +23,7 @@ void WriteUsingAccessorsInHeader(const protobuf::Descriptor* desc, MessageClassType handle_type, Output& output); void WriteOneofAccessorsInHeader(const protobuf::Descriptor* desc, Output& output); -} // namespace protos_generator +} // namespace protobuf +} // namespace google::hpb_generator #endif // PROTOBUF_COMPILER_HBP_GEN_ACCESSORS_H_ diff --git a/hpb_generator/gen_enums.cc b/hpb_generator/gen_enums.cc index 4ecedb42d8..1f20aaab51 100644 --- a/hpb_generator/gen_enums.cc +++ b/hpb_generator/gen_enums.cc @@ -17,7 +17,7 @@ #include "google/protobuf/compiler/hpb/gen_utils.h" #include "google/protobuf/compiler/hpb/names.h" -namespace protos_generator { +namespace google::protobuf::hpb_generator { namespace protobuf = ::proto2; @@ -118,4 +118,5 @@ void WriteHeaderEnumForwardDecls( } } -} // namespace protos_generator +} // namespace protobuf +} // namespace google::hpb_generator diff --git a/hpb_generator/gen_enums.h b/hpb_generator/gen_enums.h index e202a7957b..6345583395 100644 --- a/hpb_generator/gen_enums.h +++ b/hpb_generator/gen_enums.h @@ -11,7 +11,7 @@ #include "google/protobuf/descriptor.h" #include "google/protobuf/compiler/hpb/output.h" -namespace protos_generator { +namespace google::protobuf::hpb_generator { namespace protobuf = ::proto2; @@ -24,6 +24,7 @@ void WriteHeaderEnumForwardDecls( void WriteEnumDeclarations( const std::vector& enums, Output& output); -} // namespace protos_generator +} // namespace protobuf +} // namespace google::hpb_generator #endif // PROTOBUF_COMPILER_HBP_GEN_ENUMS_H_ diff --git a/hpb_generator/gen_extensions.cc b/hpb_generator/gen_extensions.cc index 8e416c2343..d0c54eb36d 100644 --- a/hpb_generator/gen_extensions.cc +++ b/hpb_generator/gen_extensions.cc @@ -11,7 +11,7 @@ #include "google/protobuf/compiler/hpb/gen_utils.h" #include "google/protobuf/compiler/hpb/names.h" -namespace protos_generator { +namespace google::protobuf::hpb_generator { namespace protobuf = ::proto2; @@ -91,4 +91,5 @@ void WriteExtensionIdentifiers( } } -} // namespace protos_generator +} // namespace protobuf +} // namespace google::hpb_generator diff --git a/hpb_generator/gen_extensions.h b/hpb_generator/gen_extensions.h index 45eba614fc..e48f657e8d 100644 --- a/hpb_generator/gen_extensions.h +++ b/hpb_generator/gen_extensions.h @@ -11,7 +11,7 @@ #include "google/protobuf/descriptor.h" #include "google/protobuf/compiler/hpb/output.h" -namespace protos_generator { +namespace google::protobuf::hpb_generator { namespace protobuf = ::proto2; @@ -26,6 +26,7 @@ void WriteExtensionIdentifiers( void WriteExtensionIdentifier(const protobuf::FieldDescriptor* ext, Output& output); -} // namespace protos_generator +} // namespace protobuf +} // namespace google::hpb_generator #endif // PROTOBUF_COMPILER_HBP_GEN_EXTENSIONS_H_ diff --git a/hpb_generator/gen_messages.cc b/hpb_generator/gen_messages.cc index 5b85c1cec6..ff0c1940e0 100644 --- a/hpb_generator/gen_messages.cc +++ b/hpb_generator/gen_messages.cc @@ -25,7 +25,7 @@ #include "upb_generator/common.h" #include "upb_generator/file_layout.h" -namespace protos_generator { +namespace google::protobuf::hpb_generator { namespace protobuf = ::proto2; @@ -537,4 +537,5 @@ void WriteUsingEnumsInHeader( } } -} // namespace protos_generator +} // namespace protobuf +} // namespace google::hpb_generator diff --git a/hpb_generator/gen_messages.h b/hpb_generator/gen_messages.h index e9285c67d6..4552a49950 100644 --- a/hpb_generator/gen_messages.h +++ b/hpb_generator/gen_messages.h @@ -11,7 +11,7 @@ #include "google/protobuf/descriptor.h" #include "google/protobuf/compiler/hpb/output.h" -namespace protos_generator { +namespace google::protobuf::hpb_generator { namespace protobuf = ::proto2; void WriteMessageClassDeclarations( @@ -23,6 +23,7 @@ void WriteMessageImplementation( const protobuf::Descriptor* descriptor, const std::vector& file_exts, Output& output); -} // namespace protos_generator +} // namespace protobuf +} // namespace google::hpb_generator #endif // PROTOBUF_COMPILER_HBP_GEN_MESSAGES_H_ diff --git a/hpb_generator/gen_repeated_fields.cc b/hpb_generator/gen_repeated_fields.cc index 66d9efa8ad..f010294d43 100644 --- a/hpb_generator/gen_repeated_fields.cc +++ b/hpb_generator/gen_repeated_fields.cc @@ -23,7 +23,8 @@ #include "upb_generator/file_layout.h" #include "upb_generator/names.h" -namespace protos_generator { +namespace google::protobuf::hpb_generator { + namespace protobuf = ::proto2; // Adds using accessors to reuse base Access class members from a Proxy/CProxy. @@ -322,4 +323,5 @@ void WriteRepeatedScalarAccessor(const protobuf::Descriptor* message, ); } -} // namespace protos_generator +} // namespace protobuf +} // namespace google::hpb_generator diff --git a/hpb_generator/gen_repeated_fields.h b/hpb_generator/gen_repeated_fields.h index 9e7169f73b..a041dd0aa8 100644 --- a/hpb_generator/gen_repeated_fields.h +++ b/hpb_generator/gen_repeated_fields.h @@ -12,7 +12,8 @@ #include "google/protobuf/descriptor.h" #include "google/protobuf/compiler/hpb/output.h" -namespace protos_generator { +namespace google::protobuf::hpb_generator { + namespace protobuf = ::proto2; void WriteRepeatedFieldUsingAccessors(const protobuf::FieldDescriptor* field, @@ -41,6 +42,7 @@ void WriteRepeatedScalarAccessor(const protobuf::Descriptor* message, absl::string_view resolved_field_name, absl::string_view class_name, Output& output); -} // namespace protos_generator +} // namespace protobuf +} // namespace google::hpb_generator #endif // PROTOBUF_COMPILER_HBP_GEN_REPEATED_FIELDS_H_ diff --git a/hpb_generator/gen_utils.cc b/hpb_generator/gen_utils.cc index ae45491cce..3827425467 100644 --- a/hpb_generator/gen_utils.cc +++ b/hpb_generator/gen_utils.cc @@ -13,7 +13,7 @@ #include "absl/strings/ascii.h" -namespace protos_generator { +namespace google::protobuf::hpb_generator { namespace protobuf = ::proto2; @@ -126,4 +126,5 @@ std::string ToCamelCase(const std::string& input, bool lower_first) { return result; } -} // namespace protos_generator +} // namespace protobuf +} // namespace google::hpb_generator diff --git a/hpb_generator/gen_utils.h b/hpb_generator/gen_utils.h index bb79db4a75..3cf8a850a9 100644 --- a/hpb_generator/gen_utils.h +++ b/hpb_generator/gen_utils.h @@ -15,7 +15,7 @@ #include "google/protobuf/compiler/code_generator.h" #include "google/protobuf/descriptor.h" -namespace protos_generator { +namespace google::protobuf::hpb_generator { namespace protobuf = ::proto2; @@ -40,6 +40,7 @@ std::vector FieldNumberOrder( std::string ToCamelCase(const std::string& input, bool lower_first); -} // namespace protos_generator +} // namespace protobuf +} // namespace google::hpb_generator #endif // PROTOBUF_COMPILER_HBP_GEN_UTILS_H_ diff --git a/hpb_generator/names.cc b/hpb_generator/names.cc index 75c206381a..b3145f34b9 100644 --- a/hpb_generator/names.cc +++ b/hpb_generator/names.cc @@ -11,8 +11,7 @@ #include "upb_generator/keywords.h" -namespace protos_generator { - +namespace google::protobuf::hpb_generator { namespace protobuf = ::proto2; namespace { @@ -175,4 +174,5 @@ std::string MessageProxyType(const protobuf::FieldDescriptor* field, "Proxy"; } -} // namespace protos_generator +} // namespace protobuf +} // namespace google::hpb_generator diff --git a/hpb_generator/names.h b/hpb_generator/names.h index 9ac6b501a6..ca044f21dc 100644 --- a/hpb_generator/names.h +++ b/hpb_generator/names.h @@ -13,11 +13,11 @@ #include "google/protobuf/descriptor.pb.h" #include "google/protobuf/compiler/hpb/output.h" -namespace protos_generator { +namespace google::protobuf::hpb_generator { namespace protobuf = ::proto2; -inline constexpr absl::string_view kNoPackageNamePrefix = "protos_"; +inline constexpr absl::string_view kNoPackageNamePrefix = "hpb_"; std::string ClassName(const protobuf::Descriptor* descriptor); std::string QualifiedClassName(const protobuf::Descriptor* descriptor); @@ -45,6 +45,7 @@ std::string MessageCProxyType(const protobuf::FieldDescriptor* field, std::string MessageProxyType(const protobuf::FieldDescriptor* field, bool is_const); -} // namespace protos_generator +} // namespace protobuf +} // namespace google::hpb_generator #endif // PROTOBUF_COMPILER_HBP_GEN_NAMES_H_ diff --git a/hpb_generator/output.cc b/hpb_generator/output.cc index 3938444dcd..32b34bcde2 100644 --- a/hpb_generator/output.cc +++ b/hpb_generator/output.cc @@ -11,7 +11,7 @@ #include "absl/strings/str_replace.h" -namespace protos_generator { +namespace google::protobuf::hpb_generator { namespace { namespace protobuf = ::proto2; @@ -66,4 +66,5 @@ std::string CSourceFilename(const google::protobuf::FileDescriptor* file) { return StripExtension(file->name()) + ".upb.c"; } -} // namespace protos_generator +} // namespace protobuf +} // namespace google::hpb_generator diff --git a/hpb_generator/output.h b/hpb_generator/output.h index 6244d3ff3b..f2769e470e 100644 --- a/hpb_generator/output.h +++ b/hpb_generator/output.h @@ -16,7 +16,7 @@ #include "google/protobuf/descriptor.h" #include "google/protobuf/io/zero_copy_stream.h" -namespace protos_generator { +namespace google::protobuf::hpb_generator { class Output { public: @@ -146,6 +146,7 @@ std::string FileLayoutName(const google::protobuf::FileDescriptor* file); std::string CHeaderFilename(const google::protobuf::FileDescriptor* file); std::string CSourceFilename(const google::protobuf::FileDescriptor* file); -} // namespace protos_generator +} // namespace protobuf +} // namespace google::hpb_generator #endif // PROTOBUF_COMPILER_HBP_OUTPUT_H_ diff --git a/hpb_generator/protoc-gen-upb-protos.cc b/hpb_generator/protoc-gen-upb-protos.cc index b96a708c32..d946fb260a 100644 --- a/hpb_generator/protoc-gen-upb-protos.cc +++ b/hpb_generator/protoc-gen-upb-protos.cc @@ -22,7 +22,7 @@ #include "google/protobuf/compiler/hpb/names.h" #include "google/protobuf/compiler/hpb/output.h" -namespace protos_generator { +namespace google::protobuf::hpb_generator { namespace { namespace protoc = ::google::protobuf::compiler; @@ -265,9 +265,10 @@ void WriteHeaderMessageForwardDecls(const protobuf::FileDescriptor* file, } } // namespace -} // namespace protos_generator +} // namespace protobuf +} // namespace google::hpb_generator int main(int argc, char** argv) { - protos_generator::Generator generator_cc; + google::protobuf::hpb_generator::Generator generator_cc; return google::protobuf::compiler::PluginMain(argc, argv, &generator_cc); } diff --git a/hpb_generator/tests/test_generated.cc b/hpb_generator/tests/test_generated.cc index e2f56b8093..7736ea0c80 100644 --- a/hpb_generator/tests/test_generated.cc +++ b/hpb_generator/tests/test_generated.cc @@ -54,7 +54,7 @@ TEST(CppGeneratedCode, ImportedEnum) { EXPECT_EQ(3, TestEnum::DEVICE_MONITOR); } TEST(CppGeneratedCode, Enum) { EXPECT_EQ(1, RED); } -TEST(CppGeneratedCode, EnumNoPackage) { EXPECT_EQ(1, ::protos_CELSIUS); } +TEST(CppGeneratedCode, EnumNoPackage) { EXPECT_EQ(1, ::hpb_CELSIUS); } TEST(CppGeneratedCode, MessageEnumType) { TestModel_Category category1 = TestModel_Category_IMAGES;