Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ TRUTH_VERSION = "1.4.4"

PROTOBUF_JAVA_VERSION = "4.33.5"

CEL_VERSION = "0.12.0"
CEL_VERSION = "0.13.0"

# Compile only artifacts
[
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ CEL-Java is available in Maven Central Repository. [Download the JARs here][8] o
<dependency>
<groupId>dev.cel</groupId>
<artifactId>cel</artifactId>
<version>0.12.0</version>
<version>0.13.0</version>
</dependency>
```

**Gradle**

```gradle
implementation 'dev.cel:cel:0.12.0'
implementation 'dev.cel:cel:0.13.0'
```

Then run this example:
Expand Down
2 changes: 1 addition & 1 deletion extensions/src/main/java/dev/cel/extensions/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ java_library(
":strings",
"//common:options",
"//extensions:extension_library",
"@maven//:com_google_errorprone_error_prone_annotations",
"@maven//:com_google_guava_guava",
],
)
Expand Down Expand Up @@ -121,7 +122,6 @@ java_library(
":extension_library",
"//checker:checker_builder",
"//common:compiler_common",
"//common:options",
"//common/ast",
"//common/exceptions:numeric_overflow",
"//common/internal:comparison_functions",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,13 @@ public void setRuntimeOptions(CelRuntimeBuilder runtimeBuilder) {
functions.forEach(
function -> {
if (celOptions.evaluateCanonicalTypesToNativeValues()) {
runtimeBuilder.addFunctionBindings(function.nativeBytesFunctionBinding);
runtimeBuilder.addFunctionBindings(
CelFunctionBinding.fromOverloads(
function.getFunction(), function.nativeBytesFunctionBinding));
} else {
runtimeBuilder.addFunctionBindings(function.protoBytesFunctionBinding);
runtimeBuilder.addFunctionBindings(
CelFunctionBinding.fromOverloads(
function.getFunction(), function.protoBytesFunctionBinding));
}
});
}
Expand Down
69 changes: 50 additions & 19 deletions extensions/src/main/java/dev/cel/extensions/CelExtensions.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@

import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Streams;
import com.google.errorprone.annotations.InlineMe;
import dev.cel.common.CelOptions;
import dev.cel.extensions.CelMathExtensions.Function;
import java.util.Set;

/**
Expand Down Expand Up @@ -121,21 +123,18 @@ public static CelProtoExtensions protos() {
* <p>This will include all functions denoted in {@link CelMathExtensions.Function}, including any
* future additions. To expose only a subset of these, use {@link #math(CelOptions,
* CelMathExtensions.Function...)} or {@link #math(CelOptions,int)} instead.
*
* @param celOptions CelOptions to configure CelMathExtension with. This should be the same
* options object used to configure the compilation/runtime environments.
*/
public static CelMathExtensions math(CelOptions celOptions) {
return CelMathExtensions.library(celOptions).latest();
public static CelMathExtensions math() {
return CelMathExtensions.library().latest();
}

/**
* Returns the specified version of the 'math' extension.
*
* <p>Refer to README.md for functions available in each version.
*/
public static CelMathExtensions math(CelOptions celOptions, int version) {
return CelMathExtensions.library(celOptions).version(version);
public static CelMathExtensions math(int version) {
return CelMathExtensions.library().version(version);
}

/**
Expand All @@ -150,13 +149,9 @@ public static CelMathExtensions math(CelOptions celOptions, int version) {
* collision.
*
* <p>This will include only the specific functions denoted by {@link CelMathExtensions.Function}.
*
* @param celOptions CelOptions to configure CelMathExtension with. This should be the same
* options object used to configure the compilation/runtime environments.
*/
public static CelMathExtensions math(
CelOptions celOptions, CelMathExtensions.Function... functions) {
return math(celOptions, ImmutableSet.copyOf(functions));
public static CelMathExtensions math(CelMathExtensions.Function... functions) {
return math(ImmutableSet.copyOf(functions));
}

/**
Expand All @@ -171,13 +166,49 @@ public static CelMathExtensions math(
* collision.
*
* <p>This will include only the specific functions denoted by {@link CelMathExtensions.Function}.
*
* @param celOptions CelOptions to configure CelMathExtension with. This should be the same
* options object used to configure the compilation/runtime environments.
*/
public static CelMathExtensions math(Set<CelMathExtensions.Function> functions) {
return new CelMathExtensions(functions);
}

/**
* @deprecated Use {@link #math()} instead.
*/
@Deprecated
@InlineMe(replacement = "CelExtensions.math()", imports = "dev.cel.extensions.CelExtensions")
public static CelMathExtensions math(CelOptions unused) {
return math();
}

/**
* @deprecated Use {@link #math(int)} instead.
*/
@Deprecated
@InlineMe(
replacement = "CelExtensions.math(version)",
imports = "dev.cel.extensions.CelExtensions")
public static CelMathExtensions math(CelOptions unused, int version) {
return math(version);
}

/**
* @deprecated Use {@link #math(Function...)} instead.
*/
@Deprecated
public static CelMathExtensions math(CelOptions unused, CelMathExtensions.Function... functions) {
return math(ImmutableSet.copyOf(functions));
}

/**
* @deprecated Use {@link #math(Set)} instead.
*/
@Deprecated
@InlineMe(
replacement = "CelExtensions.math(functions)",
imports = "dev.cel.extensions.CelExtensions")
public static CelMathExtensions math(
CelOptions celOptions, Set<CelMathExtensions.Function> functions) {
return new CelMathExtensions(celOptions, functions);
CelOptions unused, Set<CelMathExtensions.Function> functions) {
return math(functions);
}

/**
Expand Down Expand Up @@ -354,7 +385,7 @@ public static CelExtensionLibrary<? extends CelExtensionLibrary.FeatureSet> getE
case "lists":
return CelListsExtensions.library();
case "math":
return CelMathExtensions.library(options);
return CelMathExtensions.library();
case "optional":
return CelOptionalLibrary.library();
case "protos":
Expand Down
Loading
Loading