From 2c31baaa0cd9e9da80166947f06d0bcbad05f9cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 4 Jun 2019 10:47:38 +0300 Subject: [PATCH] gstreamer: Implement Add for gst::TypeFindProbability and fix comparison While the enum is a signed integer, all operations inside GStreamer (especially comparison) is based on unsigned integers. --- Gir_Gst.toml | 2 +- gstreamer/src/auto/enums.rs | 2 +- gstreamer/src/enums.rs | 44 +++++++++++++++++++++++++++++++++++-- 3 files changed, 44 insertions(+), 4 deletions(-) diff --git a/Gir_Gst.toml b/Gir_Gst.toml index 99dbd81f4..9e809744e 100644 --- a/Gir_Gst.toml +++ b/Gir_Gst.toml @@ -235,7 +235,7 @@ status = "generate" name = "Gst.TypeFindProbability" status = "generate" [[object.derive]] - name = "Debug, PartialEq, Eq, Hash" + name = "Debug" [[object]] name = "Gst.EventType" diff --git a/gstreamer/src/auto/enums.rs b/gstreamer/src/auto/enums.rs index bf07cf47b..aeebeda7b 100644 --- a/gstreamer/src/auto/enums.rs +++ b/gstreamer/src/auto/enums.rs @@ -2848,7 +2848,7 @@ impl SetValue for TocScope { } } - #[derive(Debug, PartialEq, Eq, Hash)] + #[derive(Debug)] #[derive(Clone, Copy)] pub enum TypeFindProbability { None, diff --git a/gstreamer/src/enums.rs b/gstreamer/src/enums.rs index 6911128b3..28798a890 100644 --- a/gstreamer/src/enums.rs +++ b/gstreamer/src/enums.rs @@ -385,15 +385,55 @@ impl From> for ClockReturn { } } +impl PartialEq for ::TypeFindProbability { + fn eq(&self, other: &::TypeFindProbability) -> bool { + (self.to_glib() as u32).eq(&(other.to_glib() as u32)) + } +} + +impl Eq for ::TypeFindProbability {} + impl PartialOrd for ::TypeFindProbability { fn partial_cmp(&self, other: &Self) -> Option { - self.to_glib().partial_cmp(&other.to_glib()) + (self.to_glib() as u32).partial_cmp(&(other.to_glib() as u32)) } } impl Ord for ::TypeFindProbability { fn cmp(&self, other: &Self) -> cmp::Ordering { - self.to_glib().cmp(&other.to_glib()) + (self.to_glib() as u32).cmp(&(other.to_glib() as u32)) + } +} + +impl ops::Add for ::TypeFindProbability { + type Output = ::TypeFindProbability; + + fn add(self, rhs: u32) -> ::TypeFindProbability { + let res = (self.to_glib() as u32).saturating_add(rhs); + from_glib(res as i32) + } +} + +impl ops::AddAssign for ::TypeFindProbability { + fn add_assign(&mut self, rhs: u32) { + let res = (self.to_glib() as u32).saturating_add(rhs); + *self = from_glib(res as i32); + } +} + +impl ops::Sub for ::TypeFindProbability { + type Output = ::TypeFindProbability; + + fn sub(self, rhs: u32) -> ::TypeFindProbability { + let res = (self.to_glib() as u32).saturating_sub(rhs); + from_glib(res as i32) + } +} + +impl ops::SubAssign for ::TypeFindProbability { + fn sub_assign(&mut self, rhs: u32) { + let res = (self.to_glib() as u32).saturating_sub(rhs); + *self = from_glib(res as i32); } }