Skip to content

Commit

Permalink
Merge pull request #6 from superwall/develop
Browse files Browse the repository at this point in the history
0.1.6
  • Loading branch information
ianrumac authored Sep 30, 2024
2 parents 1de4542 + 9e5f061 commit daa8d67
Show file tree
Hide file tree
Showing 8 changed files with 184 additions and 46 deletions.
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

0 comments on commit daa8d67

Please sign in to comment.