Skip to content

Commit

Permalink
Introduce CreateMessage w/ default-init msg inside hpb::interop::upb
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 676071677
  • Loading branch information
honglooker authored and copybara-github committed Sep 18, 2024
1 parent a037f28 commit aa5818d
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions hpb/backend/upb/interop.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>
typename T::Proxy CreateMessage(upb_Arena* arena) {
return hpb::internal::PrivateAccess::CreateMessage<T>(arena);
}

inline absl::string_view FromUpbStringView(upb_StringView str) {
return absl::string_view(str.data, str.size);
}
Expand Down

0 comments on commit aa5818d

Please sign in to comment.