refactor!(py): Boolean semantics should be exposed as function
This commit is contained in:
parent
e6ef427e2f
commit
bfb59c1008
1 changed files with 5 additions and 11 deletions
|
|
@ -82,21 +82,15 @@ impl Trace for PyTrace {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[pyclass(name = "BooleanSemantics")]
|
#[pyfunction]
|
||||||
struct PyBooleanSemantics;
|
fn eval_bool_semantics(expr: &PyBoolExpr, trace: &PyTrace) -> PyResult<Py<BoolSignal>> {
|
||||||
|
|
||||||
#[pymethods]
|
|
||||||
impl PyBooleanSemantics {
|
|
||||||
#[staticmethod]
|
|
||||||
fn eval(expr: &PyBoolExpr, trace: &PyTrace) -> PyResult<Py<BoolSignal>> {
|
|
||||||
let sig = BooleanSemantics::eval(&expr.0, trace, ()).map_err(PyArgusError::from)?;
|
let sig = BooleanSemantics::eval(&expr.0, trace, ()).map_err(PyArgusError::from)?;
|
||||||
Python::with_gil(|py| Py::new(py, (BoolSignal::from(sig), BoolSignal::super_type())))
|
Python::with_gil(|py| Py::new(py, (BoolSignal::from(sig), BoolSignal::super_type())))
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
pub fn init(_py: Python, m: &PyModule) -> PyResult<()> {
|
pub fn init(_py: Python, m: &PyModule) -> PyResult<()> {
|
||||||
m.add_class::<PyBooleanSemantics>()?;
|
|
||||||
m.add_class::<PyTrace>()?;
|
m.add_class::<PyTrace>()?;
|
||||||
|
m.add_function(wrap_pyfunction!(eval_bool_semantics, m)?)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue