refactor(pyargus): make pyargus depend only on argus
This commit is contained in:
parent
db3a63f9e1
commit
444d60197d
6 changed files with 32 additions and 64 deletions
|
|
@ -1,6 +1,6 @@
|
|||
use std::time::Duration;
|
||||
|
||||
use argus_core::prelude::*;
|
||||
use argus::expr::*;
|
||||
use pyo3::prelude::*;
|
||||
use pyo3::pyclass::CompareOp;
|
||||
|
||||
|
|
@ -62,7 +62,7 @@ pub struct ConstInt;
|
|||
impl ConstInt {
|
||||
#[new]
|
||||
fn new(val: i64) -> (Self, PyNumExpr) {
|
||||
(Self, Box::new(NumExpr::IntLit(argus_core::expr::IntLit(val))).into())
|
||||
(Self, Box::new(NumExpr::IntLit(argus::expr::IntLit(val))).into())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -79,7 +79,7 @@ pub struct ConstUInt;
|
|||
impl ConstUInt {
|
||||
#[new]
|
||||
fn new(val: u64) -> (Self, PyNumExpr) {
|
||||
(Self, Box::new(NumExpr::UIntLit(argus_core::expr::UIntLit(val))).into())
|
||||
(Self, Box::new(NumExpr::UIntLit(argus::expr::UIntLit(val))).into())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -91,10 +91,7 @@ pub struct ConstFloat;
|
|||
impl ConstFloat {
|
||||
#[new]
|
||||
fn new(val: f64) -> (Self, PyNumExpr) {
|
||||
(
|
||||
Self,
|
||||
Box::new(NumExpr::FloatLit(argus_core::expr::FloatLit(val))).into(),
|
||||
)
|
||||
(Self, Box::new(NumExpr::FloatLit(argus::expr::FloatLit(val))).into())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -106,10 +103,7 @@ pub struct VarInt;
|
|||
impl VarInt {
|
||||
#[new]
|
||||
fn new(name: String) -> (Self, PyNumExpr) {
|
||||
(
|
||||
Self,
|
||||
Box::new(NumExpr::IntVar(argus_core::expr::IntVar { name })).into(),
|
||||
)
|
||||
(Self, Box::new(NumExpr::IntVar(argus::expr::IntVar { name })).into())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -121,10 +115,7 @@ pub struct VarUInt;
|
|||
impl VarUInt {
|
||||
#[new]
|
||||
fn new(name: String) -> (Self, PyNumExpr) {
|
||||
(
|
||||
Self,
|
||||
Box::new(NumExpr::UIntVar(argus_core::expr::UIntVar { name })).into(),
|
||||
)
|
||||
(Self, Box::new(NumExpr::UIntVar(argus::expr::UIntVar { name })).into())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -136,10 +127,7 @@ pub struct VarFloat;
|
|||
impl VarFloat {
|
||||
#[new]
|
||||
fn new(name: String) -> (Self, PyNumExpr) {
|
||||
(
|
||||
Self,
|
||||
Box::new(NumExpr::FloatVar(argus_core::expr::FloatVar { name })).into(),
|
||||
)
|
||||
(Self, Box::new(NumExpr::FloatVar(argus::expr::FloatVar { name })).into())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -152,7 +140,7 @@ impl Negate {
|
|||
#[new]
|
||||
fn new(arg: PyNumExpr) -> (Self, PyNumExpr) {
|
||||
let arg = arg.0;
|
||||
(Self, Box::new(NumExpr::Neg(argus_core::expr::Neg { arg })).into())
|
||||
(Self, Box::new(NumExpr::Neg(argus::expr::Neg { arg })).into())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -167,7 +155,7 @@ impl Add {
|
|||
#[new]
|
||||
fn new(args: Vec<PyNumExpr>) -> (Self, PyNumExpr) {
|
||||
let args: Vec<NumExpr> = args.into_iter().map(|arg| *arg.0).collect();
|
||||
(Self, Box::new(NumExpr::Add(argus_core::expr::Add { args })).into())
|
||||
(Self, Box::new(NumExpr::Add(argus::expr::Add { args })).into())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -180,7 +168,7 @@ impl Sub {
|
|||
fn new(lhs: PyNumExpr, rhs: PyNumExpr) -> (Self, PyNumExpr) {
|
||||
let lhs = lhs.0;
|
||||
let rhs = rhs.0;
|
||||
(Self, Box::new(NumExpr::Sub(argus_core::expr::Sub { lhs, rhs })).into())
|
||||
(Self, Box::new(NumExpr::Sub(argus::expr::Sub { lhs, rhs })).into())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -192,7 +180,7 @@ impl Mul {
|
|||
#[new]
|
||||
fn new(args: Vec<PyNumExpr>) -> (Self, PyNumExpr) {
|
||||
let args: Vec<NumExpr> = args.into_iter().map(|arg| *arg.0).collect();
|
||||
(Self, Box::new(NumExpr::Mul(argus_core::expr::Mul { args })).into())
|
||||
(Self, Box::new(NumExpr::Mul(argus::expr::Mul { args })).into())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -207,7 +195,7 @@ impl Div {
|
|||
let divisor = divisor.0;
|
||||
(
|
||||
Self,
|
||||
Box::new(NumExpr::Div(argus_core::expr::Div { dividend, divisor })).into(),
|
||||
Box::new(NumExpr::Div(argus::expr::Div { dividend, divisor })).into(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -220,7 +208,7 @@ impl Abs {
|
|||
#[new]
|
||||
fn new(arg: PyNumExpr) -> (Self, PyNumExpr) {
|
||||
let arg = arg.0;
|
||||
(Self, Box::new(NumExpr::Abs(argus_core::expr::Abs { arg })).into())
|
||||
(Self, Box::new(NumExpr::Abs(argus::expr::Abs { arg })).into())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -254,7 +242,7 @@ pub struct ConstBool;
|
|||
impl ConstBool {
|
||||
#[new]
|
||||
fn new(val: bool) -> (Self, PyBoolExpr) {
|
||||
(Self, Box::new(BoolExpr::BoolLit(argus_core::expr::BoolLit(val))).into())
|
||||
(Self, Box::new(BoolExpr::BoolLit(argus::expr::BoolLit(val))).into())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -265,10 +253,7 @@ pub struct VarBool;
|
|||
impl VarBool {
|
||||
#[new]
|
||||
fn new(name: String) -> (Self, PyBoolExpr) {
|
||||
(
|
||||
Self,
|
||||
Box::new(BoolExpr::BoolVar(argus_core::expr::BoolVar { name })).into(),
|
||||
)
|
||||
(Self, Box::new(BoolExpr::BoolVar(argus::expr::BoolVar { name })).into())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -284,10 +269,7 @@ impl Cmp {
|
|||
let op = op.0;
|
||||
let lhs = lhs.0;
|
||||
let rhs = rhs.0;
|
||||
(
|
||||
Self,
|
||||
Box::new(BoolExpr::Cmp(argus_core::expr::Cmp { op, lhs, rhs })).into(),
|
||||
)
|
||||
(Self, Box::new(BoolExpr::Cmp(argus::expr::Cmp { op, lhs, rhs })).into())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -332,7 +314,7 @@ impl Not {
|
|||
#[new]
|
||||
fn new(arg: PyBoolExpr) -> (Self, PyBoolExpr) {
|
||||
let arg = arg.0;
|
||||
(Self, PyBoolExpr(Box::new(BoolExpr::Not(argus_core::expr::Not { arg }))))
|
||||
(Self, PyBoolExpr(Box::new(BoolExpr::Not(argus::expr::Not { arg }))))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -344,10 +326,7 @@ impl And {
|
|||
#[new]
|
||||
fn new(args: Vec<PyBoolExpr>) -> (Self, PyBoolExpr) {
|
||||
let args: Vec<BoolExpr> = args.into_iter().map(|arg| *arg.0).collect();
|
||||
(
|
||||
Self,
|
||||
PyBoolExpr(Box::new(BoolExpr::And(argus_core::expr::And { args }))),
|
||||
)
|
||||
(Self, PyBoolExpr(Box::new(BoolExpr::And(argus::expr::And { args }))))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -359,7 +338,7 @@ impl Or {
|
|||
#[new]
|
||||
fn new(args: Vec<PyBoolExpr>) -> (Self, PyBoolExpr) {
|
||||
let args: Vec<BoolExpr> = args.into_iter().map(|arg| *arg.0).collect();
|
||||
(Self, PyBoolExpr(Box::new(BoolExpr::Or(argus_core::expr::Or { args }))))
|
||||
(Self, PyBoolExpr(Box::new(BoolExpr::Or(argus::expr::Or { args }))))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -371,10 +350,7 @@ impl Next {
|
|||
#[new]
|
||||
fn new(arg: PyBoolExpr) -> (Self, PyBoolExpr) {
|
||||
let arg = arg.0;
|
||||
(
|
||||
Self,
|
||||
PyBoolExpr(Box::new(BoolExpr::Next(argus_core::expr::Next { arg }))),
|
||||
)
|
||||
(Self, PyBoolExpr(Box::new(BoolExpr::Next(argus::expr::Next { arg }))))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -395,7 +371,7 @@ impl Always {
|
|||
};
|
||||
(
|
||||
Self,
|
||||
PyBoolExpr(Box::new(BoolExpr::Always(argus_core::expr::Always { arg, interval }))),
|
||||
PyBoolExpr(Box::new(BoolExpr::Always(argus::expr::Always { arg, interval }))),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -417,7 +393,7 @@ impl Eventually {
|
|||
};
|
||||
(
|
||||
Self,
|
||||
PyBoolExpr(Box::new(BoolExpr::Eventually(argus_core::expr::Eventually {
|
||||
PyBoolExpr(Box::new(BoolExpr::Eventually(argus::expr::Eventually {
|
||||
arg,
|
||||
interval,
|
||||
}))),
|
||||
|
|
@ -443,11 +419,7 @@ impl Until {
|
|||
};
|
||||
(
|
||||
Self,
|
||||
PyBoolExpr(Box::new(BoolExpr::Until(argus_core::expr::Until {
|
||||
lhs,
|
||||
rhs,
|
||||
interval,
|
||||
}))),
|
||||
PyBoolExpr(Box::new(BoolExpr::Until(argus::expr::Until { lhs, rhs, interval }))),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue