mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-22 09:31:06 +00:00
gstreamer: Mark ParamSpec
constructors as deprecated in favour of the builders
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1196>
This commit is contained in:
parent
24a16a43b6
commit
257a049673
1 changed files with 51 additions and 21 deletions
|
@ -42,6 +42,7 @@ impl ParamSpecFraction {
|
||||||
ParamSpecFractionBuilder::new(name)
|
ParamSpecFractionBuilder::new(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[deprecated = "Use builder() instead"]
|
||||||
#[allow(clippy::new_ret_no_self)]
|
#[allow(clippy::new_ret_no_self)]
|
||||||
#[doc(alias = "gst_param_spec_fraction")]
|
#[doc(alias = "gst_param_spec_fraction")]
|
||||||
pub fn new<'a>(
|
pub fn new<'a>(
|
||||||
|
@ -54,6 +55,18 @@ impl ParamSpecFraction {
|
||||||
flags: glib::ParamFlags,
|
flags: glib::ParamFlags,
|
||||||
) -> glib::ParamSpec {
|
) -> glib::ParamSpec {
|
||||||
assert_initialized_main_thread!();
|
assert_initialized_main_thread!();
|
||||||
|
unsafe { Self::new_unchecked(name, nick, blurb, min, max, default, flags) }
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe fn new_unchecked<'a>(
|
||||||
|
name: &str,
|
||||||
|
nick: impl Into<Option<&'a str>>,
|
||||||
|
blurb: impl Into<Option<&'a str>>,
|
||||||
|
min: crate::Fraction,
|
||||||
|
max: crate::Fraction,
|
||||||
|
default: crate::Fraction,
|
||||||
|
flags: glib::ParamFlags,
|
||||||
|
) -> glib::ParamSpec {
|
||||||
unsafe {
|
unsafe {
|
||||||
from_glib_none(ffi::gst_param_spec_fraction(
|
from_glib_none(ffi::gst_param_spec_fraction(
|
||||||
name.to_glib_none().0,
|
name.to_glib_none().0,
|
||||||
|
@ -127,7 +140,7 @@ pub struct ParamSpecFractionBuilder<'a> {
|
||||||
|
|
||||||
impl<'a> ParamSpecFractionBuilder<'a> {
|
impl<'a> ParamSpecFractionBuilder<'a> {
|
||||||
fn new(name: &'a str) -> Self {
|
fn new(name: &'a str) -> Self {
|
||||||
skip_assert_initialized!();
|
assert_initialized_main_thread!();
|
||||||
Self {
|
Self {
|
||||||
name,
|
name,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
|
@ -157,18 +170,20 @@ impl<'a> ParamSpecFractionBuilder<'a> {
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn build(self) -> ParamSpec {
|
pub fn build(self) -> ParamSpec {
|
||||||
ParamSpecFraction::new(
|
unsafe {
|
||||||
self.name,
|
ParamSpecFraction::new_unchecked(
|
||||||
self.nick.unwrap_or(self.name),
|
self.name,
|
||||||
self.blurb.unwrap_or(self.name),
|
self.nick.unwrap_or(self.name),
|
||||||
self.minimum
|
self.blurb.unwrap_or(self.name),
|
||||||
.unwrap_or_else(|| crate::Fraction::new(-i32::MAX, 1)),
|
self.minimum
|
||||||
self.maximum
|
.unwrap_or_else(|| crate::Fraction::new(-i32::MAX, 1)),
|
||||||
.unwrap_or_else(|| crate::Fraction::new(i32::MAX, 1)),
|
self.maximum
|
||||||
self.default_value
|
.unwrap_or_else(|| crate::Fraction::new(i32::MAX, 1)),
|
||||||
.unwrap_or_else(|| crate::Fraction::new(0, 1)),
|
self.default_value
|
||||||
self.flags,
|
.unwrap_or_else(|| crate::Fraction::new(0, 1)),
|
||||||
)
|
self.flags,
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,6 +244,7 @@ impl ParamSpecArray {
|
||||||
|
|
||||||
#[allow(clippy::new_ret_no_self)]
|
#[allow(clippy::new_ret_no_self)]
|
||||||
#[doc(alias = "gst_param_spec_array")]
|
#[doc(alias = "gst_param_spec_array")]
|
||||||
|
#[deprecated = "Use builder() instead"]
|
||||||
pub fn new<'a>(
|
pub fn new<'a>(
|
||||||
name: &str,
|
name: &str,
|
||||||
nick: impl Into<Option<&'a str>>,
|
nick: impl Into<Option<&'a str>>,
|
||||||
|
@ -237,6 +253,17 @@ impl ParamSpecArray {
|
||||||
flags: glib::ParamFlags,
|
flags: glib::ParamFlags,
|
||||||
) -> glib::ParamSpec {
|
) -> glib::ParamSpec {
|
||||||
assert_initialized_main_thread!();
|
assert_initialized_main_thread!();
|
||||||
|
|
||||||
|
unsafe { Self::new_unchecked(name, nick, blurb, element_spec, flags) }
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe fn new_unchecked<'a>(
|
||||||
|
name: &str,
|
||||||
|
nick: impl Into<Option<&'a str>>,
|
||||||
|
blurb: impl Into<Option<&'a str>>,
|
||||||
|
element_spec: Option<&glib::ParamSpec>,
|
||||||
|
flags: glib::ParamFlags,
|
||||||
|
) -> glib::ParamSpec {
|
||||||
unsafe {
|
unsafe {
|
||||||
from_glib_none(ffi::gst_param_spec_array(
|
from_glib_none(ffi::gst_param_spec_array(
|
||||||
name.to_glib_none().0,
|
name.to_glib_none().0,
|
||||||
|
@ -292,7 +319,7 @@ pub struct ParamSpecArrayBuilder<'a> {
|
||||||
|
|
||||||
impl<'a> ParamSpecArrayBuilder<'a> {
|
impl<'a> ParamSpecArrayBuilder<'a> {
|
||||||
fn new(name: &'a str) -> Self {
|
fn new(name: &'a str) -> Self {
|
||||||
skip_assert_initialized!();
|
assert_initialized_main_thread!();
|
||||||
Self {
|
Self {
|
||||||
name,
|
name,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
|
@ -308,13 +335,15 @@ impl<'a> ParamSpecArrayBuilder<'a> {
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn build(self) -> ParamSpec {
|
pub fn build(self) -> ParamSpec {
|
||||||
ParamSpecArray::new(
|
unsafe {
|
||||||
self.name,
|
ParamSpecArray::new_unchecked(
|
||||||
self.nick.unwrap_or(self.name),
|
self.name,
|
||||||
self.blurb.unwrap_or(self.name),
|
self.nick.unwrap_or(self.name),
|
||||||
self.element_spec,
|
self.blurb.unwrap_or(self.name),
|
||||||
self.flags,
|
self.element_spec,
|
||||||
)
|
self.flags,
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -388,6 +417,7 @@ mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[allow(deprecated)]
|
||||||
fn test_trait() {
|
fn test_trait() {
|
||||||
crate::init().unwrap();
|
crate::init().unwrap();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue