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

Function CelAccuVarMacroExpander

conformance/service.cc:170–192  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

168}
169
170absl::optional<cel::Expr> CelAccuVarMacroExpander(
171 cel::MacroExprFactory& factory, cel::Expr& target,
172 absl::Span<cel::Expr> args) {
173 if (!IsCelNamespace(target)) {
174 return absl::nullopt;
175 }
176 cel::Expr& depth_arg = args[0];
177 if (!depth_arg.has_const_expr() || !depth_arg.const_expr().has_int_value() ||
178 depth_arg.const_expr().int_value() < 0) {
179 return factory.ReportErrorAt(
180 depth_arg, "cel.accuVar requires two non-negative int constant args");
181 }
182 cel::Expr& unique_arg = args[1];
183 if (!unique_arg.has_const_expr() ||
184 !unique_arg.const_expr().has_int_value() ||
185 unique_arg.const_expr().int_value() < 0) {
186 return factory.ReportErrorAt(
187 unique_arg, "cel.accuVar requires two non-negative int constant args");
188 }
189 return factory.NewIdent(
190 absl::StrCat("@ac:", depth_arg.const_expr().int_value(), ":",
191 unique_arg.const_expr().int_value()));
192}
193
194absl::Status RegisterCelBlockMacros(cel::MacroRegistry& registry) {
195 CEL_ASSIGN_OR_RETURN(auto block_macro,

Callers

nothing calls this directly

Calls 4

IsCelNamespaceFunction · 0.85
has_const_exprMethod · 0.80
ReportErrorAtMethod · 0.45
NewIdentMethod · 0.45

Tested by

no test coverage detected