Move hpb::internal::{MoveExtension, SetExtension} and hpb::{MoveExtension, SetExtension} from hpb.h to extension.h
This delta makes hpb.cc empty, and was therefore eliminated. PiperOrigin-RevId: 683606379pull/18639/head
parent
9dad0b9cd4
commit
9bce530117
4 changed files with 109 additions and 137 deletions
@ -1,53 +0,0 @@ |
|||||||
// Protocol Buffers - Google's data interchange format
|
|
||||||
// Copyright 2023 Google LLC. All rights reserved.
|
|
||||||
//
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file or at
|
|
||||||
// https://developers.google.com/open-source/licenses/bsd
|
|
||||||
|
|
||||||
#include "google/protobuf/hpb/hpb.h" |
|
||||||
|
|
||||||
#include "absl/status/status.h" |
|
||||||
#include "absl/strings/str_format.h" |
|
||||||
#include "absl/strings/string_view.h" |
|
||||||
#include "google/protobuf/hpb/internal/message_lock.h" |
|
||||||
#include "google/protobuf/hpb/status.h" |
|
||||||
#include "upb/mem/arena.h" |
|
||||||
#include "upb/message/accessors.h" |
|
||||||
#include "upb/message/message.h" |
|
||||||
#include "upb/mini_table/extension.h" |
|
||||||
#include "upb/wire/decode.h" |
|
||||||
#include "upb/wire/encode.h" |
|
||||||
|
|
||||||
namespace hpb { |
|
||||||
|
|
||||||
namespace internal { |
|
||||||
|
|
||||||
absl::Status MoveExtension(upb_Message* message, upb_Arena* message_arena, |
|
||||||
const upb_MiniTableExtension* ext, |
|
||||||
upb_Message* extension, upb_Arena* extension_arena) { |
|
||||||
if (message_arena != extension_arena && |
|
||||||
// Try fuse, if fusing is not allowed or fails, create copy of extension.
|
|
||||||
!upb_Arena_Fuse(message_arena, extension_arena)) { |
|
||||||
extension = DeepClone(extension, upb_MiniTableExtension_GetSubMessage(ext), |
|
||||||
message_arena); |
|
||||||
} |
|
||||||
return upb_Message_SetExtension(message, ext, &extension, message_arena) |
|
||||||
? absl::OkStatus() |
|
||||||
: MessageAllocationError(); |
|
||||||
} |
|
||||||
|
|
||||||
absl::Status SetExtension(upb_Message* message, upb_Arena* message_arena, |
|
||||||
const upb_MiniTableExtension* ext, |
|
||||||
const upb_Message* extension) { |
|
||||||
// Clone extension into target message arena.
|
|
||||||
extension = DeepClone(extension, upb_MiniTableExtension_GetSubMessage(ext), |
|
||||||
message_arena); |
|
||||||
return upb_Message_SetExtension(message, ext, &extension, message_arena) |
|
||||||
? absl::OkStatus() |
|
||||||
: MessageAllocationError(); |
|
||||||
} |
|
||||||
|
|
||||||
} // namespace internal
|
|
||||||
|
|
||||||
} // namespace hpb
|
|
Loading…
Reference in new issue