Protocol Buffers - Google's data interchange format (grpc依赖) https://developers.google.com/protocol-buffers/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

119 lines
3.3 KiB

// 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
#ifndef UPB_MINI_TABLE_ENCODE_INTERNAL_HPP_
#define UPB_MINI_TABLE_ENCODE_INTERNAL_HPP_
#include <string>
#include "upb/base/internal/log2.h"
#include "upb/mini_descriptor/internal/encode.h"
namespace upb {
class MtDataEncoder {
public:
MtDataEncoder() : appender_(&encoder_) {}
bool StartMessage(uint64_t msg_mod) {
Cherry-pick recent changes from the upb repo (#13908) I merged a handful of PRs on the upb repo after upb moved into the protobuf repo. This PR cherry-picks them here so that they will not be lost. ``` commit 7afb426a5ace6f6e76ac2144960363379a1be08d Author: Keith Smiley <keithbsmiley@gmail.com> Date: Thu Sep 7 11:36:01 2023 -0700 [bazel] Fix disallowing dylibs on darwin (#1180) Since this bazel commit https://github.com/bazelbuild/bazel/commit/ec5553352f2f661d39ac4cf665dd9b3c779e614c building dylibs like the ones in this rule on darwin platforms has been unsupported. This feature is a default C++ toolchain feature to indicate this. In bazel 7.x these dylibs will fail to link if they are still built. As far as I can tell in the tests even if they are built they are never used on macOS. Co-authored-by: Adam Cozzette <acozzette@google.com> commit 72decab5eca0110548b0c805275fffab562aebde Author: Keith Smiley <keithbsmiley@gmail.com> Date: Thu Sep 7 09:42:20 2023 -0700 Add missing darwin_x86_64 CPU (#1181) This CPU is often used when cross compiling from M1 machines. I'm also hoping we can remove the legacy 'darwin' CPU. commit ccadaf3196bda975dec5ed2aac8a78e75ab51c1b Author: messense <messense@icloud.com> Date: Fri Sep 8 00:28:54 2023 +0800 Fix `PyUpb_Message_MergeInternal` segfault (#1338) when `PyUpb_Message_MergeFromString` returns `NULL`, currently `PyUpb_Message_MergeInternal` will call `Py_DECREF` on `NULL` which results in a segmentation fault. This patch switches to `Py_XDECREF` to fix the segfault. commit 2a5724d86ea81e0c2a0f8d10db274821c8bb6656 Author: Kevin Greene <kgreenek@gmail.com> Date: Wed Sep 6 16:46:35 2023 -0700 Fix lambda capture compiler error with c++20 (#1502) When compiling with C++20, the following error is produced: ``` upb/mini_table.hpp:63:22: note: add explicit 'this' or '*this' capture upb/mini_table.hpp: In lambda function: upb/mini_table.hpp:71:22: error: implicit capture of 'this' via '[=]' is deprecated in C++20 [-Werror=deprecated] 71 | return appender_([=](char* buf) { ``` In C++20, it is no longer allowed to implicitly capture 'this' in a lambda using [=]. This commit explicitly captures required values in the appropriate lambdas and removes all uses of [=] with lambdas. ``` Closes #13908 COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/13908 from acozzette:upb 7afb426a5ace6f6e76ac2144960363379a1be08d PiperOrigin-RevId: 563784513
1 year ago
return appender_([this, msg_mod](char* buf) {
return upb_MtDataEncoder_StartMessage(&encoder_, buf, msg_mod);
});
}
bool PutField(upb_FieldType type, uint32_t field_num, uint64_t field_mod) {
Cherry-pick recent changes from the upb repo (#13908) I merged a handful of PRs on the upb repo after upb moved into the protobuf repo. This PR cherry-picks them here so that they will not be lost. ``` commit 7afb426a5ace6f6e76ac2144960363379a1be08d Author: Keith Smiley <keithbsmiley@gmail.com> Date: Thu Sep 7 11:36:01 2023 -0700 [bazel] Fix disallowing dylibs on darwin (#1180) Since this bazel commit https://github.com/bazelbuild/bazel/commit/ec5553352f2f661d39ac4cf665dd9b3c779e614c building dylibs like the ones in this rule on darwin platforms has been unsupported. This feature is a default C++ toolchain feature to indicate this. In bazel 7.x these dylibs will fail to link if they are still built. As far as I can tell in the tests even if they are built they are never used on macOS. Co-authored-by: Adam Cozzette <acozzette@google.com> commit 72decab5eca0110548b0c805275fffab562aebde Author: Keith Smiley <keithbsmiley@gmail.com> Date: Thu Sep 7 09:42:20 2023 -0700 Add missing darwin_x86_64 CPU (#1181) This CPU is often used when cross compiling from M1 machines. I'm also hoping we can remove the legacy 'darwin' CPU. commit ccadaf3196bda975dec5ed2aac8a78e75ab51c1b Author: messense <messense@icloud.com> Date: Fri Sep 8 00:28:54 2023 +0800 Fix `PyUpb_Message_MergeInternal` segfault (#1338) when `PyUpb_Message_MergeFromString` returns `NULL`, currently `PyUpb_Message_MergeInternal` will call `Py_DECREF` on `NULL` which results in a segmentation fault. This patch switches to `Py_XDECREF` to fix the segfault. commit 2a5724d86ea81e0c2a0f8d10db274821c8bb6656 Author: Kevin Greene <kgreenek@gmail.com> Date: Wed Sep 6 16:46:35 2023 -0700 Fix lambda capture compiler error with c++20 (#1502) When compiling with C++20, the following error is produced: ``` upb/mini_table.hpp:63:22: note: add explicit 'this' or '*this' capture upb/mini_table.hpp: In lambda function: upb/mini_table.hpp:71:22: error: implicit capture of 'this' via '[=]' is deprecated in C++20 [-Werror=deprecated] 71 | return appender_([=](char* buf) { ``` In C++20, it is no longer allowed to implicitly capture 'this' in a lambda using [=]. This commit explicitly captures required values in the appropriate lambdas and removes all uses of [=] with lambdas. ``` Closes #13908 COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/13908 from acozzette:upb 7afb426a5ace6f6e76ac2144960363379a1be08d PiperOrigin-RevId: 563784513
1 year ago
return appender_([this, type, field_num, field_mod](char* buf) {
return upb_MtDataEncoder_PutField(&encoder_, buf, type, field_num,
field_mod);
});
}
bool StartOneof() {
Cherry-pick recent changes from the upb repo (#13908) I merged a handful of PRs on the upb repo after upb moved into the protobuf repo. This PR cherry-picks them here so that they will not be lost. ``` commit 7afb426a5ace6f6e76ac2144960363379a1be08d Author: Keith Smiley <keithbsmiley@gmail.com> Date: Thu Sep 7 11:36:01 2023 -0700 [bazel] Fix disallowing dylibs on darwin (#1180) Since this bazel commit https://github.com/bazelbuild/bazel/commit/ec5553352f2f661d39ac4cf665dd9b3c779e614c building dylibs like the ones in this rule on darwin platforms has been unsupported. This feature is a default C++ toolchain feature to indicate this. In bazel 7.x these dylibs will fail to link if they are still built. As far as I can tell in the tests even if they are built they are never used on macOS. Co-authored-by: Adam Cozzette <acozzette@google.com> commit 72decab5eca0110548b0c805275fffab562aebde Author: Keith Smiley <keithbsmiley@gmail.com> Date: Thu Sep 7 09:42:20 2023 -0700 Add missing darwin_x86_64 CPU (#1181) This CPU is often used when cross compiling from M1 machines. I'm also hoping we can remove the legacy 'darwin' CPU. commit ccadaf3196bda975dec5ed2aac8a78e75ab51c1b Author: messense <messense@icloud.com> Date: Fri Sep 8 00:28:54 2023 +0800 Fix `PyUpb_Message_MergeInternal` segfault (#1338) when `PyUpb_Message_MergeFromString` returns `NULL`, currently `PyUpb_Message_MergeInternal` will call `Py_DECREF` on `NULL` which results in a segmentation fault. This patch switches to `Py_XDECREF` to fix the segfault. commit 2a5724d86ea81e0c2a0f8d10db274821c8bb6656 Author: Kevin Greene <kgreenek@gmail.com> Date: Wed Sep 6 16:46:35 2023 -0700 Fix lambda capture compiler error with c++20 (#1502) When compiling with C++20, the following error is produced: ``` upb/mini_table.hpp:63:22: note: add explicit 'this' or '*this' capture upb/mini_table.hpp: In lambda function: upb/mini_table.hpp:71:22: error: implicit capture of 'this' via '[=]' is deprecated in C++20 [-Werror=deprecated] 71 | return appender_([=](char* buf) { ``` In C++20, it is no longer allowed to implicitly capture 'this' in a lambda using [=]. This commit explicitly captures required values in the appropriate lambdas and removes all uses of [=] with lambdas. ``` Closes #13908 COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/13908 from acozzette:upb 7afb426a5ace6f6e76ac2144960363379a1be08d PiperOrigin-RevId: 563784513
1 year ago
return appender_([this](char* buf) {
return upb_MtDataEncoder_StartOneof(&encoder_, buf);
});
}
bool PutOneofField(uint32_t field_num) {
Cherry-pick recent changes from the upb repo (#13908) I merged a handful of PRs on the upb repo after upb moved into the protobuf repo. This PR cherry-picks them here so that they will not be lost. ``` commit 7afb426a5ace6f6e76ac2144960363379a1be08d Author: Keith Smiley <keithbsmiley@gmail.com> Date: Thu Sep 7 11:36:01 2023 -0700 [bazel] Fix disallowing dylibs on darwin (#1180) Since this bazel commit https://github.com/bazelbuild/bazel/commit/ec5553352f2f661d39ac4cf665dd9b3c779e614c building dylibs like the ones in this rule on darwin platforms has been unsupported. This feature is a default C++ toolchain feature to indicate this. In bazel 7.x these dylibs will fail to link if they are still built. As far as I can tell in the tests even if they are built they are never used on macOS. Co-authored-by: Adam Cozzette <acozzette@google.com> commit 72decab5eca0110548b0c805275fffab562aebde Author: Keith Smiley <keithbsmiley@gmail.com> Date: Thu Sep 7 09:42:20 2023 -0700 Add missing darwin_x86_64 CPU (#1181) This CPU is often used when cross compiling from M1 machines. I'm also hoping we can remove the legacy 'darwin' CPU. commit ccadaf3196bda975dec5ed2aac8a78e75ab51c1b Author: messense <messense@icloud.com> Date: Fri Sep 8 00:28:54 2023 +0800 Fix `PyUpb_Message_MergeInternal` segfault (#1338) when `PyUpb_Message_MergeFromString` returns `NULL`, currently `PyUpb_Message_MergeInternal` will call `Py_DECREF` on `NULL` which results in a segmentation fault. This patch switches to `Py_XDECREF` to fix the segfault. commit 2a5724d86ea81e0c2a0f8d10db274821c8bb6656 Author: Kevin Greene <kgreenek@gmail.com> Date: Wed Sep 6 16:46:35 2023 -0700 Fix lambda capture compiler error with c++20 (#1502) When compiling with C++20, the following error is produced: ``` upb/mini_table.hpp:63:22: note: add explicit 'this' or '*this' capture upb/mini_table.hpp: In lambda function: upb/mini_table.hpp:71:22: error: implicit capture of 'this' via '[=]' is deprecated in C++20 [-Werror=deprecated] 71 | return appender_([=](char* buf) { ``` In C++20, it is no longer allowed to implicitly capture 'this' in a lambda using [=]. This commit explicitly captures required values in the appropriate lambdas and removes all uses of [=] with lambdas. ``` Closes #13908 COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/13908 from acozzette:upb 7afb426a5ace6f6e76ac2144960363379a1be08d PiperOrigin-RevId: 563784513
1 year ago
return appender_([this, field_num](char* buf) {
return upb_MtDataEncoder_PutOneofField(&encoder_, buf, field_num);
});
}
bool StartEnum() {
Cherry-pick recent changes from the upb repo (#13908) I merged a handful of PRs on the upb repo after upb moved into the protobuf repo. This PR cherry-picks them here so that they will not be lost. ``` commit 7afb426a5ace6f6e76ac2144960363379a1be08d Author: Keith Smiley <keithbsmiley@gmail.com> Date: Thu Sep 7 11:36:01 2023 -0700 [bazel] Fix disallowing dylibs on darwin (#1180) Since this bazel commit https://github.com/bazelbuild/bazel/commit/ec5553352f2f661d39ac4cf665dd9b3c779e614c building dylibs like the ones in this rule on darwin platforms has been unsupported. This feature is a default C++ toolchain feature to indicate this. In bazel 7.x these dylibs will fail to link if they are still built. As far as I can tell in the tests even if they are built they are never used on macOS. Co-authored-by: Adam Cozzette <acozzette@google.com> commit 72decab5eca0110548b0c805275fffab562aebde Author: Keith Smiley <keithbsmiley@gmail.com> Date: Thu Sep 7 09:42:20 2023 -0700 Add missing darwin_x86_64 CPU (#1181) This CPU is often used when cross compiling from M1 machines. I'm also hoping we can remove the legacy 'darwin' CPU. commit ccadaf3196bda975dec5ed2aac8a78e75ab51c1b Author: messense <messense@icloud.com> Date: Fri Sep 8 00:28:54 2023 +0800 Fix `PyUpb_Message_MergeInternal` segfault (#1338) when `PyUpb_Message_MergeFromString` returns `NULL`, currently `PyUpb_Message_MergeInternal` will call `Py_DECREF` on `NULL` which results in a segmentation fault. This patch switches to `Py_XDECREF` to fix the segfault. commit 2a5724d86ea81e0c2a0f8d10db274821c8bb6656 Author: Kevin Greene <kgreenek@gmail.com> Date: Wed Sep 6 16:46:35 2023 -0700 Fix lambda capture compiler error with c++20 (#1502) When compiling with C++20, the following error is produced: ``` upb/mini_table.hpp:63:22: note: add explicit 'this' or '*this' capture upb/mini_table.hpp: In lambda function: upb/mini_table.hpp:71:22: error: implicit capture of 'this' via '[=]' is deprecated in C++20 [-Werror=deprecated] 71 | return appender_([=](char* buf) { ``` In C++20, it is no longer allowed to implicitly capture 'this' in a lambda using [=]. This commit explicitly captures required values in the appropriate lambdas and removes all uses of [=] with lambdas. ``` Closes #13908 COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/13908 from acozzette:upb 7afb426a5ace6f6e76ac2144960363379a1be08d PiperOrigin-RevId: 563784513
1 year ago
return appender_([this](char* buf) {
return upb_MtDataEncoder_StartEnum(&encoder_, buf);
});
}
bool PutEnumValue(uint32_t enum_value) {
Cherry-pick recent changes from the upb repo (#13908) I merged a handful of PRs on the upb repo after upb moved into the protobuf repo. This PR cherry-picks them here so that they will not be lost. ``` commit 7afb426a5ace6f6e76ac2144960363379a1be08d Author: Keith Smiley <keithbsmiley@gmail.com> Date: Thu Sep 7 11:36:01 2023 -0700 [bazel] Fix disallowing dylibs on darwin (#1180) Since this bazel commit https://github.com/bazelbuild/bazel/commit/ec5553352f2f661d39ac4cf665dd9b3c779e614c building dylibs like the ones in this rule on darwin platforms has been unsupported. This feature is a default C++ toolchain feature to indicate this. In bazel 7.x these dylibs will fail to link if they are still built. As far as I can tell in the tests even if they are built they are never used on macOS. Co-authored-by: Adam Cozzette <acozzette@google.com> commit 72decab5eca0110548b0c805275fffab562aebde Author: Keith Smiley <keithbsmiley@gmail.com> Date: Thu Sep 7 09:42:20 2023 -0700 Add missing darwin_x86_64 CPU (#1181) This CPU is often used when cross compiling from M1 machines. I'm also hoping we can remove the legacy 'darwin' CPU. commit ccadaf3196bda975dec5ed2aac8a78e75ab51c1b Author: messense <messense@icloud.com> Date: Fri Sep 8 00:28:54 2023 +0800 Fix `PyUpb_Message_MergeInternal` segfault (#1338) when `PyUpb_Message_MergeFromString` returns `NULL`, currently `PyUpb_Message_MergeInternal` will call `Py_DECREF` on `NULL` which results in a segmentation fault. This patch switches to `Py_XDECREF` to fix the segfault. commit 2a5724d86ea81e0c2a0f8d10db274821c8bb6656 Author: Kevin Greene <kgreenek@gmail.com> Date: Wed Sep 6 16:46:35 2023 -0700 Fix lambda capture compiler error with c++20 (#1502) When compiling with C++20, the following error is produced: ``` upb/mini_table.hpp:63:22: note: add explicit 'this' or '*this' capture upb/mini_table.hpp: In lambda function: upb/mini_table.hpp:71:22: error: implicit capture of 'this' via '[=]' is deprecated in C++20 [-Werror=deprecated] 71 | return appender_([=](char* buf) { ``` In C++20, it is no longer allowed to implicitly capture 'this' in a lambda using [=]. This commit explicitly captures required values in the appropriate lambdas and removes all uses of [=] with lambdas. ``` Closes #13908 COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/13908 from acozzette:upb 7afb426a5ace6f6e76ac2144960363379a1be08d PiperOrigin-RevId: 563784513
1 year ago
return appender_([this, enum_value](char* buf) {
return upb_MtDataEncoder_PutEnumValue(&encoder_, buf, enum_value);
});
}
bool EndEnum() {
Cherry-pick recent changes from the upb repo (#13908) I merged a handful of PRs on the upb repo after upb moved into the protobuf repo. This PR cherry-picks them here so that they will not be lost. ``` commit 7afb426a5ace6f6e76ac2144960363379a1be08d Author: Keith Smiley <keithbsmiley@gmail.com> Date: Thu Sep 7 11:36:01 2023 -0700 [bazel] Fix disallowing dylibs on darwin (#1180) Since this bazel commit https://github.com/bazelbuild/bazel/commit/ec5553352f2f661d39ac4cf665dd9b3c779e614c building dylibs like the ones in this rule on darwin platforms has been unsupported. This feature is a default C++ toolchain feature to indicate this. In bazel 7.x these dylibs will fail to link if they are still built. As far as I can tell in the tests even if they are built they are never used on macOS. Co-authored-by: Adam Cozzette <acozzette@google.com> commit 72decab5eca0110548b0c805275fffab562aebde Author: Keith Smiley <keithbsmiley@gmail.com> Date: Thu Sep 7 09:42:20 2023 -0700 Add missing darwin_x86_64 CPU (#1181) This CPU is often used when cross compiling from M1 machines. I'm also hoping we can remove the legacy 'darwin' CPU. commit ccadaf3196bda975dec5ed2aac8a78e75ab51c1b Author: messense <messense@icloud.com> Date: Fri Sep 8 00:28:54 2023 +0800 Fix `PyUpb_Message_MergeInternal` segfault (#1338) when `PyUpb_Message_MergeFromString` returns `NULL`, currently `PyUpb_Message_MergeInternal` will call `Py_DECREF` on `NULL` which results in a segmentation fault. This patch switches to `Py_XDECREF` to fix the segfault. commit 2a5724d86ea81e0c2a0f8d10db274821c8bb6656 Author: Kevin Greene <kgreenek@gmail.com> Date: Wed Sep 6 16:46:35 2023 -0700 Fix lambda capture compiler error with c++20 (#1502) When compiling with C++20, the following error is produced: ``` upb/mini_table.hpp:63:22: note: add explicit 'this' or '*this' capture upb/mini_table.hpp: In lambda function: upb/mini_table.hpp:71:22: error: implicit capture of 'this' via '[=]' is deprecated in C++20 [-Werror=deprecated] 71 | return appender_([=](char* buf) { ``` In C++20, it is no longer allowed to implicitly capture 'this' in a lambda using [=]. This commit explicitly captures required values in the appropriate lambdas and removes all uses of [=] with lambdas. ``` Closes #13908 COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/13908 from acozzette:upb 7afb426a5ace6f6e76ac2144960363379a1be08d PiperOrigin-RevId: 563784513
1 year ago
return appender_([this](char* buf) {
return upb_MtDataEncoder_EndEnum(&encoder_, buf);
});
}
bool EncodeExtension(upb_FieldType type, uint32_t field_num,
uint64_t field_mod) {
Cherry-pick recent changes from the upb repo (#13908) I merged a handful of PRs on the upb repo after upb moved into the protobuf repo. This PR cherry-picks them here so that they will not be lost. ``` commit 7afb426a5ace6f6e76ac2144960363379a1be08d Author: Keith Smiley <keithbsmiley@gmail.com> Date: Thu Sep 7 11:36:01 2023 -0700 [bazel] Fix disallowing dylibs on darwin (#1180) Since this bazel commit https://github.com/bazelbuild/bazel/commit/ec5553352f2f661d39ac4cf665dd9b3c779e614c building dylibs like the ones in this rule on darwin platforms has been unsupported. This feature is a default C++ toolchain feature to indicate this. In bazel 7.x these dylibs will fail to link if they are still built. As far as I can tell in the tests even if they are built they are never used on macOS. Co-authored-by: Adam Cozzette <acozzette@google.com> commit 72decab5eca0110548b0c805275fffab562aebde Author: Keith Smiley <keithbsmiley@gmail.com> Date: Thu Sep 7 09:42:20 2023 -0700 Add missing darwin_x86_64 CPU (#1181) This CPU is often used when cross compiling from M1 machines. I'm also hoping we can remove the legacy 'darwin' CPU. commit ccadaf3196bda975dec5ed2aac8a78e75ab51c1b Author: messense <messense@icloud.com> Date: Fri Sep 8 00:28:54 2023 +0800 Fix `PyUpb_Message_MergeInternal` segfault (#1338) when `PyUpb_Message_MergeFromString` returns `NULL`, currently `PyUpb_Message_MergeInternal` will call `Py_DECREF` on `NULL` which results in a segmentation fault. This patch switches to `Py_XDECREF` to fix the segfault. commit 2a5724d86ea81e0c2a0f8d10db274821c8bb6656 Author: Kevin Greene <kgreenek@gmail.com> Date: Wed Sep 6 16:46:35 2023 -0700 Fix lambda capture compiler error with c++20 (#1502) When compiling with C++20, the following error is produced: ``` upb/mini_table.hpp:63:22: note: add explicit 'this' or '*this' capture upb/mini_table.hpp: In lambda function: upb/mini_table.hpp:71:22: error: implicit capture of 'this' via '[=]' is deprecated in C++20 [-Werror=deprecated] 71 | return appender_([=](char* buf) { ``` In C++20, it is no longer allowed to implicitly capture 'this' in a lambda using [=]. This commit explicitly captures required values in the appropriate lambdas and removes all uses of [=] with lambdas. ``` Closes #13908 COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/13908 from acozzette:upb 7afb426a5ace6f6e76ac2144960363379a1be08d PiperOrigin-RevId: 563784513
1 year ago
return appender_([this, type, field_num, field_mod](char* buf) {
return upb_MtDataEncoder_EncodeExtension(&encoder_, buf, type, field_num,
field_mod);
});
}
bool EncodeMap(upb_FieldType key_type, upb_FieldType val_type,
uint64_t key_mod, uint64_t val_mod) {
Cherry-pick recent changes from the upb repo (#13908) I merged a handful of PRs on the upb repo after upb moved into the protobuf repo. This PR cherry-picks them here so that they will not be lost. ``` commit 7afb426a5ace6f6e76ac2144960363379a1be08d Author: Keith Smiley <keithbsmiley@gmail.com> Date: Thu Sep 7 11:36:01 2023 -0700 [bazel] Fix disallowing dylibs on darwin (#1180) Since this bazel commit https://github.com/bazelbuild/bazel/commit/ec5553352f2f661d39ac4cf665dd9b3c779e614c building dylibs like the ones in this rule on darwin platforms has been unsupported. This feature is a default C++ toolchain feature to indicate this. In bazel 7.x these dylibs will fail to link if they are still built. As far as I can tell in the tests even if they are built they are never used on macOS. Co-authored-by: Adam Cozzette <acozzette@google.com> commit 72decab5eca0110548b0c805275fffab562aebde Author: Keith Smiley <keithbsmiley@gmail.com> Date: Thu Sep 7 09:42:20 2023 -0700 Add missing darwin_x86_64 CPU (#1181) This CPU is often used when cross compiling from M1 machines. I'm also hoping we can remove the legacy 'darwin' CPU. commit ccadaf3196bda975dec5ed2aac8a78e75ab51c1b Author: messense <messense@icloud.com> Date: Fri Sep 8 00:28:54 2023 +0800 Fix `PyUpb_Message_MergeInternal` segfault (#1338) when `PyUpb_Message_MergeFromString` returns `NULL`, currently `PyUpb_Message_MergeInternal` will call `Py_DECREF` on `NULL` which results in a segmentation fault. This patch switches to `Py_XDECREF` to fix the segfault. commit 2a5724d86ea81e0c2a0f8d10db274821c8bb6656 Author: Kevin Greene <kgreenek@gmail.com> Date: Wed Sep 6 16:46:35 2023 -0700 Fix lambda capture compiler error with c++20 (#1502) When compiling with C++20, the following error is produced: ``` upb/mini_table.hpp:63:22: note: add explicit 'this' or '*this' capture upb/mini_table.hpp: In lambda function: upb/mini_table.hpp:71:22: error: implicit capture of 'this' via '[=]' is deprecated in C++20 [-Werror=deprecated] 71 | return appender_([=](char* buf) { ``` In C++20, it is no longer allowed to implicitly capture 'this' in a lambda using [=]. This commit explicitly captures required values in the appropriate lambdas and removes all uses of [=] with lambdas. ``` Closes #13908 COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/13908 from acozzette:upb 7afb426a5ace6f6e76ac2144960363379a1be08d PiperOrigin-RevId: 563784513
1 year ago
return appender_([this, key_type, val_type, key_mod, val_mod](char* buf) {
return upb_MtDataEncoder_EncodeMap(&encoder_, buf, key_type, val_type,
key_mod, val_mod);
});
}
bool EncodeMessageSet() {
Cherry-pick recent changes from the upb repo (#13908) I merged a handful of PRs on the upb repo after upb moved into the protobuf repo. This PR cherry-picks them here so that they will not be lost. ``` commit 7afb426a5ace6f6e76ac2144960363379a1be08d Author: Keith Smiley <keithbsmiley@gmail.com> Date: Thu Sep 7 11:36:01 2023 -0700 [bazel] Fix disallowing dylibs on darwin (#1180) Since this bazel commit https://github.com/bazelbuild/bazel/commit/ec5553352f2f661d39ac4cf665dd9b3c779e614c building dylibs like the ones in this rule on darwin platforms has been unsupported. This feature is a default C++ toolchain feature to indicate this. In bazel 7.x these dylibs will fail to link if they are still built. As far as I can tell in the tests even if they are built they are never used on macOS. Co-authored-by: Adam Cozzette <acozzette@google.com> commit 72decab5eca0110548b0c805275fffab562aebde Author: Keith Smiley <keithbsmiley@gmail.com> Date: Thu Sep 7 09:42:20 2023 -0700 Add missing darwin_x86_64 CPU (#1181) This CPU is often used when cross compiling from M1 machines. I'm also hoping we can remove the legacy 'darwin' CPU. commit ccadaf3196bda975dec5ed2aac8a78e75ab51c1b Author: messense <messense@icloud.com> Date: Fri Sep 8 00:28:54 2023 +0800 Fix `PyUpb_Message_MergeInternal` segfault (#1338) when `PyUpb_Message_MergeFromString` returns `NULL`, currently `PyUpb_Message_MergeInternal` will call `Py_DECREF` on `NULL` which results in a segmentation fault. This patch switches to `Py_XDECREF` to fix the segfault. commit 2a5724d86ea81e0c2a0f8d10db274821c8bb6656 Author: Kevin Greene <kgreenek@gmail.com> Date: Wed Sep 6 16:46:35 2023 -0700 Fix lambda capture compiler error with c++20 (#1502) When compiling with C++20, the following error is produced: ``` upb/mini_table.hpp:63:22: note: add explicit 'this' or '*this' capture upb/mini_table.hpp: In lambda function: upb/mini_table.hpp:71:22: error: implicit capture of 'this' via '[=]' is deprecated in C++20 [-Werror=deprecated] 71 | return appender_([=](char* buf) { ``` In C++20, it is no longer allowed to implicitly capture 'this' in a lambda using [=]. This commit explicitly captures required values in the appropriate lambdas and removes all uses of [=] with lambdas. ``` Closes #13908 COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/13908 from acozzette:upb 7afb426a5ace6f6e76ac2144960363379a1be08d PiperOrigin-RevId: 563784513
1 year ago
return appender_([this](char* buf) {
return upb_MtDataEncoder_EncodeMessageSet(&encoder_, buf);
});
}
const std::string& data() const { return appender_.data(); }
private:
class StringAppender {
public:
StringAppender(upb_MtDataEncoder* e) { e->end = buf_ + sizeof(buf_); }
template <class T>
bool operator()(T&& func) {
char* end = func(buf_);
if (!end) return false;
// C++ does not guarantee that string has doubling growth behavior, but
// we need it to avoid O(n^2).
str_.reserve(upb_Log2CeilingSize(str_.size() + (end - buf_)));
str_.append(buf_, end - buf_);
return true;
}
const std::string& data() const { return str_; }
private:
char buf_[kUpb_MtDataEncoder_MinSize];
std::string str_;
};
upb_MtDataEncoder encoder_;
StringAppender appender_;
};
} // namespace upb
#endif /* UPB_MINI_TABLE_ENCODE_INTERNAL_HPP_ */