| 128 | } |
| 129 | |
| 130 | absl::StatusOr<bool> CompileAndEvaluateWithContext( |
| 131 | absl::string_view cel_expr, const AttributeContext& context) { |
| 132 | CEL_ASSIGN_OR_RETURN(std::unique_ptr<cel::Compiler> compiler, |
| 133 | MakeCelCompiler()); |
| 134 | |
| 135 | CEL_ASSIGN_OR_RETURN(CheckedExpr checked_expr, |
| 136 | CompileToCheckedExpr(*compiler, cel_expr)); |
| 137 | |
| 138 | Activation activation; |
| 139 | google::protobuf::Arena arena; |
| 140 | // === Start Codelab === |
| 141 | CEL_RETURN_IF_ERROR(BindProtoToActivation( |
| 142 | &context, &arena, &activation, ProtoUnsetFieldOptions::kBindDefault)); |
| 143 | // === End Codelab === |
| 144 | |
| 145 | return EvalCheckedExpr(checked_expr, activation, &arena); |
| 146 | } |
| 147 | |
| 148 | } // namespace cel_codelab |