feat(pyargus): add temporal operators to bindings

This commit is contained in:
Anand Balakrishnan 2023-04-26 13:19:35 -07:00
parent bfd5178982
commit 4b4d02a0ec
No known key found for this signature in database
2 changed files with 54 additions and 1 deletions

View file

@ -318,6 +318,55 @@ impl Or {
}
}
#[pyclass(extends=PyBoolExpr)]
struct Next;
#[pymethods]
impl Next {
#[new]
fn new(arg: PyBoolExpr) -> (Self, PyBoolExpr) {
let arg = arg.0;
(Self, PyBoolExpr(Box::new(BoolExpr::Next { arg })))
}
}
#[pyclass(extends=PyBoolExpr)]
struct Always;
#[pymethods]
impl Always {
#[new]
fn new(arg: PyBoolExpr) -> (Self, PyBoolExpr) {
let arg = arg.0;
(Self, PyBoolExpr(Box::new(BoolExpr::Always { arg })))
}
}
#[pyclass(extends=PyBoolExpr)]
struct Eventually;
#[pymethods]
impl Eventually {
#[new]
fn new(arg: PyBoolExpr) -> (Self, PyBoolExpr) {
let arg = arg.0;
(Self, PyBoolExpr(Box::new(BoolExpr::Eventually { arg })))
}
}
#[pyclass(extends=PyBoolExpr)]
struct Until;
#[pymethods]
impl Until {
#[new]
fn new(lhs: PyBoolExpr, rhs: PyBoolExpr) -> (Self, PyBoolExpr) {
let lhs = lhs.0;
let rhs = rhs.0;
(Self, PyBoolExpr(Box::new(BoolExpr::Until { lhs, rhs })))
}
}
#[pymodule]
#[pyo3(name = "_argus")]
fn pyargus(_py: Python, m: &PyModule) -> PyResult<()> {
@ -340,6 +389,10 @@ fn pyargus(_py: Python, m: &PyModule) -> PyResult<()> {
m.add_class::<Not>()?;
m.add_class::<And>()?;
m.add_class::<Or>()?;
m.add_class::<Next>()?;
m.add_class::<Always>()?;
m.add_class::<Eventually>()?;
m.add_class::<Until>()?;
Ok(())
}