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

Function WrapFieldImpl

common/value.cc:1497–1631  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1495
1496template <typename Unsafe>
1497Value WrapFieldImpl(
1498 ProtoWrapperTypeOptions wrapper_type_options,
1499 const google::protobuf::Message* absl_nonnull message ABSL_ATTRIBUTE_LIFETIME_BOUND,
1500 const google::protobuf::FieldDescriptor* absl_nonnull field
1501 ABSL_ATTRIBUTE_LIFETIME_BOUND,
1502 const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool
1503 ABSL_ATTRIBUTE_LIFETIME_BOUND,
1504 google::protobuf::MessageFactory* absl_nonnull message_factory
1505 ABSL_ATTRIBUTE_LIFETIME_BOUND,
1506 google::protobuf::Arena* absl_nonnull arena ABSL_ATTRIBUTE_LIFETIME_BOUND) {
1507 ABSL_DCHECK(field != nullptr);
1508 ABSL_DCHECK_EQ(message->GetDescriptor(), field->containing_type());
1509 ABSL_DCHECK(descriptor_pool != nullptr);
1510 ABSL_DCHECK(message_factory != nullptr);
1511 ABSL_DCHECK(!IsWellKnownMessageType(message->GetDescriptor()));
1512
1513 const auto* reflection = message->GetReflection();
1514 if (field->is_map()) {
1515 if (reflection->FieldSize(*message, field) == 0) {
1516 return MapValue();
1517 }
1518 if constexpr (Unsafe::value) {
1519 return UnsafeParsedMapFieldValue(message, field);
1520 } else {
1521 return ParsedMapFieldValue(message, field,
1522 MessageArenaOr(message, arena));
1523 }
1524 }
1525 if (field->is_repeated()) {
1526 if (reflection->FieldSize(*message, field) == 0) {
1527 return ListValue();
1528 }
1529 if constexpr (Unsafe::value) {
1530 return UnsafeParsedRepeatedFieldValue(message, field);
1531 } else {
1532 return ParsedRepeatedFieldValue(message, field,
1533 MessageArenaOr(message, arena));
1534 }
1535 }
1536 switch (field->type()) {
1537 case google::protobuf::FieldDescriptor::TYPE_DOUBLE:
1538 return DoubleValue(reflection->GetDouble(*message, field));
1539 case google::protobuf::FieldDescriptor::TYPE_FLOAT:
1540 return DoubleValue(reflection->GetFloat(*message, field));
1541 case google::protobuf::FieldDescriptor::TYPE_INT64:
1542 return IntValue(reflection->GetInt64(*message, field));
1543 case google::protobuf::FieldDescriptor::TYPE_UINT64:
1544 return UintValue(reflection->GetUInt64(*message, field));
1545 case google::protobuf::FieldDescriptor::TYPE_INT32:
1546 return IntValue(reflection->GetInt32(*message, field));
1547 case google::protobuf::FieldDescriptor::TYPE_FIXED64:
1548 return UintValue(reflection->GetUInt64(*message, field));
1549 case google::protobuf::FieldDescriptor::TYPE_FIXED32:
1550 return UintValue(reflection->GetUInt32(*message, field));
1551 case google::protobuf::FieldDescriptor::TYPE_BOOL:
1552 return BoolValue(reflection->GetBool(*message, field));
1553 case google::protobuf::FieldDescriptor::TYPE_STRING: {
1554 std::string scratch;

Callers

nothing calls this directly

Calls 15

ArenaFunction · 0.85
ErrorValueFunction · 0.85
typeMethod · 0.80
IsWellKnownMessageTypeFunction · 0.50
MapValueClass · 0.50
ParsedMapFieldValueClass · 0.50
ListValueClass · 0.50
DoubleValueClass · 0.50

Tested by

no test coverage detected