@@ -52,12 +52,20 @@ class NonreflectableMessage : public ::google::protobuf::Message {
5252 }
5353
5454#if GOOGLE_PROTOBUF_VERSION >= 5029000
55- const ::google::protobuf::internal::ClassData* GetClassData () const override {
56- return nullptr ;
57- }
55+ using ClassData = ::google::protobuf::internal::ClassData;
56+ using ClassDataFull = ::google::protobuf::internal::ClassDataFull;
5857#elif GOOGLE_PROTOBUF_VERSION >= 5026000
58+ using ClassData = ::google::protobuf::Message::ClassData;
59+ using ClassDataFull = ::google::protobuf::Message::ClassDataFull;
60+ #endif
61+
62+ #if GOOGLE_PROTOBUF_VERSION >= 5026000
5963 const ClassData* GetClassData () const override {
64+ # if GOOGLE_PROTOBUF_VERSION >= 5027000
65+ return _class_data_.base ();
66+ # else
6067 return nullptr ;
68+ # endif
6169 }
6270#endif
6371
@@ -210,8 +218,67 @@ class NonreflectableMessage : public ::google::protobuf::Message {
210218
211219private:
212220 static T _instance;
221+
222+ #if GOOGLE_PROTOBUF_VERSION >= 5027000
223+ struct NonreflectableMessageClassData : ClassDataFull {
224+ constexpr NonreflectableMessageClassData ()
225+ : ClassDataFull(
226+ # if GOOGLE_PROTOBUF_VERSION >= 5029000
227+ ClassData{
228+ &_instance, // prototype
229+ nullptr , // tc_table
230+ nullptr , // on_demand_register_arena_dtor
231+ nullptr , // is_initialized
232+ nullptr , // merge_to_from
233+ ::google::protobuf::internal::MessageCreator (), // message_creator
234+ 0, // cached_size_offset
235+ false, // is_lite
236+ },
237+ nullptr , // descriptor_methods
238+ nullptr , // descriptor_table
239+ nullptr // get_metadata_tracker
240+ # elif GOOGLE_PROTOBUF_VERSION >= 5028000
241+ ClassData{
242+ &_instance, // prototype
243+ nullptr , // tc_table
244+ nullptr , // on_demand_register_arena_dtor
245+ nullptr , // is_initialized
246+ nullptr , // merge_to_from
247+ 0 , // cached_size_offset
248+ false , // is_lite
249+ },
250+ nullptr , // descriptor_methods
251+ nullptr , // descriptor_table
252+ nullptr // get_metadata_tracker
253+ # else
254+ ClassData{
255+ nullptr , // tc_table
256+ nullptr , // on_demand_register_arena_dtor
257+ nullptr , // is_initialized
258+ 0 , // cached_size_offset
259+ false , // is_lite
260+ },
261+ nullptr , // merge_to_from
262+ nullptr , // descriptor_methods
263+ nullptr , // descriptor_table
264+ nullptr // get_metadata_tracker
265+ # endif
266+ ) {
267+ // Only can be used to determine whether the Types are the same.
268+ descriptor = default_instance ().GetMetadata ().descriptor ;
269+ reflection = default_instance ().GetMetadata ().reflection ;
270+ }
271+ };
272+
273+ static const NonreflectableMessageClassData _class_data_;
274+ #endif
213275};
214276
277+ #if GOOGLE_PROTOBUF_VERSION >= 5027000
278+ template <typename T>
279+ const typename NonreflectableMessage<T>::NonreflectableMessageClassData NonreflectableMessage<T>::_class_data_;
280+ #endif
281+
215282template <typename T>
216283T NonreflectableMessage<T>::_instance;
217284
0 commit comments