This is an automated email from the ASF dual-hosted git repository.
xiaofeng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brpc.git
The following commit(s) were added to refs/heads/master by this push:
new 724e2fdc Fix class data for protobuf v27+ (#2941)
724e2fdc is described below
commit 724e2fdc4f96fb727d07ab7ae7e48f144965802d
Author: Xiaofeng Wang <[email protected]>
AuthorDate: Mon Apr 7 22:17:36 2025 +0800
Fix class data for protobuf v27+ (#2941)
Close #2917
---
src/brpc/nonreflectable_message.h | 73 +++++++++++++++++++++++++++++++++++++--
1 file changed, 70 insertions(+), 3 deletions(-)
diff --git a/src/brpc/nonreflectable_message.h
b/src/brpc/nonreflectable_message.h
index 495e1874..54a479fc 100644
--- a/src/brpc/nonreflectable_message.h
+++ b/src/brpc/nonreflectable_message.h
@@ -52,12 +52,20 @@ public:
}
#if GOOGLE_PROTOBUF_VERSION >= 5029000
- const ::google::protobuf::internal::ClassData* GetClassData() const
override {
- return nullptr;
- }
+ using ClassData = ::google::protobuf::internal::ClassData;
+ using ClassDataFull = ::google::protobuf::internal::ClassDataFull;
#elif GOOGLE_PROTOBUF_VERSION >= 5026000
+ using ClassData = ::google::protobuf::Message::ClassData;
+ using ClassDataFull = ::google::protobuf::Message::ClassDataFull;
+#endif
+
+#if GOOGLE_PROTOBUF_VERSION >= 5026000
const ClassData* GetClassData() const override {
+# if GOOGLE_PROTOBUF_VERSION >= 5027000
+ return _class_data_.base();
+# else
return nullptr;
+# endif
}
#endif
@@ -210,8 +218,67 @@ public:
private:
static T _instance;
+
+#if GOOGLE_PROTOBUF_VERSION >= 5027000
+ struct NonreflectableMessageClassData : ClassDataFull {
+ constexpr NonreflectableMessageClassData()
+ : ClassDataFull(
+# if GOOGLE_PROTOBUF_VERSION >= 5029000
+ ClassData{
+ &_instance, // prototype
+ nullptr, // tc_table
+ nullptr, // on_demand_register_arena_dtor
+ nullptr, // is_initialized
+ nullptr, // merge_to_from
+
::google::protobuf::internal::MessageCreator(), // message_creator
+ 0, // cached_size_offset
+ false, // is_lite
+ },
+ nullptr, // descriptor_methods
+ nullptr, // descriptor_table
+ nullptr // get_metadata_tracker
+# elif GOOGLE_PROTOBUF_VERSION >= 5028000
+ ClassData{
+ &_instance, // prototype
+ nullptr, // tc_table
+ nullptr, // on_demand_register_arena_dtor
+ nullptr, // is_initialized
+ nullptr, // merge_to_from
+ 0, // cached_size_offset
+ false, // is_lite
+ },
+ nullptr, // descriptor_methods
+ nullptr, // descriptor_table
+ nullptr // get_metadata_tracker
+# else
+ ClassData{
+ nullptr, // tc_table
+ nullptr, // on_demand_register_arena_dtor
+ nullptr, // is_initialized
+ 0, // cached_size_offset
+ false, // is_lite
+ },
+ nullptr, // merge_to_from
+ nullptr, // descriptor_methods
+ nullptr, // descriptor_table
+ nullptr // get_metadata_tracker
+# endif
+ ) {
+ // Only can be used to determine whether the Types are the same.
+ descriptor = default_instance().GetMetadata().descriptor;
+ reflection = default_instance().GetMetadata().reflection;
+ }
+ };
+
+ static const NonreflectableMessageClassData _class_data_;
+#endif
};
+#if GOOGLE_PROTOBUF_VERSION >= 5027000
+template <typename T>
+const typename NonreflectableMessage<T>::NonreflectableMessageClassData
NonreflectableMessage<T>::_class_data_;
+#endif
+
template <typename T>
T NonreflectableMessage<T>::_instance;
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]