Skip to content

Commit f3b9b46

Browse files
Internal build change
PiperOrigin-RevId: 366083872
1 parent f433eb3 commit f3b9b46

File tree

1 file changed

+31
-18
lines changed

1 file changed

+31
-18
lines changed

eval/public/structs/cel_proto_wrapper.cc

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -380,11 +380,11 @@ absl::optional<const google::protobuf::Message*> MessageFromValue(const CelValue
380380

381381
absl::optional<const google::protobuf::Message*> MessageFromValue(const CelValue& value,
382382
BytesValue* wrapper) {
383-
CelValue::BytesHolder val;
384-
if (!value.GetValue(&val)) {
383+
CelValue::BytesHolder view_val;
384+
if (!value.GetValue(&view_val)) {
385385
return {};
386386
}
387-
wrapper->set_value(val.value());
387+
wrapper->set_value(view_val.value().data());
388388
return wrapper;
389389
}
390390

@@ -444,11 +444,11 @@ absl::optional<const google::protobuf::Message*> MessageFromValue(const CelValue
444444

445445
absl::optional<const google::protobuf::Message*> MessageFromValue(const CelValue& value,
446446
StringValue* wrapper) {
447-
CelValue::StringHolder val;
448-
if (!value.GetValue(&val)) {
447+
CelValue::StringHolder view_val;
448+
if (!value.GetValue(&view_val)) {
449449
return {};
450450
}
451-
wrapper->set_value(val.value());
451+
wrapper->set_value(view_val.value().data());
452452
return wrapper;
453453
}
454454

@@ -644,85 +644,98 @@ absl::optional<const google::protobuf::Message*> MessageFromValue(const CelValue
644644

645645
absl::optional<const google::protobuf::Message*> MessageFromValue(const CelValue& value,
646646
Any* any) {
647+
// In open source, any->PackFrom() returns void rather than boolean.
647648
switch (value.type()) {
648649
case CelValue::Type::kBool: {
649650
BoolValue v;
650651
auto msg = MessageFromValue(value, &v);
651-
if (msg.has_value() && any->PackFrom(**msg)) {
652+
if (msg.has_value()) {
653+
any->PackFrom(**msg);
652654
return any;
653655
}
654656
} break;
655657
case CelValue::Type::kBytes: {
656658
BytesValue v;
657659
auto msg = MessageFromValue(value, &v);
658-
if (msg.has_value() && any->PackFrom(**msg)) {
660+
if (msg.has_value()) {
661+
any->PackFrom(**msg);
659662
return any;
660663
}
661664
} break;
662665
case CelValue::Type::kDouble: {
663666
DoubleValue v;
664667
auto msg = MessageFromValue(value, &v);
665-
if (msg.has_value() && any->PackFrom(**msg)) {
668+
if (msg.has_value()) {
669+
any->PackFrom(**msg);
666670
return any;
667671
}
668672
} break;
669673
case CelValue::Type::kDuration: {
670674
Duration v;
671675
auto msg = MessageFromValue(value, &v);
672-
if (msg.has_value() && any->PackFrom(**msg)) {
676+
if (msg.has_value()) {
677+
any->PackFrom(**msg);
673678
return any;
674679
}
675680
} break;
676681
case CelValue::Type::kInt64: {
677682
Int64Value v;
678683
auto msg = MessageFromValue(value, &v);
679-
if (msg.has_value() && any->PackFrom(**msg)) {
684+
if (msg.has_value()) {
685+
any->PackFrom(**msg);
680686
return any;
681687
}
682688
} break;
683689
case CelValue::Type::kString: {
684690
StringValue v;
685691
auto msg = MessageFromValue(value, &v);
686-
if (msg.has_value() && any->PackFrom(**msg)) {
692+
if (msg.has_value()) {
693+
any->PackFrom(**msg);
687694
return any;
688695
}
689696
} break;
690697
case CelValue::Type::kTimestamp: {
691698
Timestamp v;
692699
auto msg = MessageFromValue(value, &v);
693-
if (msg.has_value() && any->PackFrom(**msg)) {
700+
if (msg.has_value()) {
701+
any->PackFrom(**msg);
694702
return any;
695703
}
696704
} break;
697705
case CelValue::Type::kUint64: {
698706
UInt64Value v;
699707
auto msg = MessageFromValue(value, &v);
700-
if (msg.has_value() && any->PackFrom(**msg)) {
708+
if (msg.has_value()) {
709+
any->PackFrom(**msg);
701710
return any;
702711
}
703712
} break;
704713
case CelValue::Type::kList: {
705714
ListValue v;
706715
auto msg = MessageFromValue(value, &v);
707-
if (msg.has_value() && any->PackFrom(**msg)) {
716+
if (msg.has_value()) {
717+
any->PackFrom(**msg);
708718
return any;
709719
}
710720
} break;
711721
case CelValue::Type::kMap: {
712722
Struct v;
713723
auto msg = MessageFromValue(value, &v);
714-
if (msg.has_value() && any->PackFrom(**msg)) {
724+
if (msg.has_value()) {
725+
any->PackFrom(**msg);
715726
return any;
716727
}
717728
} break;
718729
case CelValue::Type::kMessage: {
719730
if (value.IsNull()) {
720731
Value v;
721732
auto msg = MessageFromValue(value, &v);
722-
if (msg.has_value() && any->PackFrom(**msg)) {
733+
if (msg.has_value()) {
734+
any->PackFrom(**msg);
723735
return any;
724736
}
725-
} else if (any->PackFrom(*(value.MessageOrDie()))) {
737+
} else {
738+
any->PackFrom(*(value.MessageOrDie()));
726739
return any;
727740
}
728741
} break;

0 commit comments

Comments
 (0)