| 53 | using ::google::rpc::context::AttributeContext; |
| 54 | |
| 55 | absl::StatusOr<std::unique_ptr<cel::Compiler>> MakeConfiguredCompiler() { |
| 56 | // Setup for handling for protobuf types. |
| 57 | // Using the generated descriptor pool is simpler to configure, but often |
| 58 | // adds more types than necessary. |
| 59 | google::protobuf::LinkMessageReflection<AttributeContext>(); |
| 60 | CEL_ASSIGN_OR_RETURN( |
| 61 | std::unique_ptr<cel::CompilerBuilder> builder, |
| 62 | cel::NewCompilerBuilder(google::protobuf::DescriptorPool::generated_pool())); |
| 63 | CEL_RETURN_IF_ERROR(builder->AddLibrary(cel::StandardCompilerLibrary())); |
| 64 | // Adds fields of AttributeContext as variables. |
| 65 | CEL_RETURN_IF_ERROR(builder->GetCheckerBuilder().AddContextDeclaration( |
| 66 | AttributeContext::descriptor()->full_name())); |
| 67 | |
| 68 | // Codelab part 1: |
| 69 | // Add a declaration for the map<string, V>.contains(string, V) function. |
| 70 | // Hint: use cel::MakeFunctionDecl and cel::TypeCheckerBuilder::MergeFunction. |
| 71 | return builder->Build(); |
| 72 | } |
| 73 | |
| 74 | class Evaluator { |
| 75 | public: |
no test coverage detected