@@ -60,22 +60,6 @@ class EmptyListValue final : public common_internal::CompatListValue {
60
60
61
61
size_t Size () const override { return 0 ; }
62
62
63
- absl::Status ConvertToJson (
64
- absl::Nonnull<const google::protobuf::DescriptorPool*> descriptor_pool,
65
- absl::Nonnull<google::protobuf::MessageFactory*> message_factory,
66
- absl::Nonnull<google::protobuf::Message*> json) const override {
67
- ABSL_DCHECK (descriptor_pool != nullptr );
68
- ABSL_DCHECK (message_factory != nullptr );
69
- ABSL_DCHECK (json != nullptr );
70
- ABSL_DCHECK_EQ (json->GetDescriptor ()->well_known_type (),
71
- google::protobuf::Descriptor::WELLKNOWNTYPE_VALUE);
72
-
73
- ValueReflection value_reflection;
74
- CEL_RETURN_IF_ERROR (value_reflection.Initialize (json->GetDescriptor ()));
75
- value_reflection.MutableListValue (json)->Clear ();
76
- return absl::OkStatus ();
77
- }
78
-
79
63
absl::Status ConvertToJsonArray (
80
64
absl::Nonnull<const google::protobuf::DescriptorPool*> descriptor_pool,
81
65
absl::Nonnull<google::protobuf::MessageFactory*> message_factory,
@@ -102,7 +86,6 @@ class EmptyListValue final : public common_internal::CompatListValue {
102
86
return CelValue::CreateError (&*error);
103
87
}
104
88
105
- using CompatListValue::Get;
106
89
CelValue Get (google::protobuf::Arena* arena, int index) const override {
107
90
if (arena == nullptr ) {
108
91
return (*this )[index ];
@@ -112,12 +95,12 @@ class EmptyListValue final : public common_internal::CompatListValue {
112
95
}
113
96
114
97
private:
115
- absl::Status GetImpl (size_t , absl::Nonnull<const google::protobuf::DescriptorPool*>,
116
- absl::Nonnull<google::protobuf::MessageFactory*>,
117
- absl::Nonnull<google::protobuf::Arena*>,
118
- absl::Nonnull<Value*>) const override {
119
- // Not reachable, `Get` performs index checking.
120
- return absl::InternalError ( " unreachable " );
98
+ absl::Status Get (size_t index , absl::Nonnull<const google::protobuf::DescriptorPool*>,
99
+ absl::Nonnull<google::protobuf::MessageFactory*>,
100
+ absl::Nonnull<google::protobuf::Arena*>,
101
+ absl::Nonnull<Value*> result ) const override {
102
+ *result = IndexOutOfBoundsError ( index );
103
+ return absl::OkStatus ( );
121
104
}
122
105
};
123
106
@@ -149,8 +132,8 @@ class CustomListValueInterfaceIterator final : public ValueIterator {
149
132
" ValueIterator::Next() called when "
150
133
" ValueIterator::HasNext() returns false" );
151
134
}
152
- return interface_.GetImpl (index_++, descriptor_pool, message_factory, arena,
153
- result);
135
+ return interface_.Get (index_++, descriptor_pool, message_factory, arena,
136
+ result);
154
137
}
155
138
156
139
private:
@@ -221,17 +204,6 @@ absl::Status CustomListValueInterface::SerializeTo(
221
204
return absl::OkStatus ();
222
205
}
223
206
224
- absl::Status CustomListValueInterface::Get (
225
- size_t index, absl::Nonnull<const google::protobuf::DescriptorPool*> descriptor_pool,
226
- absl::Nonnull<google::protobuf::MessageFactory*> message_factory,
227
- absl::Nonnull<google::protobuf::Arena*> arena, absl::Nonnull<Value*> result) const {
228
- if (ABSL_PREDICT_FALSE (index >= Size ())) {
229
- *result = IndexOutOfBoundsError (index );
230
- return absl::OkStatus ();
231
- }
232
- return GetImpl (index , descriptor_pool, message_factory, arena, result);
233
- }
234
-
235
207
absl::Status CustomListValueInterface::ForEach (
236
208
ForEachWithIndexCallback callback,
237
209
absl::Nonnull<const google::protobuf::DescriptorPool*> descriptor_pool,
@@ -241,7 +213,7 @@ absl::Status CustomListValueInterface::ForEach(
241
213
for (size_t index = 0 ; index < size; ++index ) {
242
214
Value element;
243
215
CEL_RETURN_IF_ERROR (
244
- GetImpl (index , descriptor_pool, message_factory, arena, &element));
216
+ Get (index , descriptor_pool, message_factory, arena, &element));
245
217
CEL_ASSIGN_OR_RETURN (auto ok, callback (index , element));
246
218
if (!ok) {
247
219
break ;
@@ -256,16 +228,12 @@ CustomListValueInterface::NewIterator() const {
256
228
}
257
229
258
230
absl::Status CustomListValueInterface::Equal (
259
- const Value & other,
231
+ const ListValue & other,
260
232
absl::Nonnull<const google::protobuf::DescriptorPool*> descriptor_pool,
261
233
absl::Nonnull<google::protobuf::MessageFactory*> message_factory,
262
234
absl::Nonnull<google::protobuf::Arena*> arena, absl::Nonnull<Value*> result) const {
263
- if (auto list_value = other.As <ListValue>(); list_value.has_value ()) {
264
- return ListValueEqual (*this , *list_value, descriptor_pool, message_factory,
265
- arena, result);
266
- }
267
- *result = FalseValue ();
268
- return absl::OkStatus ();
235
+ return ListValueEqual (*this , other, descriptor_pool, message_factory, arena,
236
+ result);
269
237
}
270
238
271
239
absl::Status CustomListValueInterface::Contains (
@@ -301,7 +269,7 @@ NativeTypeId CustomListValue::GetTypeId() const {
301
269
CustomListValueInterface::Content content =
302
270
content_.To <CustomListValueInterface::Content>();
303
271
ABSL_DCHECK (content.interface != nullptr );
304
- return NativeTypeId::Of (* content.interface );
272
+ return content.interface -> GetNativeTypeId ( );
305
273
}
306
274
return dispatcher_->get_type_id (dispatcher_, content_);
307
275
}
@@ -392,14 +360,14 @@ absl::Status CustomListValue::Equal(
392
360
ABSL_DCHECK (arena != nullptr );
393
361
ABSL_DCHECK (result != nullptr );
394
362
395
- if (dispatcher_ == nullptr ) {
396
- CustomListValueInterface::Content content =
397
- content_.To <CustomListValueInterface::Content>();
398
- ABSL_DCHECK (content.interface != nullptr );
399
- return content.interface ->Equal (other, descriptor_pool, message_factory,
400
- arena, result);
401
- }
402
363
if (auto other_list_value = other.AsList (); other_list_value) {
364
+ if (dispatcher_ == nullptr ) {
365
+ CustomListValueInterface::Content content =
366
+ content_.To <CustomListValueInterface::Content>();
367
+ ABSL_DCHECK (content.interface != nullptr );
368
+ return content.interface ->Equal (*other_list_value, descriptor_pool,
369
+ message_factory, arena, result);
370
+ }
403
371
if (dispatcher_->equal != nullptr ) {
404
372
return dispatcher_->equal (dispatcher_, content_, *other_list_value,
405
373
descriptor_pool, message_factory, arena,
0 commit comments