From 44396619acd821ad9a385019b53f6235f292fb17 Mon Sep 17 00:00:00 2001 From: Kevin Phoenix Date: Tue, 5 Nov 2024 12:11:09 -0700 Subject: [PATCH] Implement __eq__ and __ne__ for python Bool (#30) --- crates/clarirs_py/src/ast/bool.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/crates/clarirs_py/src/ast/bool.rs b/crates/clarirs_py/src/ast/bool.rs index 65893d5..53cfa20 100644 --- a/crates/clarirs_py/src/ast/bool.rs +++ b/crates/clarirs_py/src/ast/bool.rs @@ -300,6 +300,20 @@ impl Bool { &GLOBAL_CONTEXT.xor(&self.inner, &>::into(other))?, ) } + + pub fn __eq__(&self, py: Python, other: CoerceBool) -> Result, ClaripyError> { + Bool::new( + py, + &GLOBAL_CONTEXT.eq_(&self.inner, &>::into(other))?, + ) + } + + pub fn __ne__(&self, py: Python, other: CoerceBool) -> Result, ClaripyError> { + Bool::new( + py, + &GLOBAL_CONTEXT.neq(&self.inner, &>::into(other))?, + ) + } } #[pyfunction(signature = (name, explicit_name = false))]