diff --git a/hpb/backend/upb/interop.h b/hpb/backend/upb/interop.h index d0a7ebbe91874..c899cb6fefeb6 100644 --- a/hpb/backend/upb/interop.h +++ b/hpb/backend/upb/interop.h @@ -95,6 +95,18 @@ typename T::Proxy MakeHandle(upb_Message* msg, upb_Arena* arena) { return typename T::Proxy(msg, arena); } +/** + * Creates a message in the given arena and returns a handle to it. + * + * The supplied arena must outlive the hpb handle. + * All messages reachable from from the upb message must + * outlive the hpb handle. + */ +template +typename T::Proxy CreateMessage(upb_Arena* arena) { + return hpb::internal::PrivateAccess::CreateMessage(arena); +} + inline absl::string_view FromUpbStringView(upb_StringView str) { return absl::string_view(str.data, str.size); }