MCPcopy Create free account
hub / github.com/cel-expr/cel-cpp / LegacyTrivialListValue

Function LegacyTrivialListValue

common/legacy_value.cc:275–311  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

273}
274
275CelValue LegacyTrivialListValue(google::protobuf::Arena* absl_nonnull arena,
276 const Value& value) {
277 if (auto legacy_list_value = common_internal::AsLegacyListValue(value);
278 legacy_list_value) {
279 return CelValue::CreateList(legacy_list_value->cel_list());
280 }
281 if (auto parsed_repeated_field_value = value.AsParsedRepeatedField();
282 parsed_repeated_field_value) {
283 auto maybe_cloned = parsed_repeated_field_value->Clone(arena);
284 return CelValue::CreateList(google::protobuf::Arena::Create<FieldBackedListImpl>(
285 arena, &maybe_cloned.message(), maybe_cloned.field(), arena));
286 }
287 if (auto parsed_json_list_value = value.AsParsedJsonList();
288 parsed_json_list_value) {
289 auto maybe_cloned = parsed_json_list_value->Clone(arena);
290 return CelValue::CreateList(google::protobuf::Arena::Create<FieldBackedListImpl>(
291 arena, cel::to_address(maybe_cloned),
292 well_known_types::GetListValueReflectionOrDie(
293 maybe_cloned->GetDescriptor())
294 .GetValuesDescriptor(),
295 arena));
296 }
297 if (auto custom_list_value = value.AsCustomList(); custom_list_value) {
298 auto status_or_compat_list = common_internal::MakeCompatListValue(
299 *custom_list_value, google::protobuf::DescriptorPool::generated_pool(),
300 google::protobuf::MessageFactory::generated_factory(), arena);
301 if (!status_or_compat_list.ok()) {
302 return CelValue::CreateError(google::protobuf::Arena::Create<absl::Status>(
303 arena, std::move(status_or_compat_list).status()));
304 }
305 return CelValue::CreateList(*status_or_compat_list);
306 }
307 return CelValue::CreateError(google::protobuf::Arena::Create<absl::Status>(
308 arena, absl::InvalidArgumentError(absl::StrCat(
309 "unsupported conversion from cel::ListValue to CelValue: ",
310 value.GetRuntimeType().DebugString()))));
311}
312
313CelValue LegacyTrivialMapValue(google::protobuf::Arena* absl_nonnull arena,
314 const Value& value) {

Callers 3

UnsafeLegacyValueFunction · 0.85
LegacyValueFunction · 0.85
ToLegacyValueFunction · 0.85

Calls 15

AsLegacyListValueFunction · 0.85
to_addressFunction · 0.85
MakeCompatListValueFunction · 0.85
cel_listMethod · 0.80
messageMethod · 0.80
GetValuesDescriptorMethod · 0.80
CreateListFunction · 0.50
CreateErrorFunction · 0.50
AsParsedRepeatedFieldMethod · 0.45
CloneMethod · 0.45
fieldMethod · 0.45

Tested by

no test coverage detected