Migrate internal.h to hpb + update fwd hdr

PiperOrigin-RevId: 652504901
pull/17424/head
Hong Shin 4 months ago committed by Copybara-Service
parent 16a8034d04
commit 133136cd9a
  1. 4
      hpb/internal.h
  2. 4
      hpb/internal_test.cc
  3. 3
      hpb_generator/gen_messages.cc
  4. 3
      protos/protos_internal.h

@ -11,7 +11,7 @@
#include "upb/mem/arena.h"
#include "upb/message/message.h"
namespace protos::internal {
namespace hpb::internal {
// Moves ownership of a message created in a source arena.
//
@ -21,5 +21,5 @@ T MoveMessage(upb_Message* msg, upb_Arena* arena) {
return T(msg, arena);
}
} // namespace protos::internal
} // namespace hpb::internal
#endif

@ -25,8 +25,8 @@ TEST(CppGeneratedCode, InternalMoveMessage) {
hpb_unittest_TestModel_set_int_value_with_default(message, 123);
// Move ownership.
TestModel model = protos::internal::MoveMessage<TestModel>(
(upb_Message*)message, source_arena);
TestModel model = hpb::internal::MoveMessage<TestModel>((upb_Message*)message,
source_arena);
// Now that we have moved ownership, free original arena.
upb_Arena_Free(source_arena);
EXPECT_EQ(model.int_value_with_default(), 123);

@ -254,8 +254,7 @@ void WriteModelPublicDeclaration(
int options));
friend upb_Arena* ::protos::internal::GetArena<$0>($0* message);
friend upb_Arena* ::protos::internal::GetArena<$0>(::protos::Ptr<$0> message);
friend $0(::protos::internal::MoveMessage<$0>(upb_Message* msg,
upb_Arena* arena));
friend $0(::hpb::internal::MoveMessage<$0>(upb_Message* msg, upb_Arena* arena));
)cc",
ClassName(descriptor), MessageName(descriptor),
QualifiedClassName(descriptor));

@ -8,4 +8,7 @@
#ifndef UPB_PROTOS_PROTOS_INTERNAL_H_
#define UPB_PROTOS_PROTOS_INTERNAL_H_
#include "google/protobuf/hpb/internal.h"
namespace protos::internal {
using ::hpb::internal::MoveMessage;
} // namespace protos::internal
#endif

Loading…
Cancel
Save