From 6f06a26327dc4c5fee38d4f0f74859fc180519f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Sun, 12 Feb 2023 13:27:59 +0200 Subject: [PATCH] Add support for inline variable names in error/warning/info message creation macros Simply by removing the special-casing of string literals, which doesn't really bring any improvements here. Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/issues/442 Part-of: --- gstreamer-audio/src/audio_decoder.rs | 36 ---- gstreamer-video/src/video_decoder.rs | 36 ---- gstreamer/src/element.rs | 297 --------------------------- gstreamer/src/error.rs | 18 -- 4 files changed, 387 deletions(-) diff --git a/gstreamer-audio/src/audio_decoder.rs b/gstreamer-audio/src/audio_decoder.rs index 635078a8c..ba720afc5 100644 --- a/gstreamer-audio/src/audio_decoder.rs +++ b/gstreamer-audio/src/audio_decoder.rs @@ -152,42 +152,6 @@ impl> AudioDecoderExtManual for O { #[macro_export] macro_rules! audio_decoder_error( - ($obj:expr, $weight:expr, $err:expr, ($msg:expr), [$debug:expr]) => { { - use $crate::prelude::AudioDecoderExtManual; - $obj.error( - $weight, - $err, - Some($msg), - Some($debug), - file!(), - $crate::glib::function_name!(), - line!(), - ) - }}; - ($obj:expr, $weight:expr, $err:expr, ($msg:expr)) => { { - use $crate::prelude::AudioDecoderExtManual; - $obj.error( - $weight, - $err, - Some($msg), - None, - file!(), - $crate::glib::function_name!(), - line!(), - ) - }}; - ($obj:expr, $weight:expr, $err:expr, [$debug:expr]) => { { - use $crate::prelude::AudioDecoderExtManual; - $obj.error( - $weight, - $err, - None, - Some($debug), - file!(), - $crate::glib::function_name!(), - line!(), - ) - }}; ($obj:expr, $weight:expr, $err:expr, ($($msg:tt)*), [$($debug:tt)*]) => { { use $crate::prelude::AudioDecoderExtManual; $obj.error( diff --git a/gstreamer-video/src/video_decoder.rs b/gstreamer-video/src/video_decoder.rs index 5f4a9d981..de54c32a8 100644 --- a/gstreamer-video/src/video_decoder.rs +++ b/gstreamer-video/src/video_decoder.rs @@ -353,42 +353,6 @@ impl HasStreamLock for VideoDecoder { #[macro_export] macro_rules! video_decoder_error( - ($obj:expr, $weight:expr, $err:expr, ($msg:expr), [$debug:expr]) => { { - use $crate::prelude::VideoDecoderExtManual; - $obj.error( - $weight, - $err, - Some($msg), - Some($debug), - file!(), - $crate::glib::function_name!(), - line!(), - ) - }}; - ($obj:expr, $weight:expr, $err:expr, ($msg:expr)) => { { - use $crate::prelude::VideoDecoderExtManual; - $obj.error( - $weight, - $err, - Some($msg), - None, - file!(), - $crate::glib::function_name!(), - line!(), - ) - }}; - ($obj:expr, $weight:expr, $err:expr, [$debug:expr]) => { { - use $crate::prelude::VideoDecoderExtManual; - $obj.error( - $weight, - $err, - None, - Some($debug), - file!(), - $crate::glib::function_name!(), - line!(), - ) - }}; ($obj:expr, $weight:expr, $err:expr, ($($msg:tt)*), [$($debug:tt)*]) => { { use $crate::prelude::VideoDecoderExtManual; $obj.error( diff --git a/gstreamer/src/element.rs b/gstreamer/src/element.rs index 2e2724b84..ddb79f121 100644 --- a/gstreamer/src/element.rs +++ b/gstreamer/src/element.rs @@ -1003,42 +1003,6 @@ pub static ELEMENT_METADATA_LONGNAME: &glib::GStr = #[doc(alias = "GST_ELEMENT_ERROR_WITH_DETAILS")] #[macro_export] macro_rules! element_error( - ($obj:expr, $err:expr, ($msg:expr), [$debug:expr]) => { { - use $crate::prelude::ElementExtManual; - $obj.message_full( - $crate::ElementMessageType::Error, - $err, - Some($msg), - Some($debug), - file!(), - $crate::glib::function_name!(), - line!(), - ); - }}; - ($obj:expr, $err:expr, ($msg:expr)) => { { - use $crate::prelude::ElementExtManual; - $obj.message_full( - $crate::ElementMessageType::Error, - $err, - Some($msg), - None, - file!(), - $crate::glib::function_name!(), - line!(), - ); - }}; - ($obj:expr, $err:expr, [$debug:expr]) => { { - use $crate::prelude::ElementExtManual; - $obj.message_full( - $crate::ElementMessageType::Error, - $err, - None, - Some($debug), - file!(), - $crate::glib::function_name!(), - line!(), - ); - }}; ($obj:expr, $err:expr, ($($msg:tt)*), [$($debug:tt)*]) => { { use $crate::prelude::ElementExtManual; $obj.message_full( @@ -1076,45 +1040,6 @@ macro_rules! element_error( ); }}; - ($obj:expr, $err:expr, ($msg:expr), [$debug:expr], details: $details:expr) => { { - use $crate::prelude::ElementExtManual; - $obj.message_full_with_details( - $crate::ElementMessageType::Error, - $err, - Some($msg), - Some($debug), - file!(), - $crate::glib::function_name!(), - line!(), - $details, - ); - }}; - ($obj:expr, $err:expr, ($msg:expr), details: $details:expr) => { { - use $crate::prelude::ElementExtManual; - $obj.message_full_with_details( - $crate::ElementMessageType::Error, - $err, - Some($msg), - None, - file!(), - $crate::glib::function_name!(), - line!(), - $details, - ); - }}; - ($obj:expr, $err:expr, [$debug:expr], details: $details:expr) => { { - use $crate::prelude::ElementExtManual; - $obj.message_full_with_details( - $crate::ElementMessageType::Error, - $err, - None, - Some($debug), - file!(), - $crate::glib::function_name!(), - line!(), - $details, - ); - }}; ($obj:expr, $err:expr, ($($msg:tt)*), [$($debug:tt)*], details: $details:expr) => { { use $crate::prelude::ElementExtManual; $obj.message_full_with_details( @@ -1160,42 +1085,6 @@ macro_rules! element_error( #[doc(alias = "GST_ELEMENT_WARNING_WITH_DETAILS")] #[macro_export] macro_rules! element_warning( - ($obj:expr, $err:expr, ($msg:expr), [$debug:expr]) => { { - use $crate::prelude::ElementExtManual; - $obj.message_full( - $crate::ElementMessageType::Warning, - $err, - Some($msg), - Some($debug), - file!(), - $crate::glib::function_name!(), - line!(), - ); - }}; - ($obj:expr, $err:expr, ($msg:expr)) => { { - use $crate::prelude::ElementExtManual; - $obj.message_full( - $crate::ElementMessageType::Warning, - $err, - Some($msg), - None, - file!(), - $crate::glib::function_name!(), - line!(), - ); - }}; - ($obj:expr, $err:expr, [$debug:expr]) => { { - use $crate::prelude::ElementExtManual; - $obj.message_full( - $crate::ElementMessageType::Warning, - $err, - None, - Some($debug), - file!(), - $crate::glib::function_name!(), - line!(), - ); - }}; ($obj:expr, $err:expr, ($($msg:tt)*), [$($debug:tt)*]) => { { use $crate::prelude::ElementExtManual; $obj.message_full( @@ -1233,45 +1122,6 @@ macro_rules! element_warning( ); }}; - ($obj:expr, $err:expr, ($msg:expr), [$debug:expr], details: $details:expr) => { { - use $crate::prelude::ElementExtManual; - $obj.message_full_with_details( - $crate::ElementMessageType::Warning, - $err, - Some($msg), - Some($debug), - file!(), - $crate::glib::function_name!(), - line!(), - $details, - ); - }}; - ($obj:expr, $err:expr, ($msg:expr), details: $details:expr) => { { - use $crate::prelude::ElementExtManual; - $obj.message_full_with_details( - $crate::ElementMessageType::Warning, - $err, - Some($msg), - None, - file!(), - $crate::glib::function_name!(), - line!(), - $details, - ); - }}; - ($obj:expr, $err:expr, [$debug:expr], details: $details:expr) => { { - use $crate::prelude::ElementExtManual; - $obj.message_full_with_details( - $crate::ElementMessageType::Warning, - $err, - None, - Some($debug), - file!(), - $crate::glib::function_name!(), - line!(), - $details, - ); - }}; ($obj:expr, $err:expr, ($($msg:tt)*), [$($debug:tt)*], details: $details:expr) => { { use $crate::prelude::ElementExtManual; $obj.message_full_with_details( @@ -1317,42 +1167,6 @@ macro_rules! element_warning( #[doc(alias = "GST_ELEMENT_INFO_WITH_DETAILS")] #[macro_export] macro_rules! element_info( - ($obj:expr, $err:expr, ($msg:expr), [$debug:expr]) => { { - use $crate::prelude::ElementExtManual; - $obj.message_full( - $crate::ElementMessageType::Info, - $err, - Some($msg), - Some($debug), - file!(), - $crate::glib::function_name!(), - line!(), - ); - }}; - ($obj:expr, $err:expr, ($msg:expr)) => { { - use $crate::prelude::ElementExtManual; - $obj.message_full( - $crate::ElementMessageType::Info, - $err, - Some($msg), - None, - file!(), - $crate::glib::function_name!(), - line!(), - ); - }}; - ($obj:expr, $err:expr, [$debug:expr]) => { { - use $crate::prelude::ElementExtManual; - $obj.message_full( - $crate::ElementMessageType::Info, - $err, - None, - Some($debug), - file!(), - $crate::glib::function_name!(), - line!(), - ); - }}; ($obj:expr, $err:expr, ($($msg:tt)*), [$($debug:tt)*]) => { { use $crate::prelude::ElementExtManual; $obj.message_full( @@ -1390,45 +1204,6 @@ macro_rules! element_info( ); }}; - ($obj:expr, $err:expr, ($msg:expr), [$debug:expr], details: $details:expr) => { { - use $crate::prelude::ElementExtManual; - $obj.message_full_with_details( - $crate::ElementMessageType::Info, - $err, - Some($msg), - Some($debug), - file!(), - $crate::glib::function_name!(), - line!(), - $details, - ); - }}; - ($obj:expr, $err:expr, ($msg:expr), details: $details:expr) => { { - use $crate::prelude::ElementExtManual; - $obj.message_full_with_details( - $crate::ElementMessageType::Info, - $err, - Some($msg), - None, - file!(), - $crate::glib::function_name!(), - line!(), - $details, - ); - }}; - ($obj:expr, $err:expr, [$debug:expr], details: $details:expr) => { { - use $crate::prelude::ElementExtManual; - $obj.message_full_with_details( - $crate::ElementMessageType::Info, - $err, - None, - Some($debug), - file!(), - $crate::glib::function_name!(), - line!(), - $details, - ); - }}; ($obj:expr, $err:expr, ($($msg:tt)*), [$($debug:tt)*], details: $details:expr) => { { use $crate::prelude::ElementExtManual; $obj.message_full_with_details( @@ -1474,18 +1249,6 @@ macro_rules! element_info( #[doc(alias = "GST_ELEMENT_ERROR_WITH_DETAILS")] #[macro_export] macro_rules! element_imp_error( - ($imp:expr, $err:expr, ($msg:expr), [$debug:expr]) => { { - let obj = $imp.obj(); - $crate::element_error!(obj, $err, ($msg), [$debug]); - }}; - ($imp:expr, $err:expr, ($msg:expr)) => { { - let obj = $imp.obj(); - $crate::element_error!(obj, $err, ($msg)); - }}; - ($imp:expr, $err:expr, [$debug:expr]) => { { - let obj = $imp.obj(); - $crate::element_error!(obj, $err, [$debug]); - }}; ($imp:expr, $err:expr, ($($msg:tt)*), [$($debug:tt)*]) => { { let obj = $imp.obj(); $crate::element_error!(obj, $err, ($($msg)*), [$($debug)*]); @@ -1499,18 +1262,6 @@ macro_rules! element_imp_error( $crate::element_error!(obj, $err, [$($debug)*]); }}; - ($imp:expr, $err:expr, ($msg:expr), [$debug:expr], details: $details:expr) => { { - let obj = $imp.obj(); - $crate::element_error!(obj, $err, ($msg), [$debug], details: $details); - }}; - ($imp:expr, $err:expr, ($msg:expr), details: $details:expr) => { { - let obj = $imp.obj(); - $crate::element_error!(obj, $err, ($msg), details: $details); - }}; - ($imp:expr, $err:expr, [$debug:expr], details: $details:expr) => { { - let obj = $imp.obj(); - $crate::element_error!(obj, $err, [$debug], details: $details); - }}; ($imp:expr, $err:expr, ($($msg:tt)*), [$($debug:tt)*], details: $details:expr) => { { let obj = $imp.obj(); $crate::element_error!(obj, $err, ($($msg)*), [$($debug)*], details: $details); @@ -1529,18 +1280,6 @@ macro_rules! element_imp_error( #[doc(alias = "GST_ELEMENT_WARNING_WITH_DETAILS")] #[macro_export] macro_rules! element_imp_warning( - ($imp:expr, $err:expr, ($msg:expr), [$debug:expr]) => { { - let obj = $imp.obj(); - $crate::element_warning!(obj, $err, ($msg), [$debug]); - }}; - ($imp:expr, $err:expr, ($msg:expr)) => { { - let obj = $imp.obj(); - $crate::element_warning!(obj, $err, ($msg)); - }}; - ($imp:expr, $err:expr, [$debug:expr]) => { { - let obj = $imp.obj(); - $crate::element_warning!(obj, $err, [$debug]); - }}; ($imp:expr, $err:expr, ($($msg:tt)*), [$($debug:tt)*]) => { { let obj = $imp.obj(); $crate::element_warning!(obj, $err, ($($msg)*), [$($debug)*]); @@ -1554,18 +1293,6 @@ macro_rules! element_imp_warning( $crate::element_warning!(obj, $err, [$($debug)*]); }}; - ($imp:expr, $err:expr, ($msg:expr), [$debug:expr], details: $details:expr) => { { - let obj = $imp.obj(); - $crate::element_warning!(obj, $err, ($msg), [$debug], details: $details); - }}; - ($imp:expr, $err:expr, ($msg:expr), details: $details:expr) => { { - let obj = $imp.obj(); - $crate::element_warning!(obj, $err, ($msg), details: $details); - }}; - ($imp:expr, $err:expr, [$debug:expr], details: $details:expr) => { { - let obj = $imp.obj(); - $crate::element_warning!(obj, $err, [$debug], details: $details); - }}; ($imp:expr, $err:expr, ($($msg:tt)*), [$($debug:tt)*], details: $details:expr) => { { let obj = $imp.obj(); $crate::element_warning!(obj, $err, ($($msg)*), [$($debug)*], details: $details); @@ -1584,18 +1311,6 @@ macro_rules! element_imp_warning( #[doc(alias = "GST_ELEMENT_INFO_WITH_DETAILS")] #[macro_export] macro_rules! element_imp_info( - ($imp:expr, $err:expr, ($msg:expr), [$debug:expr]) => { { - let obj = $imp.obj(); - $crate::element_info!(obj, $err, ($msg), [$debug]); - }}; - ($imp:expr, $err:expr, ($msg:expr)) => { { - let obj = $imp.obj(); - $crate::element_info!(obj, $err, ($msg)); - }}; - ($imp:expr, $err:expr, [$debug:expr]) => { { - let obj = $imp.obj(); - $crate::element_info!(obj, $err, [$debug]); - }}; ($imp:expr, $err:expr, ($($msg:tt)*), [$($debug:tt)*]) => { { let obj = $imp.obj(); $crate::element_info!(obj, $err, ($($msg)*), [$($debug)*]); @@ -1609,18 +1324,6 @@ macro_rules! element_imp_info( $crate::element_info!(obj, $err, [$($debug)*]); }}; - ($imp:expr, $err:expr, ($msg:expr), [$debug:expr], details: $details:expr) => { { - let obj = $imp.obj(); - $crate::element_info!(obj, $err, ($msg), [$debug], details: $details); - }}; - ($imp:expr, $err:expr, ($msg:expr), details: $details:expr) => { { - let obj = $imp.obj(); - $crate::element_info!(obj, $err, ($msg), details: $details); - }}; - ($imp:expr, $err:expr, [$debug:expr], details: $details:expr) => { { - let obj = $imp.obj(); - $crate::element_info!(obj, $err, [$debug], details: $details); - }}; ($imp:expr, $err:expr, ($($msg:tt)*), [$($debug:tt)*], details: $details:expr) => { { let obj = $imp.obj(); $crate::element_info!(obj, $err, ($($msg)*), [$($debug)*], details: $details); diff --git a/gstreamer/src/error.rs b/gstreamer/src/error.rs index 92e2d2a2c..c43926a82 100644 --- a/gstreamer/src/error.rs +++ b/gstreamer/src/error.rs @@ -5,24 +5,6 @@ use thiserror::Error; #[macro_export] macro_rules! error_msg( -// Plain strings - ($err:expr, ($msg:expr), [$dbg:expr]) => { - $crate::ErrorMessage::new(&$err, Some($msg), - Some($dbg), - file!(), $crate::glib::function_name!(), line!()) - }; - ($err:expr, ($msg:expr)) => { - $crate::ErrorMessage::new(&$err, Some($msg), - None, - file!(), $crate::glib::function_name!(), line!()) - }; - ($err:expr, [$dbg:expr]) => { - $crate::ErrorMessage::new(&$err, None, - Some($dbg), - file!(), $crate::glib::function_name!(), line!()) - }; - -// Format strings ($err:expr, ($($msg:tt)*), [$($dbg:tt)*]) => { { $crate::ErrorMessage::new(&$err, Some(format!($($msg)*).as_ref()), Some(format!($($dbg)*).as_ref()),