diff --git a/php/ext/google/protobuf/php-upb.c b/php/ext/google/protobuf/php-upb.c index bafc8045faf5..502bf57bd063 100644 --- a/php/ext/google/protobuf/php-upb.c +++ b/php/ext/google/protobuf/php-upb.c @@ -3944,6 +3944,14 @@ bool upb_Message_NextUnknown(const upb_Message* msg, upb_StringView* data, return false; } +bool upb_Message_HasUnknown(const upb_Message* msg) { + const upb_Message_Internal* in = UPB_PRIVATE(_upb_Message_GetInternal)(msg); + if (in) { + return in->unknown_end > message_overhead; + } + return false; +} + const char* upb_Message_GetUnknown(const upb_Message* msg, size_t* len) { upb_Message_Internal* in = UPB_PRIVATE(_upb_Message_GetInternal)(msg); if (in) { diff --git a/php/ext/google/protobuf/php-upb.h b/php/ext/google/protobuf/php-upb.h index c536cfa0c6b7..2aca71f94073 100644 --- a/php/ext/google/protobuf/php-upb.h +++ b/php/ext/google/protobuf/php-upb.h @@ -2403,6 +2403,8 @@ UPB_API upb_Message* upb_Message_New(const upb_MiniTable* m, upb_Arena* arena); bool upb_Message_NextUnknown(const upb_Message* msg, upb_StringView* data, uintptr_t* iter); +bool upb_Message_HasUnknown(const upb_Message* msg); + // Returns a reference to the message's unknown data. const char* upb_Message_GetUnknown(const upb_Message* msg, size_t* len); diff --git a/ruby/ext/google/protobuf_c/ruby-upb.c b/ruby/ext/google/protobuf_c/ruby-upb.c index 6881264bf5aa..6039bcd55f27 100644 --- a/ruby/ext/google/protobuf_c/ruby-upb.c +++ b/ruby/ext/google/protobuf_c/ruby-upb.c @@ -3944,6 +3944,14 @@ bool upb_Message_NextUnknown(const upb_Message* msg, upb_StringView* data, return false; } +bool upb_Message_HasUnknown(const upb_Message* msg) { + const upb_Message_Internal* in = UPB_PRIVATE(_upb_Message_GetInternal)(msg); + if (in) { + return in->unknown_end > message_overhead; + } + return false; +} + const char* upb_Message_GetUnknown(const upb_Message* msg, size_t* len) { upb_Message_Internal* in = UPB_PRIVATE(_upb_Message_GetInternal)(msg); if (in) { diff --git a/ruby/ext/google/protobuf_c/ruby-upb.h b/ruby/ext/google/protobuf_c/ruby-upb.h index 178dd1c0822d..f564c75dcbb8 100755 --- a/ruby/ext/google/protobuf_c/ruby-upb.h +++ b/ruby/ext/google/protobuf_c/ruby-upb.h @@ -2405,6 +2405,8 @@ UPB_API upb_Message* upb_Message_New(const upb_MiniTable* m, upb_Arena* arena); bool upb_Message_NextUnknown(const upb_Message* msg, upb_StringView* data, uintptr_t* iter); +bool upb_Message_HasUnknown(const upb_Message* msg); + // Returns a reference to the message's unknown data. const char* upb_Message_GetUnknown(const upb_Message* msg, size_t* len);