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

Method FindOverloads

eval/public/cel_function_registry.cc:77–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

75}
76
77std::vector<const CelFunction*> CelFunctionRegistry::FindOverloads(
78 absl::string_view name, bool receiver_style,
79 const std::vector<CelValue::Type>& types) const {
80 std::vector<cel::FunctionOverloadReference> matched_funcs =
81 modern_registry_.FindStaticOverloads(name, receiver_style, types);
82
83 // For backwards compatibility, lazily initialize a legacy CEL function
84 // if required.
85 // The registry should remain add-only until migration to the new type is
86 // complete, so this should work whether the function was introduced via
87 // the modern registry or the old registry wrapping a modern instance.
88 std::vector<const CelFunction*> results;
89 results.reserve(matched_funcs.size());
90
91 {
92 absl::MutexLock lock(mu_);
93 for (cel::FunctionOverloadReference entry : matched_funcs) {
94 std::unique_ptr<CelFunction>& legacy_impl =
95 functions_[&entry.implementation];
96
97 if (legacy_impl == nullptr) {
98 legacy_impl = std::make_unique<ProxyToModernCelFunction>(
99 entry.descriptor, entry.implementation);
100 }
101 results.push_back(legacy_impl.get());
102 }
103 }
104 return results;
105}
106
107std::vector<const CelFunctionDescriptor*>
108CelFunctionRegistry::FindLazyOverloads(

Calls 3

FindStaticOverloadsMethod · 0.45
sizeMethod · 0.45
getMethod · 0.45

Tested by 15

TestStringInclusionMethod · 0.36
PerformBetweenTestMethod · 0.36
PerformBetweenStrTestMethod · 0.36
PerformGetDateTestMethod · 0.36
PerformGetDateUTCTestMethod · 0.36
PerformBetweenToDTestMethod · 0.36