Skip to content

Commit 5588410

Browse files
l46kokcopybara-github
authored andcommitted
Associate original function names to each of CEL Standard Function binding
PiperOrigin-RevId: 850462832
1 parent 52f7a8f commit 5588410

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+118
-43
lines changed

common/BUILD.bazel

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,3 +126,8 @@ java_library(
126126
name = "operator",
127127
exports = ["//common/src/main/java/dev/cel/common:operator"],
128128
)
129+
130+
cel_android_library(
131+
name = "operator_android",
132+
exports = ["//common/src/main/java/dev/cel/common:operator_android"],
133+
)

common/src/main/java/dev/cel/common/BUILD.bazel

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,3 +360,11 @@ java_library(
360360
],
361361
deps = ["@maven//:com_google_guava_guava"],
362362
)
363+
364+
cel_android_library(
365+
name = "operator_android",
366+
srcs = ["Operator.java"],
367+
tags = [
368+
],
369+
deps = ["@maven_android//:com_google_guava_guava"],
370+
)

runtime/src/main/java/dev/cel/runtime/standard/AddOperator.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
package dev.cel.runtime.standard;
1616

17+
import static dev.cel.common.Operator.ADD;
1718
import static dev.cel.runtime.standard.ArithmeticHelpers.getArithmeticErrorCode;
1819

1920
import com.google.common.collect.ImmutableSet;
@@ -170,6 +171,6 @@ public CelFunctionBinding newFunctionBinding(
170171
}
171172

172173
private AddOperator(ImmutableSet<CelStandardOverload> overloads) {
173-
super(overloads);
174+
super(ADD.getFunction(), overloads);
174175
}
175176
}

runtime/src/main/java/dev/cel/runtime/standard/BUILD.bazel

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ java_library(
4848
":arithmetic_helpers",
4949
":standard_function",
5050
":standard_overload",
51+
"//common:operator",
5152
"//common:options",
5253
"//common:runtime_exception",
5354
"//common/internal:date_time_helpers",
@@ -70,6 +71,7 @@ cel_android_library(
7071
":arithmetic_helpers",
7172
":standard_function_android",
7273
":standard_overload_android",
74+
"//common:operator_android",
7375
"//common:options",
7476
"//common:runtime_exception",
7577
"//common/internal:date_time_helpers_android",
@@ -92,6 +94,7 @@ java_library(
9294
":arithmetic_helpers",
9395
":standard_function",
9496
":standard_overload",
97+
"//common:operator",
9598
"//common:options",
9699
"//common:runtime_exception",
97100
"//common/internal:date_time_helpers",
@@ -113,6 +116,7 @@ cel_android_library(
113116
":arithmetic_helpers",
114117
":standard_function_android",
115118
":standard_overload_android",
119+
"//common:operator_android",
116120
"//common:options",
117121
"//common:runtime_exception",
118122
"//common/internal:date_time_helpers_android",
@@ -364,6 +368,7 @@ java_library(
364368
],
365369
deps = [
366370
":standard_overload",
371+
"//common:operator",
367372
"//common:options",
368373
"//runtime:function_binding",
369374
"//runtime:runtime_equality",
@@ -380,6 +385,7 @@ cel_android_library(
380385
deps = [
381386
":standard_function_android",
382387
":standard_overload_android",
388+
"//common:operator_android",
383389
"//common:options",
384390
"//runtime:function_binding_android",
385391
"//runtime:runtime_equality_android",
@@ -742,6 +748,7 @@ java_library(
742748
],
743749
deps = [
744750
":standard_overload",
751+
"//common:operator",
745752
"//common:options",
746753
"//common/internal:comparison_functions",
747754
"//common/internal:proto_time_utils",
@@ -763,6 +770,7 @@ cel_android_library(
763770
deps = [
764771
":standard_function_android",
765772
":standard_overload_android",
773+
"//common:operator_android",
766774
"//common:options",
767775
"//common/internal:comparison_functions_android",
768776
"//common/internal:proto_time_utils_android",
@@ -782,6 +790,7 @@ java_library(
782790
],
783791
deps = [
784792
":standard_overload",
793+
"//common:operator",
785794
"//common:options",
786795
"//common/internal:comparison_functions",
787796
"//common/internal:proto_time_utils",
@@ -803,6 +812,7 @@ cel_android_library(
803812
deps = [
804813
":standard_function_android",
805814
":standard_overload_android",
815+
"//common:operator_android",
806816
"//common:options",
807817
"//common/internal:comparison_functions_android",
808818
"//common/internal:proto_time_utils_android",
@@ -822,6 +832,7 @@ java_library(
822832
],
823833
deps = [
824834
":standard_overload",
835+
"//common:operator",
825836
"//common:options",
826837
"//runtime:function_binding",
827838
"//runtime:runtime_equality",
@@ -838,6 +849,7 @@ cel_android_library(
838849
deps = [
839850
":standard_function_android",
840851
":standard_overload_android",
852+
"//common:operator_android",
841853
"//common:options",
842854
"//runtime:function_binding_android",
843855
"//runtime:runtime_equality_android",
@@ -852,6 +864,7 @@ java_library(
852864
],
853865
deps = [
854866
":standard_overload",
867+
"//common:operator",
855868
"//common:options",
856869
"//runtime:function_binding",
857870
"//runtime:runtime_equality",
@@ -869,6 +882,7 @@ cel_android_library(
869882
deps = [
870883
":standard_function_android",
871884
":standard_overload_android",
885+
"//common:operator_android",
872886
"//common:options",
873887
"//runtime:function_binding_android",
874888
"//runtime:runtime_equality_android",
@@ -924,6 +938,7 @@ java_library(
924938
],
925939
deps = [
926940
":standard_overload",
941+
"//common:operator",
927942
"//common:options",
928943
"//common/internal:comparison_functions",
929944
"//common/internal:proto_time_utils",
@@ -945,6 +960,7 @@ cel_android_library(
945960
deps = [
946961
":standard_function_android",
947962
":standard_overload_android",
963+
"//common:operator_android",
948964
"//common:options",
949965
"//common/internal:comparison_functions_android",
950966
"//common/internal:proto_time_utils_android",
@@ -964,6 +980,7 @@ java_library(
964980
],
965981
deps = [
966982
":standard_overload",
983+
"//common:operator",
967984
"//common:options",
968985
"//common/internal:comparison_functions",
969986
"//common/internal:proto_time_utils",
@@ -985,6 +1002,7 @@ cel_android_library(
9851002
deps = [
9861003
":standard_function_android",
9871004
":standard_overload_android",
1005+
"//common:operator_android",
9881006
"//common:options",
9891007
"//common/internal:comparison_functions_android",
9901008
"//common/internal:proto_time_utils_android",
@@ -1004,6 +1022,7 @@ java_library(
10041022
],
10051023
deps = [
10061024
":standard_overload",
1025+
"//common:operator",
10071026
"//common:options",
10081027
"//runtime:function_binding",
10091028
"//runtime:runtime_equality",
@@ -1020,6 +1039,7 @@ cel_android_library(
10201039
deps = [
10211040
":standard_function_android",
10221041
":standard_overload_android",
1042+
"//common:operator_android",
10231043
"//common:options",
10241044
"//runtime:function_binding_android",
10251045
"//runtime:runtime_equality_android",
@@ -1071,6 +1091,7 @@ java_library(
10711091
deps = [
10721092
":arithmetic_helpers",
10731093
":standard_overload",
1094+
"//common:operator",
10741095
"//common:options",
10751096
"//common:runtime_exception",
10761097
"//runtime:function_binding",
@@ -1090,6 +1111,7 @@ cel_android_library(
10901111
":arithmetic_helpers",
10911112
":standard_function_android",
10921113
":standard_overload_android",
1114+
"//common:operator_android",
10931115
"//common:options",
10941116
"//common:runtime_exception",
10951117
"//runtime:function_binding_android",
@@ -1107,6 +1129,7 @@ java_library(
11071129
deps = [
11081130
":arithmetic_helpers",
11091131
":standard_overload",
1132+
"//common:operator",
11101133
"//common:options",
11111134
"//common:runtime_exception",
11121135
"//runtime:function_binding",
@@ -1126,6 +1149,7 @@ cel_android_library(
11261149
":arithmetic_helpers",
11271150
":standard_function_android",
11281151
":standard_overload_android",
1152+
"//common:operator_android",
11291153
"//common:options",
11301154
"//common:runtime_exception",
11311155
"//runtime:function_binding_android",
@@ -1143,6 +1167,7 @@ java_library(
11431167
deps = [
11441168
":arithmetic_helpers",
11451169
":standard_overload",
1170+
"//common:operator",
11461171
"//common:options",
11471172
"//common:runtime_exception",
11481173
"//runtime:function_binding",
@@ -1162,6 +1187,7 @@ cel_android_library(
11621187
":arithmetic_helpers",
11631188
":standard_function_android",
11641189
":standard_overload_android",
1190+
"//common:operator_android",
11651191
"//common:options",
11661192
"//common:runtime_exception",
11671193
"//runtime:function_binding_android",
@@ -1179,6 +1205,7 @@ java_library(
11791205
deps = [
11801206
":arithmetic_helpers",
11811207
":standard_overload",
1208+
"//common:operator",
11821209
"//common:options",
11831210
"//common:runtime_exception",
11841211
"//runtime:function_binding",
@@ -1198,6 +1225,7 @@ cel_android_library(
11981225
":arithmetic_helpers",
11991226
":standard_function_android",
12001227
":standard_overload_android",
1228+
"//common:operator_android",
12011229
"//common:options",
12021230
"//common:runtime_exception",
12031231
"//runtime:function_binding_android",
@@ -1214,6 +1242,7 @@ java_library(
12141242
],
12151243
deps = [
12161244
":standard_overload",
1245+
"//common:operator",
12171246
"//common:options",
12181247
"//runtime:function_binding",
12191248
"//runtime:runtime_equality",
@@ -1230,6 +1259,7 @@ cel_android_library(
12301259
deps = [
12311260
":standard_function_android",
12321261
":standard_overload_android",
1262+
"//common:operator_android",
12331263
"//common:options",
12341264
"//runtime:function_binding_android",
12351265
"//runtime:runtime_equality_android",
@@ -1426,6 +1456,7 @@ java_library(
14261456
],
14271457
deps = [
14281458
":standard_overload",
1459+
"//common:operator",
14291460
"//common:options",
14301461
"//runtime:function_binding",
14311462
"//runtime:internal_function_binder",
@@ -1443,6 +1474,7 @@ cel_android_library(
14431474
deps = [
14441475
":standard_function_android",
14451476
":standard_overload_android",
1477+
"//common:operator_android",
14461478
"//common:options",
14471479
"//runtime:function_binding_android",
14481480
"//runtime:internal_function_binder_android",

runtime/src/main/java/dev/cel/runtime/standard/BoolFunction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,6 @@ public CelFunctionBinding newFunctionBinding(
8787
}
8888

8989
private BoolFunction(ImmutableSet<CelStandardOverload> overloads) {
90-
super(overloads);
90+
super("bool", overloads);
9191
}
9292
}

runtime/src/main/java/dev/cel/runtime/standard/BytesFunction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,6 @@ public CelFunctionBinding newFunctionBinding(
7676
}
7777

7878
private BytesFunction(ImmutableSet<CelStandardOverload> overloads) {
79-
super(overloads);
79+
super("bytes", overloads);
8080
}
8181
}

runtime/src/main/java/dev/cel/runtime/standard/CelStandardFunction.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414

1515
package dev.cel.runtime.standard;
1616

17-
import static com.google.common.base.Preconditions.checkState;
17+
import static com.google.common.base.Preconditions.checkArgument;
1818

19+
import com.google.common.base.Strings;
1920
import com.google.common.collect.ImmutableSet;
2021
import com.google.errorprone.annotations.Immutable;
2122
import dev.cel.common.CelOptions;
@@ -28,6 +29,7 @@
2829
*/
2930
@Immutable
3031
public abstract class CelStandardFunction {
32+
private final String name;
3133
private final ImmutableSet<CelStandardOverload> overloads;
3234

3335
public ImmutableSet<CelFunctionBinding> newFunctionBindings(
@@ -40,8 +42,10 @@ public ImmutableSet<CelFunctionBinding> newFunctionBindings(
4042
return builder.build();
4143
}
4244

43-
CelStandardFunction(ImmutableSet<CelStandardOverload> overloads) {
44-
checkState(!overloads.isEmpty(), "At least 1 overload must be provided.");
45+
CelStandardFunction(String name, ImmutableSet<CelStandardOverload> overloads) {
46+
checkArgument(!Strings.isNullOrEmpty(name), "Function name must be provided.");
47+
checkArgument(!overloads.isEmpty(), "At least 1 overload must be provided.");
4548
this.overloads = overloads;
49+
this.name = name;
4650
}
4751
}

runtime/src/main/java/dev/cel/runtime/standard/ContainsFunction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,6 @@ public CelFunctionBinding newFunctionBinding(
5858
}
5959

6060
private ContainsFunction(ImmutableSet<CelStandardOverload> overloads) {
61-
super(overloads);
61+
super("contains", overloads);
6262
}
6363
}

runtime/src/main/java/dev/cel/runtime/standard/DivideOperator.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
package dev.cel.runtime.standard;
1616

17+
import static dev.cel.common.Operator.DIVIDE;
1718
import static dev.cel.runtime.standard.ArithmeticHelpers.getArithmeticErrorCode;
1819

1920
import com.google.common.collect.ImmutableSet;
@@ -90,6 +91,6 @@ public CelFunctionBinding newFunctionBinding(
9091
}
9192

9293
private DivideOperator(ImmutableSet<CelStandardOverload> overloads) {
93-
super(overloads);
94+
super(DIVIDE.getFunction(), overloads);
9495
}
9596
}

runtime/src/main/java/dev/cel/runtime/standard/DoubleFunction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,6 @@ public CelFunctionBinding newFunctionBinding(
8787
}
8888

8989
private DoubleFunction(ImmutableSet<CelStandardOverload> overloads) {
90-
super(overloads);
90+
super("double", overloads);
9191
}
9292
}

0 commit comments

Comments
 (0)