| 86 | // For repeated fields, an unset field is bound as an empty list. |
| 87 | template <typename T> |
| 88 | absl::Status BindProtoToActivation( |
| 89 | const T& context, BindProtoUnsetFieldBehavior unset_field_behavior, |
| 90 | const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool, |
| 91 | google::protobuf::MessageFactory* absl_nonnull message_factory, |
| 92 | google::protobuf::Arena* absl_nonnull arena, Activation* absl_nonnull activation) { |
| 93 | static_assert(std::is_base_of_v<google::protobuf::Message, T>); |
| 94 | // TODO(uncreated-issue/68): for simplicity, just convert the whole message to a |
| 95 | // struct value. For performance, may be better to convert members as needed. |
| 96 | CEL_ASSIGN_OR_RETURN( |
| 97 | Value parent, |
| 98 | ProtoMessageToValue(context, descriptor_pool, message_factory, arena)); |
| 99 | |
| 100 | if (!InstanceOf<StructValue>(parent)) { |
| 101 | return absl::InvalidArgumentError( |
| 102 | absl::StrCat("context is a well-known type: ", context.GetTypeName())); |
| 103 | } |
| 104 | const StructValue& struct_value = Cast<StructValue>(parent); |
| 105 | |
| 106 | const google::protobuf::Descriptor* descriptor = context.GetDescriptor(); |
| 107 | |
| 108 | if (descriptor == nullptr) { |
| 109 | return absl::InvalidArgumentError( |
| 110 | absl::StrCat("context missing descriptor: ", context.GetTypeName())); |
| 111 | } |
| 112 | |
| 113 | return protobuf_internal::BindProtoToActivation( |
| 114 | *descriptor, struct_value, unset_field_behavior, descriptor_pool, |
| 115 | message_factory, arena, activation); |
| 116 | } |
| 117 | template <typename T> |
| 118 | absl::Status BindProtoToActivation( |
| 119 | const T& context, |