Revert "Add support for inline variable names in error/warning/info message creation macros"

This reverts commit 6bd559f5b5. It breaks
backwards compatibility as it makes it impossible to use a `&String` or
`&str` as debug message and only allows for string literals or format
strings plus arguments.
This commit is contained in:
Sebastian Dröge 2023-02-13 11:40:55 +02:00
parent 6bd559f5b5
commit 6cb469934d
4 changed files with 387 additions and 0 deletions

View file

@ -152,6 +152,42 @@ impl<O: IsA<AudioDecoder>> AudioDecoderExtManual for O {
#[macro_export] #[macro_export]
macro_rules! audio_decoder_error( 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)*]) => { { ($obj:expr, $weight:expr, $err:expr, ($($msg:tt)*), [$($debug:tt)*]) => { {
use $crate::prelude::AudioDecoderExtManual; use $crate::prelude::AudioDecoderExtManual;
$obj.error( $obj.error(

View file

@ -353,6 +353,42 @@ impl HasStreamLock for VideoDecoder {
#[macro_export] #[macro_export]
macro_rules! video_decoder_error( 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)*]) => { { ($obj:expr, $weight:expr, $err:expr, ($($msg:tt)*), [$($debug:tt)*]) => { {
use $crate::prelude::VideoDecoderExtManual; use $crate::prelude::VideoDecoderExtManual;
$obj.error( $obj.error(

View file

@ -1003,6 +1003,42 @@ pub static ELEMENT_METADATA_LONGNAME: &glib::GStr =
#[doc(alias = "GST_ELEMENT_ERROR_WITH_DETAILS")] #[doc(alias = "GST_ELEMENT_ERROR_WITH_DETAILS")]
#[macro_export] #[macro_export]
macro_rules! element_error( 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)*]) => { { ($obj:expr, $err:expr, ($($msg:tt)*), [$($debug:tt)*]) => { {
use $crate::prelude::ElementExtManual; use $crate::prelude::ElementExtManual;
$obj.message_full( $obj.message_full(
@ -1040,6 +1076,45 @@ 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) => { { ($obj:expr, $err:expr, ($($msg:tt)*), [$($debug:tt)*], details: $details:expr) => { {
use $crate::prelude::ElementExtManual; use $crate::prelude::ElementExtManual;
$obj.message_full_with_details( $obj.message_full_with_details(
@ -1085,6 +1160,42 @@ macro_rules! element_error(
#[doc(alias = "GST_ELEMENT_WARNING_WITH_DETAILS")] #[doc(alias = "GST_ELEMENT_WARNING_WITH_DETAILS")]
#[macro_export] #[macro_export]
macro_rules! element_warning( 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)*]) => { { ($obj:expr, $err:expr, ($($msg:tt)*), [$($debug:tt)*]) => { {
use $crate::prelude::ElementExtManual; use $crate::prelude::ElementExtManual;
$obj.message_full( $obj.message_full(
@ -1122,6 +1233,45 @@ 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) => { { ($obj:expr, $err:expr, ($($msg:tt)*), [$($debug:tt)*], details: $details:expr) => { {
use $crate::prelude::ElementExtManual; use $crate::prelude::ElementExtManual;
$obj.message_full_with_details( $obj.message_full_with_details(
@ -1167,6 +1317,42 @@ macro_rules! element_warning(
#[doc(alias = "GST_ELEMENT_INFO_WITH_DETAILS")] #[doc(alias = "GST_ELEMENT_INFO_WITH_DETAILS")]
#[macro_export] #[macro_export]
macro_rules! element_info( 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)*]) => { { ($obj:expr, $err:expr, ($($msg:tt)*), [$($debug:tt)*]) => { {
use $crate::prelude::ElementExtManual; use $crate::prelude::ElementExtManual;
$obj.message_full( $obj.message_full(
@ -1204,6 +1390,45 @@ 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) => { { ($obj:expr, $err:expr, ($($msg:tt)*), [$($debug:tt)*], details: $details:expr) => { {
use $crate::prelude::ElementExtManual; use $crate::prelude::ElementExtManual;
$obj.message_full_with_details( $obj.message_full_with_details(
@ -1249,6 +1474,18 @@ macro_rules! element_info(
#[doc(alias = "GST_ELEMENT_ERROR_WITH_DETAILS")] #[doc(alias = "GST_ELEMENT_ERROR_WITH_DETAILS")]
#[macro_export] #[macro_export]
macro_rules! element_imp_error( 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)*]) => { { ($imp:expr, $err:expr, ($($msg:tt)*), [$($debug:tt)*]) => { {
let obj = $imp.obj(); let obj = $imp.obj();
$crate::element_error!(obj, $err, ($($msg)*), [$($debug)*]); $crate::element_error!(obj, $err, ($($msg)*), [$($debug)*]);
@ -1262,6 +1499,18 @@ macro_rules! element_imp_error(
$crate::element_error!(obj, $err, [$($debug)*]); $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) => { { ($imp:expr, $err:expr, ($($msg:tt)*), [$($debug:tt)*], details: $details:expr) => { {
let obj = $imp.obj(); let obj = $imp.obj();
$crate::element_error!(obj, $err, ($($msg)*), [$($debug)*], details: $details); $crate::element_error!(obj, $err, ($($msg)*), [$($debug)*], details: $details);
@ -1280,6 +1529,18 @@ macro_rules! element_imp_error(
#[doc(alias = "GST_ELEMENT_WARNING_WITH_DETAILS")] #[doc(alias = "GST_ELEMENT_WARNING_WITH_DETAILS")]
#[macro_export] #[macro_export]
macro_rules! element_imp_warning( 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)*]) => { { ($imp:expr, $err:expr, ($($msg:tt)*), [$($debug:tt)*]) => { {
let obj = $imp.obj(); let obj = $imp.obj();
$crate::element_warning!(obj, $err, ($($msg)*), [$($debug)*]); $crate::element_warning!(obj, $err, ($($msg)*), [$($debug)*]);
@ -1293,6 +1554,18 @@ macro_rules! element_imp_warning(
$crate::element_warning!(obj, $err, [$($debug)*]); $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) => { { ($imp:expr, $err:expr, ($($msg:tt)*), [$($debug:tt)*], details: $details:expr) => { {
let obj = $imp.obj(); let obj = $imp.obj();
$crate::element_warning!(obj, $err, ($($msg)*), [$($debug)*], details: $details); $crate::element_warning!(obj, $err, ($($msg)*), [$($debug)*], details: $details);
@ -1311,6 +1584,18 @@ macro_rules! element_imp_warning(
#[doc(alias = "GST_ELEMENT_INFO_WITH_DETAILS")] #[doc(alias = "GST_ELEMENT_INFO_WITH_DETAILS")]
#[macro_export] #[macro_export]
macro_rules! element_imp_info( 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)*]) => { { ($imp:expr, $err:expr, ($($msg:tt)*), [$($debug:tt)*]) => { {
let obj = $imp.obj(); let obj = $imp.obj();
$crate::element_info!(obj, $err, ($($msg)*), [$($debug)*]); $crate::element_info!(obj, $err, ($($msg)*), [$($debug)*]);
@ -1324,6 +1609,18 @@ macro_rules! element_imp_info(
$crate::element_info!(obj, $err, [$($debug)*]); $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) => { { ($imp:expr, $err:expr, ($($msg:tt)*), [$($debug:tt)*], details: $details:expr) => { {
let obj = $imp.obj(); let obj = $imp.obj();
$crate::element_info!(obj, $err, ($($msg)*), [$($debug)*], details: $details); $crate::element_info!(obj, $err, ($($msg)*), [$($debug)*], details: $details);

View file

@ -5,6 +5,24 @@ use thiserror::Error;
#[macro_export] #[macro_export]
macro_rules! error_msg( 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)*]) => { { ($err:expr, ($($msg:tt)*), [$($dbg:tt)*]) => { {
$crate::ErrorMessage::new(&$err, Some(format!($($msg)*).as_ref()), $crate::ErrorMessage::new(&$err, Some(format!($($msg)*).as_ref()),
Some(format!($($dbg)*).as_ref()), Some(format!($($dbg)*).as_ref()),