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

Function bindings_macros

extensions/bindings_ext.cc:52–71  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50} // namespace
51
52std::vector<Macro> bindings_macros() {
53 absl::StatusOr<Macro> cel_bind = Macro::Receiver(
54 kBind, 3,
55 [](MacroExprFactory& factory, Expr& target,
56 absl::Span<Expr> args) -> absl::optional<Expr> {
57 if (!IsTargetNamespace(target)) {
58 return absl::nullopt;
59 }
60 if (!args[0].has_ident_expr()) {
61 return factory.ReportErrorAt(
62 args[0], "cel.bind() variable name must be a simple identifier");
63 }
64 auto var_name = args[0].ident_expr().name();
65 return factory.NewComprehension(kUnusedIterVar, factory.NewList(),
66 std::move(var_name), std::move(args[1]),
67 factory.NewBoolConst(false),
68 std::move(args[0]), std::move(args[2]));
69 });
70 return {*cel_bind};
71}
72
73CompilerLibrary BindingsCompilerLibrary() {
74 return CompilerLibrary("cel.lib.ext.bindings", &ConfigureParser);

Callers 7

ParseTestCaseFunction · 0.85
ConfigureParserFunction · 0.85
TEST_PFunction · 0.85
TEST_PFunction · 0.85
RunBenchmarkFunction · 0.85
RegisterBindingsMacrosFunction · 0.85

Calls 7

has_ident_exprMethod · 0.80
IsTargetNamespaceFunction · 0.70
ReportErrorAtMethod · 0.45
nameMethod · 0.45
NewComprehensionMethod · 0.45
NewListMethod · 0.45
NewBoolConstMethod · 0.45

Tested by 4

ParseTestCaseFunction · 0.68
TEST_PFunction · 0.68
TEST_PFunction · 0.68
RunBenchmarkFunction · 0.68