Skip to content

Commit 5549f42

Browse files
jckingcopybara-github
authored andcommitted
absl::Cord& -> absl::Nonnull<absl::Cord*>
PiperOrigin-RevId: 733359208
1 parent 7ad7d66 commit 5549f42

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+131
-107
lines changed

common/legacy_value.cc

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -330,9 +330,10 @@ std::string LegacyListValue::DebugString() const {
330330
absl::Status LegacyListValue::SerializeTo(
331331
absl::Nonnull<const google::protobuf::DescriptorPool*> descriptor_pool,
332332
absl::Nonnull<google::protobuf::MessageFactory*> message_factory,
333-
absl::Cord& value) const {
333+
absl::Nonnull<absl::Cord*> value) const {
334334
ABSL_DCHECK(descriptor_pool != nullptr);
335335
ABSL_DCHECK(message_factory != nullptr);
336+
ABSL_DCHECK(value != nullptr);
336337

337338
const google::protobuf::Descriptor* descriptor =
338339
descriptor_pool->FindMessageTypeByName("google.protobuf.ListValue");
@@ -349,7 +350,7 @@ absl::Status LegacyListValue::SerializeTo(
349350
if (wrapped == nullptr) {
350351
return absl::UnknownError("failed to convert legacy map to JSON");
351352
}
352-
if (!wrapped->SerializePartialToCord(&value)) {
353+
if (!wrapped->SerializePartialToCord(value)) {
353354
return absl::UnknownError(
354355
absl::StrCat("failed to serialize message: ", wrapped->GetTypeName()));
355356
}
@@ -506,9 +507,10 @@ std::string LegacyMapValue::DebugString() const {
506507
absl::Status LegacyMapValue::SerializeTo(
507508
absl::Nonnull<const google::protobuf::DescriptorPool*> descriptor_pool,
508509
absl::Nonnull<google::protobuf::MessageFactory*> message_factory,
509-
absl::Cord& value) const {
510+
absl::Nonnull<absl::Cord*> value) const {
510511
ABSL_DCHECK(descriptor_pool != nullptr);
511512
ABSL_DCHECK(message_factory != nullptr);
513+
ABSL_DCHECK(value != nullptr);
512514

513515
const google::protobuf::Descriptor* descriptor =
514516
descriptor_pool->FindMessageTypeByName("google.protobuf.Struct");
@@ -524,7 +526,7 @@ absl::Status LegacyMapValue::SerializeTo(
524526
if (wrapped == nullptr) {
525527
return absl::UnknownError("failed to convert legacy map to JSON");
526528
}
527-
if (!wrapped->SerializePartialToCord(&value)) {
529+
if (!wrapped->SerializePartialToCord(value)) {
528530
return absl::UnknownError(
529531
absl::StrCat("failed to serialize message: ", wrapped->GetTypeName()));
530532
}
@@ -752,13 +754,14 @@ std::string LegacyStructValue::DebugString() const {
752754
absl::Status LegacyStructValue::SerializeTo(
753755
absl::Nonnull<const google::protobuf::DescriptorPool*> descriptor_pool,
754756
absl::Nonnull<google::protobuf::MessageFactory*> message_factory,
755-
absl::Cord& value) const {
757+
absl::Nonnull<absl::Cord*> value) const {
756758
ABSL_DCHECK(descriptor_pool != nullptr);
757759
ABSL_DCHECK(message_factory != nullptr);
760+
ABSL_DCHECK(value != nullptr);
758761

759762
auto message_wrapper = AsMessageWrapper(message_ptr_, type_info_);
760763
if (ABSL_PREDICT_TRUE(
761-
message_wrapper.message_ptr()->SerializePartialToCord(&value))) {
764+
message_wrapper.message_ptr()->SerializePartialToCord(value))) {
762765
return absl::OkStatus();
763766
}
764767
return absl::UnknownError("failed to serialize protocol buffer message");

common/value.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,14 +162,15 @@ std::string Value::DebugString() const {
162162
absl::Status Value::SerializeTo(
163163
absl::Nonnull<const google::protobuf::DescriptorPool*> descriptor_pool,
164164
absl::Nonnull<google::protobuf::MessageFactory*> message_factory,
165-
absl::Cord& value) const {
165+
absl::Nonnull<absl::Cord*> value) const {
166166
ABSL_DCHECK(descriptor_pool != nullptr);
167167
ABSL_DCHECK(message_factory != nullptr);
168+
ABSL_DCHECK(value != nullptr);
168169

169170
AssertIsValid();
170171
return absl::visit(
171172
[descriptor_pool, message_factory,
172-
&value](const auto& alternative) -> absl::Status {
173+
value](const auto& alternative) -> absl::Status {
173174
if constexpr (IsMonostate<decltype(alternative)>::value) {
174175
// In optimized builds, we just return an error. In debug builds we
175176
// cannot reach here.

common/value.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ class Value final : private common_internal::ValueMixin<Value> {
420420
absl::Status SerializeTo(
421421
absl::Nonnull<const google::protobuf::DescriptorPool*> descriptor_pool,
422422
absl::Nonnull<google::protobuf::MessageFactory*> message_factory,
423-
absl::Cord& value) const;
423+
absl::Nonnull<absl::Cord*> value) const;
424424

425425
// `ConvertToJson` converts this value to its JSON representation. The
426426
// argument `json` **MUST** be an instance of `google.protobuf.Value` which is

common/values/bool_value.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,14 @@ std::string BoolValue::DebugString() const {
4444
absl::Status BoolValue::SerializeTo(
4545
absl::Nonnull<const google::protobuf::DescriptorPool*> descriptor_pool,
4646
absl::Nonnull<google::protobuf::MessageFactory*> message_factory,
47-
absl::Cord& value) const {
47+
absl::Nonnull<absl::Cord*> value) const {
4848
ABSL_DCHECK(descriptor_pool != nullptr);
4949
ABSL_DCHECK(message_factory != nullptr);
50+
ABSL_DCHECK(value != nullptr);
5051

5152
google::protobuf::BoolValue message;
5253
message.set_value(NativeValue());
53-
if (!message.SerializePartialToCord(&value)) {
54+
if (!message.SerializePartialToCord(value)) {
5455
return absl::UnknownError(
5556
absl::StrCat("failed to serialize message: ", message.GetTypeName()));
5657
}

common/values/bool_value.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class BoolValue final : private common_internal::ValueMixin<BoolValue> {
7171
absl::Status SerializeTo(
7272
absl::Nonnull<const google::protobuf::DescriptorPool*> descriptor_pool,
7373
absl::Nonnull<google::protobuf::MessageFactory*> message_factory,
74-
absl::Cord& value) const;
74+
absl::Nonnull<absl::Cord*> value) const;
7575

7676
// See Value::ConvertToJson().
7777
absl::Status ConvertToJson(

common/values/bytes_value.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,14 @@ std::string BytesValue::DebugString() const { return BytesDebugString(*this); }
5959
absl::Status BytesValue::SerializeTo(
6060
absl::Nonnull<const google::protobuf::DescriptorPool*> descriptor_pool,
6161
absl::Nonnull<google::protobuf::MessageFactory*> message_factory,
62-
absl::Cord& value) const {
62+
absl::Nonnull<absl::Cord*> value) const {
6363
ABSL_DCHECK(descriptor_pool != nullptr);
6464
ABSL_DCHECK(message_factory != nullptr);
65+
ABSL_DCHECK(value != nullptr);
6566

6667
google::protobuf::BytesValue message;
6768
message.set_value(NativeString());
68-
if (!message.SerializePartialToCord(&value)) {
69+
if (!message.SerializePartialToCord(value)) {
6970
return absl::UnknownError(
7071
absl::StrCat("failed to serialize message: ", message.GetTypeName()));
7172
}

common/values/bytes_value.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class BytesValue final : private common_internal::ValueMixin<BytesValue> {
102102
absl::Status SerializeTo(
103103
absl::Nonnull<const google::protobuf::DescriptorPool*> descriptor_pool,
104104
absl::Nonnull<google::protobuf::MessageFactory*> message_factory,
105-
absl::Cord& value) const;
105+
absl::Nonnull<absl::Cord*> value) const;
106106

107107
// See Value::ConvertToJson().
108108
absl::Status ConvertToJson(

common/values/custom_list_value.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,10 @@ class CustomListValueInterfaceIterator final : public ValueIterator {
163163
absl::Status CustomListValueInterface::SerializeTo(
164164
absl::Nonnull<const google::protobuf::DescriptorPool*> descriptor_pool,
165165
absl::Nonnull<google::protobuf::MessageFactory*> message_factory,
166-
absl::Cord& value) const {
166+
absl::Nonnull<absl::Cord*> value) const {
167167
ABSL_DCHECK(descriptor_pool != nullptr);
168168
ABSL_DCHECK(message_factory != nullptr);
169+
ABSL_DCHECK(value != nullptr);
169170

170171
ListValueReflection reflection;
171172
CEL_RETURN_IF_ERROR(reflection.Initialize(descriptor_pool));
@@ -180,7 +181,7 @@ absl::Status CustomListValueInterface::SerializeTo(
180181
google::protobuf::Message* message = prototype->New(&arena);
181182
CEL_RETURN_IF_ERROR(
182183
ConvertToJsonArray(descriptor_pool, message_factory, message));
183-
if (!message->SerializePartialToCord(&value)) {
184+
if (!message->SerializePartialToCord(value)) {
184185
return absl::UnknownError(
185186
"failed to serialize message: google.protobuf.ListValue");
186187
}

common/values/custom_list_value.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class CustomListValueInterface : public CustomValueInterface {
7575
absl::Status SerializeTo(
7676
absl::Nonnull<const google::protobuf::DescriptorPool*> descriptor_pool,
7777
absl::Nonnull<google::protobuf::MessageFactory*> message_factory,
78-
absl::Cord& value) const override;
78+
absl::Nonnull<absl::Cord*> value) const override;
7979

8080
absl::Status Equal(
8181
const Value& other,
@@ -153,7 +153,7 @@ class CustomListValue
153153
absl::Status SerializeTo(
154154
absl::Nonnull<const google::protobuf::DescriptorPool*> descriptor_pool,
155155
absl::Nonnull<google::protobuf::MessageFactory*> message_factory,
156-
absl::Cord& value) const {
156+
absl::Nonnull<absl::Cord*> value) const {
157157
ABSL_DCHECK(descriptor_pool != nullptr);
158158
ABSL_DCHECK(message_factory != nullptr);
159159

common/values/custom_map_value.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,10 @@ absl::Nonnull<const CompatMapValue*> EmptyCompatMapValue() {
177177
absl::Status CustomMapValueInterface::SerializeTo(
178178
absl::Nonnull<const google::protobuf::DescriptorPool*> descriptor_pool,
179179
absl::Nonnull<google::protobuf::MessageFactory*> message_factory,
180-
absl::Cord& value) const {
180+
absl::Nonnull<absl::Cord*> value) const {
181181
ABSL_DCHECK(descriptor_pool != nullptr);
182182
ABSL_DCHECK(message_factory != nullptr);
183+
ABSL_DCHECK(value != nullptr);
183184

184185
StructReflection reflection;
185186
CEL_RETURN_IF_ERROR(reflection.Initialize(descriptor_pool));
@@ -194,7 +195,7 @@ absl::Status CustomMapValueInterface::SerializeTo(
194195
google::protobuf::Message* message = prototype->New(&arena);
195196
CEL_RETURN_IF_ERROR(
196197
ConvertToJsonObject(descriptor_pool, message_factory, message));
197-
if (!message->SerializePartialToCord(&value)) {
198+
if (!message->SerializePartialToCord(value)) {
198199
return absl::UnknownError(
199200
"failed to serialize message: google.protobuf.Struct");
200201
}

0 commit comments

Comments
 (0)