Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.1.6 #6

Merged
merged 4 commits into from
Sep 30, 2024
Merged
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 Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cel-eval"
version = "0.1.4"
version = "0.1.6"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.htmlž
Expand Down
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,20 @@ The JSON is required to be in shape of `ExecutionContext`, which is defined as:
]
},
// Functions for our platform object - signature will be changed soon to allow for args
"platform" : {
"functionName" : "fallbackValue"
"computed" : {
"functionName": [{ // List of args
"type": "string",
"value": "event_name"
}]
},
// Functions for our device object - signature will be changed soon to allow for args
"device" : {
"functionName": [{ // List of args
"type": "string",
"value": "event_name"
}]
}

}},
// The expression to evaluate
"expression": "foo == 100"
Expand Down
3 changes: 2 additions & 1 deletion src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ use std::sync::Arc;
pub(crate) struct ASTExecutionContext {
pub(crate) variables: PassableMap,
pub(crate) expression: JSONExpression,
pub(crate) platform: Option<HashMap<String, Vec<PassableValue>>>,
pub(crate) computed: Option<HashMap<String, Vec<PassableValue>>>,
pub(crate) device: Option<HashMap<String, Vec<PassableValue>>>
}

#[derive(Debug, Eq, PartialEq, Clone, Serialize, Deserialize)]
Expand Down
4 changes: 4 additions & 0 deletions src/cel.udl
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@
interface HostContext {
[Async]
string computed_property(string name, string args);
[Async]
string device_property(string name, string args);

};

namespace cel {
string evaluate_with_context(string definition, HostContext context);
string evaluate_ast_with_context(string definition, HostContext context);
string evaluate_ast(string ast);
string parse_to_ast(string expression);
};
Loading