MCPcopy Create free account
hub / github.com/cel-expr/cel-cpp / SetupEvaluatorEnvironment

Method SetupEvaluatorEnvironment

codelab/solutions/exercise4.cc:120–132  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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) {

Callers 1

Calls 2

RegisterBuiltinFunctionsFunction · 0.85
GetRegistryMethod · 0.80

Tested by

no test coverage detected