mirror of
https://github.com/protocolbuffers/protobuf
synced 2026-08-26 02:23:14 -04:00
Handle return values in cpp code in upb/hpb
PiperOrigin-RevId: 956112101
This commit is contained in:
parent
a772068fea
commit
bbe3b9e4f2
17 changed files with 109 additions and 32 deletions
|
|
@ -102,6 +102,7 @@ cc_test(
|
|||
"//upb/mini_table",
|
||||
"//upb/reflection",
|
||||
"//upb/reflection:internal",
|
||||
"//upb/reflection:reflection_cc",
|
||||
"//upb/wire",
|
||||
"@abseil-cpp//absl/container:flat_hash_set",
|
||||
"@abseil-cpp//absl/log:absl_check",
|
||||
|
|
|
|||
|
|
@ -213,7 +213,6 @@ upb/port/undef.inc
|
|||
upb/port/vsnprintf_compat.h
|
||||
upb/reflection/common.h
|
||||
upb/reflection/def.h
|
||||
upb/reflection/def.hpp
|
||||
upb/reflection/def_pool.h
|
||||
upb/reflection/def_type.h
|
||||
upb/reflection/descriptor_bootstrap.h
|
||||
|
|
@ -224,7 +223,6 @@ upb/reflection/extension_range.h
|
|||
upb/reflection/field_def.h
|
||||
upb/reflection/file_def.h
|
||||
upb/reflection/message.h
|
||||
upb/reflection/message.hpp
|
||||
upb/reflection/message_def.h
|
||||
upb/reflection/message_reserved_range.h
|
||||
upb/reflection/method_def.h
|
||||
|
|
|
|||
|
|
@ -78,6 +78,7 @@ cc_library(
|
|||
"//upb/message:promote",
|
||||
"//upb/mini_table",
|
||||
"//upb/wire",
|
||||
"@abseil-cpp//absl/log:check",
|
||||
"@abseil-cpp//absl/status:statusor",
|
||||
"@abseil-cpp//absl/strings:string_view",
|
||||
],
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
#include "absl/log/check.h"
|
||||
#include "absl/status/statusor.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "hpb/status.h"
|
||||
|
|
@ -90,7 +91,9 @@ absl::StatusOr<absl::string_view> Serialize(const upb_Message* message,
|
|||
void DeepCopy(upb_Message* target, const upb_Message* source,
|
||||
const upb_MiniTable* mini_table, upb_Arena* arena) {
|
||||
MessageLock msg_lock(source);
|
||||
upb_Message_DeepCopy(target, source, mini_table, arena);
|
||||
// TODO: Change to absl::ThrowStdBadAlloc once our min absl version is above
|
||||
// 202603
|
||||
ABSL_CHECK(upb_Message_DeepCopy(target, source, mini_table, arena));
|
||||
}
|
||||
|
||||
upb_Message* DeepClone(const upb_Message* source,
|
||||
|
|
|
|||
|
|
@ -202,7 +202,7 @@ bootstrap_cc_library(
|
|||
":enum",
|
||||
":extension",
|
||||
":message",
|
||||
"//upb/reflection:reflection",
|
||||
"//upb/reflection:reflection_cc",
|
||||
"//upb_generator:plugin",
|
||||
],
|
||||
copts = COPTS,
|
||||
|
|
@ -244,7 +244,7 @@ bootstrap_cc_library(
|
|||
bootstrap_deps = [
|
||||
":enum",
|
||||
":extension",
|
||||
"//upb/reflection:reflection",
|
||||
"//upb/reflection:reflection_cc",
|
||||
],
|
||||
copts = COPTS,
|
||||
strip_include_prefix = "/src",
|
||||
|
|
@ -272,7 +272,7 @@ bootstrap_cc_library(
|
|||
srcs = ["extension.cc"],
|
||||
hdrs = ["extension.h"],
|
||||
bootstrap_deps = [
|
||||
"//upb/reflection:reflection",
|
||||
"//upb/reflection:reflection_cc",
|
||||
],
|
||||
copts = COPTS,
|
||||
strip_include_prefix = "/src",
|
||||
|
|
@ -291,7 +291,7 @@ bootstrap_cc_library(
|
|||
srcs = ["enum.cc"],
|
||||
hdrs = ["enum.h"],
|
||||
bootstrap_deps = [
|
||||
"//upb/reflection:reflection",
|
||||
"//upb/reflection:reflection_cc",
|
||||
],
|
||||
copts = COPTS,
|
||||
strip_include_prefix = "/src",
|
||||
|
|
|
|||
|
|
@ -98,12 +98,15 @@ cc_toolchain_config(
|
|||
cc_toolchain_config(
|
||||
name = "osx-aarch_64-config",
|
||||
extra_compiler_flags = [
|
||||
"-I/usr/tools/xcode_14_0/macosx/usr/include/c++/v1",
|
||||
"-I/usr/tools/xcode_14_0/macosx/usr/include",
|
||||
"-F/usr/tools/xcode_14_0/macosx/System/Library/Frameworks",
|
||||
"-isystem/usr/tools/xcode_14_0/macosx/usr/include/c++/v1",
|
||||
"-isystem/usr/tools/xcode_14_0/macosx/usr/include",
|
||||
"-iframework/usr/tools/xcode_14_0/macosx/System/Library/Frameworks",
|
||||
"-Wno-error=nullability-completeness",
|
||||
"-Wno-error=availability",
|
||||
"-Wno-error=elaborated-enum-base",
|
||||
"-Wno-error=undef",
|
||||
"-Wno-error=shadow",
|
||||
"-Wno-error=unknown-pragmas",
|
||||
],
|
||||
extra_linker_flags = ["-framework CoreFoundation"],
|
||||
linker_path = "/usr/tools",
|
||||
|
|
@ -115,12 +118,15 @@ cc_toolchain_config(
|
|||
cc_toolchain_config(
|
||||
name = "osx-x86_64-config",
|
||||
extra_compiler_flags = [
|
||||
"-I/usr/tools/xcode_14_0/macosx/usr/include/c++/v1",
|
||||
"-I/usr/tools/xcode_14_0/macosx/usr/include",
|
||||
"-F/usr/tools/xcode_14_0/macosx/System/Library/Frameworks",
|
||||
"-isystem/usr/tools/xcode_14_0/macosx/usr/include/c++/v1",
|
||||
"-isystem/usr/tools/xcode_14_0/macosx/usr/include",
|
||||
"-iframework/usr/tools/xcode_14_0/macosx/System/Library/Frameworks",
|
||||
"-Wno-error=nullability-completeness",
|
||||
"-Wno-error=availability",
|
||||
"-Wno-error=elaborated-enum-base",
|
||||
"-Wno-error=undef",
|
||||
"-Wno-error=shadow",
|
||||
"-Wno-error=unknown-pragmas",
|
||||
],
|
||||
extra_linker_flags = ["-framework CoreFoundation"],
|
||||
linker_path = "/usr/tools",
|
||||
|
|
@ -134,6 +140,9 @@ cc_toolchain_config(
|
|||
extra_compiler_flags = [
|
||||
"-isystem/usr/lib/gcc/i686-w64-mingw32/10-posix/include/c++",
|
||||
"-isystem/usr/lib/gcc/i686-w64-mingw32/10-posix/include/c++/i686-w64-mingw32",
|
||||
"-Wno-error=undef",
|
||||
"-Wno-error=shadow",
|
||||
"-Wno-error=unknown-pragmas",
|
||||
],
|
||||
extra_include = "/usr/lib/gcc/i686-w64-mingw32",
|
||||
extra_linker_flags = [
|
||||
|
|
@ -152,6 +161,9 @@ cc_toolchain_config(
|
|||
extra_compiler_flags = [
|
||||
"-isystem/usr/lib/gcc/x86_64-w64-mingw32/10-posix/include/c++/",
|
||||
"-isystem/usr/lib/gcc/x86_64-w64-mingw32/10-posix/include/c++/x86_64-w64-mingw32",
|
||||
"-Wno-error=undef",
|
||||
"-Wno-error=shadow",
|
||||
"-Wno-error=unknown-pragmas",
|
||||
],
|
||||
extra_include = "/usr/lib/gcc/x86_64-w64-mingw32/10-posix/include",
|
||||
extra_linker_flags = [
|
||||
|
|
|
|||
|
|
@ -50,6 +50,8 @@ cc_test(
|
|||
"//upb/base",
|
||||
"//upb/mem",
|
||||
"//upb/reflection",
|
||||
"//upb/reflection:internal_cc",
|
||||
"//upb/reflection:reflection_cc",
|
||||
"@googletest//:gtest",
|
||||
"@googletest//:gtest_main",
|
||||
],
|
||||
|
|
@ -68,6 +70,8 @@ cc_test(
|
|||
"//upb/base",
|
||||
"//upb/mem",
|
||||
"//upb/reflection",
|
||||
"//upb/reflection:internal_cc",
|
||||
"//upb/reflection:reflection_cc",
|
||||
"@googletest//:gtest",
|
||||
"@googletest//:gtest_main",
|
||||
],
|
||||
|
|
|
|||
|
|
@ -579,6 +579,9 @@ cc_test(
|
|||
"//upb/mini_table:internal",
|
||||
"//upb/port",
|
||||
"//upb/reflection",
|
||||
"//upb/reflection:internal",
|
||||
"//upb/reflection:internal_cc",
|
||||
"//upb/reflection:reflection_cc",
|
||||
"//upb/test:fuzz_util",
|
||||
"//upb/test:test_messages_proto3_upb_proto",
|
||||
"//upb/text:debug",
|
||||
|
|
|
|||
|
|
@ -38,9 +38,7 @@ bootstrap_cc_library(
|
|||
name = "reflection",
|
||||
hdrs = [
|
||||
"def.h",
|
||||
"def.hpp",
|
||||
"message.h",
|
||||
"message.hpp",
|
||||
],
|
||||
bootstrap_deps = [
|
||||
":internal",
|
||||
|
|
@ -60,10 +58,30 @@ bootstrap_cc_library(
|
|||
],
|
||||
)
|
||||
|
||||
alias(
|
||||
bootstrap_cc_library(
|
||||
name = "reflection_cc",
|
||||
actual = ":reflection",
|
||||
hdrs = [
|
||||
"def.hpp",
|
||||
"message.hpp",
|
||||
],
|
||||
bootstrap_deps = [
|
||||
":descriptor_upb_proto",
|
||||
":internal",
|
||||
":internal_cc",
|
||||
":reflection",
|
||||
],
|
||||
copts = UPB_DEFAULT_COPTS,
|
||||
features = UPB_DEFAULT_FEATURES,
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//upb/base",
|
||||
"//upb/mem",
|
||||
"//upb/message",
|
||||
"//upb/mini_descriptor",
|
||||
"//upb/mini_table",
|
||||
"//upb/port",
|
||||
"@abseil-cpp//absl/log:absl_check",
|
||||
],
|
||||
)
|
||||
|
||||
bootstrap_cc_library(
|
||||
|
|
@ -92,7 +110,6 @@ bootstrap_cc_library(
|
|||
hdrs = [
|
||||
"common.h",
|
||||
"def.h",
|
||||
"def.hpp",
|
||||
"def_pool.h",
|
||||
"def_type.h",
|
||||
"enum_def.h",
|
||||
|
|
@ -116,7 +133,6 @@ bootstrap_cc_library(
|
|||
"internal/service_def.h",
|
||||
"internal/upb_edition_defaults.h",
|
||||
"message.h",
|
||||
"message.hpp",
|
||||
"message_def.h",
|
||||
"message_reserved_range.h",
|
||||
"method_def.h",
|
||||
|
|
@ -144,10 +160,28 @@ bootstrap_cc_library(
|
|||
],
|
||||
)
|
||||
|
||||
alias(
|
||||
bootstrap_cc_library(
|
||||
name = "internal_cc",
|
||||
actual = ":internal",
|
||||
hdrs = [
|
||||
"def.hpp",
|
||||
"message.hpp",
|
||||
],
|
||||
bootstrap_deps = [
|
||||
":descriptor_upb_proto",
|
||||
":internal",
|
||||
],
|
||||
copts = UPB_DEFAULT_COPTS,
|
||||
features = UPB_DEFAULT_FEATURES,
|
||||
visibility = ["//upb:__subpackages__"],
|
||||
deps = [
|
||||
"//upb/base",
|
||||
"//upb/mem",
|
||||
"//upb/message",
|
||||
"//upb/mini_descriptor",
|
||||
"//upb/mini_table",
|
||||
"//upb/port",
|
||||
"@abseil-cpp//absl/log:absl_check",
|
||||
],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
|
|
@ -200,7 +234,9 @@ cc_test(
|
|||
],
|
||||
deps = [
|
||||
":internal",
|
||||
":internal_cc",
|
||||
":reflection",
|
||||
":reflection_cc",
|
||||
"//src/google/protobuf",
|
||||
"//src/google/protobuf:descriptor_upb_c_proto",
|
||||
"//src/google/protobuf:unittest_upb_reflection_proto",
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "absl/log/absl_check.h"
|
||||
#include "upb/base/descriptor_constants.h"
|
||||
#include "upb/base/status.hpp"
|
||||
#include "upb/base/string_view.h"
|
||||
|
|
@ -27,7 +28,6 @@
|
|||
#include "upb/reflection/descriptor_bootstrap.h"
|
||||
#include "upb/reflection/internal/def_pool.h"
|
||||
#include "upb/reflection/internal/enum_def.h"
|
||||
#include "upb/reflection/message.h"
|
||||
|
||||
// Must be last
|
||||
#include "upb/port/def.inc"
|
||||
|
|
@ -65,7 +65,9 @@ class FieldDefPtr {
|
|||
std::string MiniDescriptorEncode() const {
|
||||
upb::Arena arena;
|
||||
upb_StringView md;
|
||||
upb_FieldDef_MiniDescriptorEncode(ptr_, arena.ptr(), &md);
|
||||
// TODO: Change to absl::ThrowStdBadAlloc once our min absl version is above
|
||||
// 202603
|
||||
ABSL_CHECK(upb_FieldDef_MiniDescriptorEncode(ptr_, arena.ptr(), &md));
|
||||
return std::string(md.data, md.size);
|
||||
}
|
||||
|
||||
|
|
@ -207,7 +209,9 @@ class MessageDefPtr {
|
|||
std::string MiniDescriptorEncode() const {
|
||||
upb::Arena arena;
|
||||
upb_StringView md;
|
||||
upb_MessageDef_MiniDescriptorEncode(ptr_, arena.ptr(), &md);
|
||||
// TODO: Change to absl::ThrowStdBadAlloc once our min absl version is above
|
||||
// 202603
|
||||
ABSL_CHECK(upb_MessageDef_MiniDescriptorEncode(ptr_, arena.ptr(), &md));
|
||||
return std::string(md.data, md.size);
|
||||
}
|
||||
|
||||
|
|
@ -423,7 +427,9 @@ class EnumDefPtr {
|
|||
std::string MiniDescriptorEncode() const {
|
||||
upb::Arena arena;
|
||||
upb_StringView md;
|
||||
upb_EnumDef_MiniDescriptorEncode(ptr_, arena.ptr(), &md);
|
||||
// TODO: Change to absl::ThrowStdBadAlloc once our min absl version is above
|
||||
// 202603
|
||||
ABSL_CHECK(upb_EnumDef_MiniDescriptorEncode(ptr_, arena.ptr(), &md));
|
||||
return std::string(md.data, md.size);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -218,6 +218,8 @@ cc_test(
|
|||
":proto3_test_upb_proto",
|
||||
":proto3_test_upb_proto_reflection",
|
||||
"//upb/reflection",
|
||||
"//upb/reflection:internal_cc",
|
||||
"//upb/reflection:reflection_cc",
|
||||
"@googletest//:gtest",
|
||||
"@googletest//:gtest_main",
|
||||
],
|
||||
|
|
@ -239,6 +241,8 @@ cc_test(
|
|||
"//upb/port",
|
||||
"//upb/reflection",
|
||||
"//upb/reflection:descriptor_upb_proto",
|
||||
"//upb/reflection:internal_cc",
|
||||
"//upb/reflection:reflection_cc",
|
||||
"@googletest//:gtest",
|
||||
"@googletest//:gtest_main",
|
||||
],
|
||||
|
|
@ -278,6 +282,8 @@ cc_test(
|
|||
"//upb/json",
|
||||
"//upb/port",
|
||||
"//upb/reflection",
|
||||
"//upb/reflection:internal_cc",
|
||||
"//upb/reflection:reflection_cc",
|
||||
"@googletest//:gtest",
|
||||
"@googletest//:gtest_main",
|
||||
],
|
||||
|
|
|
|||
|
|
@ -61,6 +61,8 @@ cc_library(
|
|||
"//upb/base",
|
||||
"//upb/mem",
|
||||
"//upb/reflection:internal",
|
||||
"//upb/reflection:internal_cc",
|
||||
"//upb/reflection:reflection_cc",
|
||||
"@googletest//:gtest",
|
||||
],
|
||||
)
|
||||
|
|
@ -82,6 +84,8 @@ cc_test(
|
|||
"//upb/base",
|
||||
"//upb/mem",
|
||||
"//upb/reflection",
|
||||
"//upb/reflection:internal_cc",
|
||||
"//upb/reflection:reflection_cc",
|
||||
"//upb/test:parse_text_proto",
|
||||
"@abseil-cpp//absl/strings",
|
||||
"@googletest//:gtest",
|
||||
|
|
@ -150,6 +154,8 @@ cc_test(
|
|||
"//upb/mem",
|
||||
"//upb/reflection",
|
||||
"//upb/reflection:internal",
|
||||
"//upb/reflection:internal_cc",
|
||||
"//upb/reflection:reflection_cc",
|
||||
"@abseil-cpp//absl/strings",
|
||||
"@googletest//:gtest",
|
||||
"@googletest//:gtest_main",
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ bootstrap_cc_library(
|
|||
"common.h",
|
||||
],
|
||||
bootstrap_deps = [
|
||||
"//upb/reflection:reflection",
|
||||
"//upb/reflection:reflection_cc",
|
||||
],
|
||||
copts = UPB_DEFAULT_CPPOPTS,
|
||||
features = UPB_DEFAULT_FEATURES,
|
||||
|
|
@ -64,6 +64,7 @@ bootstrap_cc_library(
|
|||
bootstrap_deps = [
|
||||
":common",
|
||||
"//upb/reflection:reflection",
|
||||
"//upb/reflection:reflection_cc",
|
||||
"//upb/reflection:descriptor_upb_proto",
|
||||
],
|
||||
copts = UPB_DEFAULT_CPPOPTS,
|
||||
|
|
@ -90,7 +91,7 @@ bootstrap_cc_library(
|
|||
bootstrap_deps = [
|
||||
":plugin_upb_proto",
|
||||
"//upb/reflection:descriptor_upb_proto",
|
||||
"//upb/reflection:reflection",
|
||||
"//upb/reflection:reflection_cc",
|
||||
"//upb_generator:file_layout",
|
||||
],
|
||||
copts = UPB_DEFAULT_CPPOPTS,
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ bootstrap_cc_binary(
|
|||
"//upb_generator:file_layout",
|
||||
"//upb_generator:plugin",
|
||||
"//upb/reflection:descriptor_upb_proto",
|
||||
"//upb/reflection:reflection",
|
||||
"//upb/reflection:reflection_cc",
|
||||
],
|
||||
copts = UPB_DEFAULT_CPPOPTS,
|
||||
features = UPB_DEFAULT_FEATURES,
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ cc_library(
|
|||
"//upb/base",
|
||||
"//upb/mem",
|
||||
"//upb/mini_table",
|
||||
"//upb/reflection",
|
||||
"//upb/reflection:reflection_cc",
|
||||
"@abseil-cpp//absl/container:flat_hash_set",
|
||||
"@abseil-cpp//absl/log:absl_check",
|
||||
],
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ bootstrap_cc_library(
|
|||
"//upb_generator:common",
|
||||
"//upb_generator:file_layout",
|
||||
"//upb/reflection:descriptor_upb_proto",
|
||||
"//upb/reflection:reflection",
|
||||
"//upb/reflection:reflection_cc",
|
||||
],
|
||||
copts = UPB_DEFAULT_CPPOPTS,
|
||||
features = UPB_DEFAULT_FEATURES,
|
||||
|
|
@ -93,7 +93,7 @@ bootstrap_cc_binary(
|
|||
"//upb_generator:file_layout",
|
||||
"//upb_generator:common",
|
||||
"//upb_generator:plugin",
|
||||
"//upb/reflection:reflection",
|
||||
"//upb/reflection:reflection_cc",
|
||||
],
|
||||
copts = UPB_DEFAULT_CPPOPTS,
|
||||
features = UPB_DEFAULT_FEATURES,
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ cc_binary(
|
|||
"//src/google/protobuf/io:printer",
|
||||
"//upb/mem",
|
||||
"//upb/port",
|
||||
"//upb/reflection",
|
||||
"//upb/reflection:reflection_cc",
|
||||
"//upb/util:def_to_proto",
|
||||
"//upb_generator:common",
|
||||
"//upb_generator:file_layout",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue