| 311 | } |
| 312 | |
| 313 | CelValue LegacyTrivialMapValue(google::protobuf::Arena* absl_nonnull arena, |
| 314 | const Value& value) { |
| 315 | if (auto legacy_map_value = common_internal::AsLegacyMapValue(value); |
| 316 | legacy_map_value) { |
| 317 | return CelValue::CreateMap(legacy_map_value->cel_map()); |
| 318 | } |
| 319 | if (auto parsed_map_field_value = value.AsParsedMapField(); |
| 320 | parsed_map_field_value) { |
| 321 | auto maybe_cloned = parsed_map_field_value->Clone(arena); |
| 322 | return CelValue::CreateMap(google::protobuf::Arena::Create<FieldBackedMapImpl>( |
| 323 | arena, &maybe_cloned.message(), maybe_cloned.field(), arena)); |
| 324 | } |
| 325 | if (auto parsed_json_map_value = value.AsParsedJsonMap(); |
| 326 | parsed_json_map_value) { |
| 327 | auto maybe_cloned = parsed_json_map_value->Clone(arena); |
| 328 | return CelValue::CreateMap(google::protobuf::Arena::Create<FieldBackedMapImpl>( |
| 329 | arena, cel::to_address(maybe_cloned), |
| 330 | well_known_types::GetStructReflectionOrDie( |
| 331 | maybe_cloned->GetDescriptor()) |
| 332 | .GetFieldsDescriptor(), |
| 333 | arena)); |
| 334 | } |
| 335 | if (auto custom_map_value = value.AsCustomMap(); custom_map_value) { |
| 336 | auto status_or_compat_map = common_internal::MakeCompatMapValue( |
| 337 | *custom_map_value, google::protobuf::DescriptorPool::generated_pool(), |
| 338 | google::protobuf::MessageFactory::generated_factory(), arena); |
| 339 | if (!status_or_compat_map.ok()) { |
| 340 | return CelValue::CreateError(google::protobuf::Arena::Create<absl::Status>( |
| 341 | arena, std::move(status_or_compat_map).status())); |
| 342 | } |
| 343 | return CelValue::CreateMap(*status_or_compat_map); |
| 344 | } |
| 345 | return CelValue::CreateError(google::protobuf::Arena::Create<absl::Status>( |
| 346 | arena, absl::InvalidArgumentError(absl::StrCat( |
| 347 | "unsupported conversion from cel::MapValue to CelValue: ", |
| 348 | value.GetRuntimeType().DebugString())))); |
| 349 | } |
| 350 | |
| 351 | } // namespace |
| 352 |
no test coverage detected