|
|
|
@ -10,7 +10,10 @@ |
|
|
|
|
|
|
|
|
|
// The sole public header in hpb/backend/upb
|
|
|
|
|
|
|
|
|
|
#include "google/protobuf/hpb/internal/internal.h" |
|
|
|
|
#include "google/protobuf/hpb/ptr.h" |
|
|
|
|
#include "upb/mem/arena.h" |
|
|
|
|
#include "upb/message/message.h" |
|
|
|
|
#include "upb/mini_table/message.h" |
|
|
|
|
|
|
|
|
|
namespace hpb::interop::upb { |
|
|
|
@ -25,6 +28,28 @@ const upb_MiniTable* GetMiniTable(Ptr<T>) { |
|
|
|
|
return T::minitable(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Creates a const Handle to a upb message. |
|
|
|
|
* |
|
|
|
|
* The supplied arena must outlive the hpb handle. |
|
|
|
|
* All messages reachable from from the upb message must |
|
|
|
|
* outlive the hpb handle. |
|
|
|
|
* |
|
|
|
|
* That is: |
|
|
|
|
* upb allows message M on arena A to point to message M' on |
|
|
|
|
* arena A'. As a user of hpb, you must guarantee that both A and A' |
|
|
|
|
* outlive M and M'. In practice, this is enforced by using upb::Fuse, |
|
|
|
|
* or manual tracking. |
|
|
|
|
* |
|
|
|
|
* The upb message must not be mutated directly while the handle is alive. |
|
|
|
|
* |
|
|
|
|
* TODO: b/361596328 - revisit GetArena for CHandles |
|
|
|
|
*/ |
|
|
|
|
template <typename T> |
|
|
|
|
typename T::CProxy MakeCHandle(const upb_Message* msg, upb_Arena* arena) { |
|
|
|
|
return hpb::internal::PrivateAccess::CProxy<T>(msg, arena); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} // namespace hpb::interop::upb
|
|
|
|
|
|
|
|
|
|
#endif // GOOGLE_PROTOBUF_HPB_BACKEND_UPB_INTEROP_H__
|
|
|
|
|