forked from cel-expr/cel-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcel_function.cc
More file actions
50 lines (41 loc) · 1.16 KB
/
Copy pathcel_function.cc
File metadata and controls
50 lines (41 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "eval/public/cel_function.h"
namespace google {
namespace api {
namespace expr {
namespace runtime {
bool CelFunctionDescriptor::ShapeMatches(
bool receiver_style, const std::vector<CelValue::Type>& types) const {
if (receiver_style_ != receiver_style) {
return false;
}
if (types_.size() != types.size()) {
return false;
}
for (size_t i = 0; i < types_.size(); i++) {
CelValue::Type this_type = types_[i];
CelValue::Type other_type = types[i];
if (this_type != CelValue::Type::kAny &&
other_type != CelValue::Type::kAny && this_type != other_type) {
return false;
}
}
return true;
}
bool CelFunction::MatchArguments(absl::Span<const CelValue> arguments) const {
auto types_size = descriptor().types().size();
if (types_size != arguments.size()) {
return false;
}
for (size_t i = 0; i < types_size; i++) {
const auto& value = arguments[i];
CelValue::Type arg_type = descriptor().types()[i];
if (value.type() != arg_type && arg_type != CelValue::Type::kAny) {
return false;
}
}
return true;
}
} // namespace runtime
} // namespace expr
} // namespace api
} // namespace google