Move hpb::internal::{Serialize, HasExtensionOrUnknown, GetOrPromoteExtension, DeepCopy, DeepClone} to message_lock.h as they all use the message lock absl status helpers are now housed in status.h PiperOrigin-RevId: 681432239pull/18565/head
parent
67de0878d6
commit
aaec548849
6 changed files with 187 additions and 139 deletions
@ -0,0 +1,37 @@ |
|||||||
|
// Protocol Buffers - Google's data interchange format
|
||||||
|
// Copyright 2024 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/status.h" |
||||||
|
|
||||||
|
#include "absl/status/status.h" |
||||||
|
#include "absl/strings/str_format.h" |
||||||
|
#include "absl/types/source_location.h" |
||||||
|
#include "upb/wire/decode.h" |
||||||
|
#include "upb/wire/encode.h" |
||||||
|
|
||||||
|
namespace hpb { |
||||||
|
absl::Status MessageAllocationError(SourceLocation loc) { |
||||||
|
return absl::Status(absl::StatusCode::kUnknown, |
||||||
|
"Upb message allocation error"); |
||||||
|
} |
||||||
|
|
||||||
|
absl::Status ExtensionNotFoundError(int ext_number, SourceLocation loc) { |
||||||
|
return absl::Status(absl::StatusCode::kUnknown, |
||||||
|
absl::StrFormat("Extension %d not found", ext_number)); |
||||||
|
} |
||||||
|
|
||||||
|
absl::Status MessageEncodeError(upb_EncodeStatus s, SourceLocation loc) { |
||||||
|
return absl::Status(absl::StatusCode::kUnknown, "Encoding error"); |
||||||
|
} |
||||||
|
|
||||||
|
absl::Status MessageDecodeError(upb_DecodeStatus status, SourceLocation loc |
||||||
|
|
||||||
|
) { |
||||||
|
return absl::Status(absl::StatusCode::kUnknown, "Upb message parse error"); |
||||||
|
} |
||||||
|
|
||||||
|
} // namespace hpb
|
@ -0,0 +1,39 @@ |
|||||||
|
// Protocol Buffers - Google's data interchange format
|
||||||
|
// Copyright 2024 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
|
||||||
|
|
||||||
|
#ifndef GOOGLE_PROTOBUF_HPB_STATUS_H__ |
||||||
|
#define GOOGLE_PROTOBUF_HPB_STATUS_H__ |
||||||
|
|
||||||
|
#include "absl/status/status.h" |
||||||
|
#include "absl/types/source_location.h" |
||||||
|
#include "upb/wire/decode.h" |
||||||
|
#include "upb/wire/encode.h" |
||||||
|
|
||||||
|
namespace hpb { |
||||||
|
|
||||||
|
// This type exists to work around an absl type that has not yet been
|
||||||
|
// released.
|
||||||
|
struct SourceLocation { |
||||||
|
static SourceLocation current() { return {}; } |
||||||
|
absl::string_view file_name() { return "<unknown>"; } |
||||||
|
int line() { return 0; } |
||||||
|
}; |
||||||
|
|
||||||
|
absl::Status MessageEncodeError(upb_EncodeStatus status, |
||||||
|
SourceLocation loc = SourceLocation::current()); |
||||||
|
|
||||||
|
absl::Status MessageAllocationError( |
||||||
|
SourceLocation loc = SourceLocation::current()); |
||||||
|
|
||||||
|
absl::Status ExtensionNotFoundError( |
||||||
|
int extension_number, SourceLocation loc = SourceLocation::current()); |
||||||
|
|
||||||
|
absl::Status MessageDecodeError(upb_DecodeStatus status, |
||||||
|
SourceLocation loc = SourceLocation::current()); |
||||||
|
} // namespace hpb
|
||||||
|
|
||||||
|
#endif // GOOGLE_PROTOBUF_HPB_STATUS_H__
|
Loading…
Reference in new issue