From 050b21eaf1dfd750f356bff9039f29cc9e6706e3 Mon Sep 17 00:00:00 2001 From: Antoine Pietri Date: Thu, 17 Apr 2025 12:13:14 -0700 Subject: [PATCH] Add AddUnknownPattern() and AddMissingPattern(). The other activation functions can be used incrementally, but SetUnknownPatterns() and SetMissingPatterns() cannot. This makes it a bit annoying to use, since you can't have a wrapper function that either binds an attribute or add an unknown pattern, that you could for example call in a loop. Since attribute patterns are just a vector anyway, it is easy to make it support incremental additions. PiperOrigin-RevId: 748766532 --- runtime/activation.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/runtime/activation.h b/runtime/activation.h index cb8f539fe..2d8b8a44a 100644 --- a/runtime/activation.h +++ b/runtime/activation.h @@ -92,10 +92,18 @@ class Activation final : public ActivationInterface { bool InsertOrAssignValueProvider(absl::string_view name, ValueProvider provider); + void AddUnknownPattern(cel::AttributePattern pattern) { + unknown_patterns_.push_back(std::move(pattern)); + } + void SetUnknownPatterns(std::vector patterns) { unknown_patterns_ = std::move(patterns); } + void AddMissingPattern(cel::AttributePattern pattern) { + missing_patterns_.push_back(std::move(pattern)); + } + void SetMissingPatterns(std::vector patterns) { missing_patterns_ = std::move(patterns); }