| 118 | } |
| 119 | |
| 120 | absl::Status SetupEvaluatorEnvironment() { |
| 121 | CEL_RETURN_IF_ERROR(RegisterBuiltinFunctions(builder_->GetRegistry())); |
| 122 | // Codelab part 2: |
| 123 | // Register the map.contains(string, string) function. |
| 124 | // Hint: use `FunctionAdapter::CreateAndRegister` to adapt from a free |
| 125 | // function ContainsExtensionFunction. |
| 126 | using AdapterT = FunctionAdapter<absl::StatusOr<bool>, const CelMap*, |
| 127 | CelValue::StringHolder, CelValue>; |
| 128 | CEL_RETURN_IF_ERROR(AdapterT::CreateAndRegister( |
| 129 | "contains", /*receiver_style=*/true, &ContainsExtensionFunction, |
| 130 | builder_->GetRegistry())); |
| 131 | return absl::OkStatus(); |
| 132 | } |
| 133 | |
| 134 | absl::StatusOr<bool> Evaluate(const CheckedExpr& expr, |
| 135 | const AttributeContext& context) { |
no test coverage detected