Commit be0f64ce authored by Sebastian Dröge's avatar Sebastian Dröge 🍵

Run everything through rustfmt

parent 77a9f4b4
......@@ -6,8 +6,8 @@ extern crate pkg_config;
use pkg_config::{Config, Error};
use std::env;
use std::io::prelude::*;
use std::io;
use std::io::prelude::*;
use std::process;
fn main() {
......@@ -48,7 +48,7 @@ fn find() -> Result<(), Error> {
println!("cargo:rustc-link-lib=dylib={}", lib_);
}
println!("cargo:rustc-link-search=native={}", lib_dir);
return Ok(())
return Ok(());
}
let target = env::var("TARGET").expect("TARGET environment variable doesn't exist");
......@@ -70,8 +70,10 @@ fn find() -> Result<(), Error> {
println!("cargo:rustc-link-lib=dylib={}", lib_);
}
for path in library.link_paths.iter() {
println!("cargo:rustc-link-search=native={}",
path.to_str().expect("library path doesn't exist"));
println!(
"cargo:rustc-link-search=native={}",
path.to_str().expect("library path doesn't exist")
);
}
}
Ok(())
......@@ -85,4 +87,3 @@ fn find() -> Result<(), Error> {
Err(err) => Err(err),
}
}
......@@ -3,17 +3,22 @@
// DO NOT EDIT
#![allow(non_camel_case_types, non_upper_case_globals, non_snake_case)]
#![allow(clippy::approx_constant, clippy::type_complexity, clippy::unreadable_literal)]
#![allow(
clippy::approx_constant,
clippy::type_complexity,
clippy::unreadable_literal
)]
extern crate libc;
extern crate glib_sys as glib;
extern crate gstreamer_sys as gst;
extern crate gstreamer_base_sys as gst_base;
extern crate gstreamer_sys as gst;
extern crate libc;
#[allow(unused_imports)]
use libc::{c_int, c_char, c_uchar, c_float, c_uint, c_double,
c_short, c_ushort, c_long, c_ulong,
c_void, size_t, ssize_t, intptr_t, uintptr_t, time_t, FILE};
use libc::{
c_char, c_double, c_float, c_int, c_long, c_short, c_uchar, c_uint, c_ulong, c_ushort, c_void,
intptr_t, size_t, ssize_t, time_t, uintptr_t, FILE,
};
#[allow(unused_imports)]
use glib::{gboolean, gconstpointer, gpointer, GType};
......@@ -37,10 +42,10 @@ pub struct GstAppSinkCallbacks {
impl ::std::fmt::Debug for GstAppSinkCallbacks {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("GstAppSinkCallbacks @ {:?}", self as *const _))
.field("eos", &self.eos)
.field("new_preroll", &self.new_preroll)
.field("new_sample", &self.new_sample)
.finish()
.field("eos", &self.eos)
.field("new_preroll", &self.new_preroll)
.field("new_sample", &self.new_sample)
.finish()
}
}
......@@ -53,23 +58,25 @@ pub struct GstAppSinkClass {
pub new_sample: Option<unsafe extern "C" fn(*mut GstAppSink) -> gst::GstFlowReturn>,
pub pull_preroll: Option<unsafe extern "C" fn(*mut GstAppSink) -> *mut gst::GstSample>,
pub pull_sample: Option<unsafe extern "C" fn(*mut GstAppSink) -> *mut gst::GstSample>,
pub try_pull_preroll: Option<unsafe extern "C" fn(*mut GstAppSink, gst::GstClockTime) -> *mut gst::GstSample>,
pub try_pull_sample: Option<unsafe extern "C" fn(*mut GstAppSink, gst::GstClockTime) -> *mut gst::GstSample>,
pub try_pull_preroll:
Option<unsafe extern "C" fn(*mut GstAppSink, gst::GstClockTime) -> *mut gst::GstSample>,
pub try_pull_sample:
Option<unsafe extern "C" fn(*mut GstAppSink, gst::GstClockTime) -> *mut gst::GstSample>,
pub _gst_reserved: [gpointer; 2],
}
impl ::std::fmt::Debug for GstAppSinkClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("GstAppSinkClass @ {:?}", self as *const _))
.field("basesink_class", &self.basesink_class)
.field("eos", &self.eos)
.field("new_preroll", &self.new_preroll)
.field("new_sample", &self.new_sample)
.field("pull_preroll", &self.pull_preroll)
.field("pull_sample", &self.pull_sample)
.field("try_pull_preroll", &self.try_pull_preroll)
.field("try_pull_sample", &self.try_pull_sample)
.finish()
.field("basesink_class", &self.basesink_class)
.field("eos", &self.eos)
.field("new_preroll", &self.new_preroll)
.field("new_sample", &self.new_sample)
.field("pull_preroll", &self.pull_preroll)
.field("pull_sample", &self.pull_sample)
.field("try_pull_preroll", &self.try_pull_preroll)
.field("try_pull_sample", &self.try_pull_sample)
.finish()
}
}
......@@ -90,10 +97,10 @@ pub struct GstAppSrcCallbacks {
impl ::std::fmt::Debug for GstAppSrcCallbacks {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("GstAppSrcCallbacks @ {:?}", self as *const _))
.field("need_data", &self.need_data)
.field("enough_data", &self.enough_data)
.field("seek_data", &self.seek_data)
.finish()
.field("need_data", &self.need_data)
.field("enough_data", &self.enough_data)
.field("seek_data", &self.seek_data)
.finish()
}
}
......@@ -104,25 +111,28 @@ pub struct GstAppSrcClass {
pub need_data: Option<unsafe extern "C" fn(*mut GstAppSrc, c_uint)>,
pub enough_data: Option<unsafe extern "C" fn(*mut GstAppSrc)>,
pub seek_data: Option<unsafe extern "C" fn(*mut GstAppSrc, u64) -> gboolean>,
pub push_buffer: Option<unsafe extern "C" fn(*mut GstAppSrc, *mut gst::GstBuffer) -> gst::GstFlowReturn>,
pub push_buffer:
Option<unsafe extern "C" fn(*mut GstAppSrc, *mut gst::GstBuffer) -> gst::GstFlowReturn>,
pub end_of_stream: Option<unsafe extern "C" fn(*mut GstAppSrc) -> gst::GstFlowReturn>,
pub push_sample: Option<unsafe extern "C" fn(*mut GstAppSrc, *mut gst::GstSample) -> gst::GstFlowReturn>,
pub push_buffer_list: Option<unsafe extern "C" fn(*mut GstAppSrc, *mut gst::GstBufferList) -> gst::GstFlowReturn>,
pub push_sample:
Option<unsafe extern "C" fn(*mut GstAppSrc, *mut gst::GstSample) -> gst::GstFlowReturn>,
pub push_buffer_list:
Option<unsafe extern "C" fn(*mut GstAppSrc, *mut gst::GstBufferList) -> gst::GstFlowReturn>,
pub _gst_reserved: [gpointer; 2],
}
impl ::std::fmt::Debug for GstAppSrcClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("GstAppSrcClass @ {:?}", self as *const _))
.field("basesrc_class", &self.basesrc_class)
.field("need_data", &self.need_data)
.field("enough_data", &self.enough_data)
.field("seek_data", &self.seek_data)
.field("push_buffer", &self.push_buffer)
.field("end_of_stream", &self.end_of_stream)
.field("push_sample", &self.push_sample)
.field("push_buffer_list", &self.push_buffer_list)
.finish()
.field("basesrc_class", &self.basesrc_class)
.field("need_data", &self.need_data)
.field("enough_data", &self.enough_data)
.field("seek_data", &self.seek_data)
.field("push_buffer", &self.push_buffer)
.field("end_of_stream", &self.end_of_stream)
.field("push_sample", &self.push_sample)
.field("push_buffer_list", &self.push_buffer_list)
.finish()
}
}
......@@ -143,8 +153,8 @@ pub struct GstAppSink {
impl ::std::fmt::Debug for GstAppSink {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("GstAppSink @ {:?}", self as *const _))
.field("basesink", &self.basesink)
.finish()
.field("basesink", &self.basesink)
.finish()
}
}
......@@ -159,8 +169,8 @@ pub struct GstAppSrc {
impl ::std::fmt::Debug for GstAppSrc {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("GstAppSrc @ {:?}", self as *const _))
.field("basesrc", &self.basesrc)
.finish()
.field("basesrc", &self.basesrc)
.finish()
}
}
......@@ -187,16 +197,27 @@ extern "C" {
pub fn gst_app_sink_pull_sample(appsink: *mut GstAppSink) -> *mut gst::GstSample;
#[cfg(any(feature = "v1_12", feature = "dox"))]
pub fn gst_app_sink_set_buffer_list_support(appsink: *mut GstAppSink, enable_lists: gboolean);
pub fn gst_app_sink_set_callbacks(appsink: *mut GstAppSink, callbacks: *mut GstAppSinkCallbacks, user_data: gpointer, notify: glib::GDestroyNotify);
pub fn gst_app_sink_set_callbacks(
appsink: *mut GstAppSink,
callbacks: *mut GstAppSinkCallbacks,
user_data: gpointer,
notify: glib::GDestroyNotify,
);
pub fn gst_app_sink_set_caps(appsink: *mut GstAppSink, caps: *const gst::GstCaps);
pub fn gst_app_sink_set_drop(appsink: *mut GstAppSink, drop: gboolean);
pub fn gst_app_sink_set_emit_signals(appsink: *mut GstAppSink, emit: gboolean);
pub fn gst_app_sink_set_max_buffers(appsink: *mut GstAppSink, max: c_uint);
pub fn gst_app_sink_set_wait_on_eos(appsink: *mut GstAppSink, wait: gboolean);
#[cfg(any(feature = "v1_10", feature = "dox"))]
pub fn gst_app_sink_try_pull_preroll(appsink: *mut GstAppSink, timeout: gst::GstClockTime) -> *mut gst::GstSample;
pub fn gst_app_sink_try_pull_preroll(
appsink: *mut GstAppSink,
timeout: gst::GstClockTime,
) -> *mut gst::GstSample;
#[cfg(any(feature = "v1_10", feature = "dox"))]
pub fn gst_app_sink_try_pull_sample(appsink: *mut GstAppSink, timeout: gst::GstClockTime) -> *mut gst::GstSample;
pub fn gst_app_sink_try_pull_sample(
appsink: *mut GstAppSink,
timeout: gst::GstClockTime,
) -> *mut gst::GstSample;
//=========================================================================
// GstAppSrc
......@@ -213,12 +234,26 @@ extern "C" {
pub fn gst_app_src_get_max_bytes(appsrc: *mut GstAppSrc) -> u64;
pub fn gst_app_src_get_size(appsrc: *mut GstAppSrc) -> i64;
pub fn gst_app_src_get_stream_type(appsrc: *mut GstAppSrc) -> GstAppStreamType;
pub fn gst_app_src_push_buffer(appsrc: *mut GstAppSrc, buffer: *mut gst::GstBuffer) -> gst::GstFlowReturn;
pub fn gst_app_src_push_buffer(
appsrc: *mut GstAppSrc,
buffer: *mut gst::GstBuffer,
) -> gst::GstFlowReturn;
#[cfg(any(feature = "v1_14", feature = "dox"))]
pub fn gst_app_src_push_buffer_list(appsrc: *mut GstAppSrc, buffer_list: *mut gst::GstBufferList) -> gst::GstFlowReturn;
pub fn gst_app_src_push_buffer_list(
appsrc: *mut GstAppSrc,
buffer_list: *mut gst::GstBufferList,
) -> gst::GstFlowReturn;
#[cfg(any(feature = "v1_6", feature = "dox"))]
pub fn gst_app_src_push_sample(appsrc: *mut GstAppSrc, sample: *mut gst::GstSample) -> gst::GstFlowReturn;
pub fn gst_app_src_set_callbacks(appsrc: *mut GstAppSrc, callbacks: *mut GstAppSrcCallbacks, user_data: gpointer, notify: glib::GDestroyNotify);
pub fn gst_app_src_push_sample(
appsrc: *mut GstAppSrc,
sample: *mut gst::GstSample,
) -> gst::GstFlowReturn;
pub fn gst_app_src_set_callbacks(
appsrc: *mut GstAppSrc,
callbacks: *mut GstAppSrcCallbacks,
user_data: gpointer,
notify: glib::GDestroyNotify,
);
pub fn gst_app_src_set_caps(appsrc: *mut GstAppSrc, caps: *const gst::GstCaps);
#[cfg(any(feature = "v1_10", feature = "dox"))]
pub fn gst_app_src_set_duration(appsrc: *mut GstAppSrc, duration: gst::GstClockTime);
......
......@@ -5,13 +5,13 @@
extern crate gstreamer_app_sys;
extern crate shell_words;
extern crate tempdir;
use gstreamer_app_sys::*;
use std::env;
use std::error::Error;
use std::path::Path;
use std::mem::{align_of, size_of};
use std::path::Path;
use std::process::Command;
use std::str;
use gstreamer_app_sys::*;
static PACKAGES: &[&str] = &["gstreamer-app-1.0"];
......@@ -47,8 +47,7 @@ impl Compiler {
cmd.arg(out);
let status = cmd.spawn()?.wait()?;
if !status.success() {
return Err(format!("compilation command {:?} failed, {}",
&cmd, status).into());
return Err(format!("compilation command {:?} failed, {}", &cmd, status).into());
}
Ok(())
}
......@@ -77,14 +76,12 @@ fn pkg_config_cflags(packages: &[&str]) -> Result<Vec<String>, Box<Error>> {
cmd.args(packages);
let out = cmd.output()?;
if !out.status.success() {
return Err(format!("command {:?} returned {}",
&cmd, out.status).into());
return Err(format!("command {:?} returned {}", &cmd, out.status).into());
}
let stdout = str::from_utf8(&out.stdout)?;
Ok(shell_words::split(stdout.trim())?)
}
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
struct Layout {
size: usize,
......@@ -115,9 +112,8 @@ impl Results {
fn summary(&self) -> String {
format!(
"{} passed; {} failed (compilation errors: {})",
self.passed,
self.failed,
self.failed_to_compile)
self.passed, self.failed, self.failed_to_compile
)
}
fn expect_total_success(&self) {
if self.failed == 0 {
......@@ -133,24 +129,28 @@ fn cross_validate_constants_with_c() {
let tmpdir = tempdir::TempDir::new("abi").expect("temporary directory");
let cc = Compiler::new().expect("configured compiler");
assert_eq!("1",
get_c_value(tmpdir.path(), &cc, "1").expect("C constant"),
"failed to obtain correct constant value for 1");
assert_eq!(
"1",
get_c_value(tmpdir.path(), &cc, "1").expect("C constant"),
"failed to obtain correct constant value for 1"
);
let mut results : Results = Default::default();
let mut results: Results = Default::default();
for (i, &(name, rust_value)) in RUST_CONSTANTS.iter().enumerate() {
match get_c_value(tmpdir.path(), &cc, name) {
Err(e) => {
results.record_failed_to_compile();
eprintln!("{}", e);
},
}
Ok(ref c_value) => {
if rust_value == c_value {
results.record_passed();
} else {
results.record_failed();
eprintln!("Constant value mismatch for {}\nRust: {:?}\nC: {:?}",
name, rust_value, c_value);
eprintln!(
"Constant value mismatch for {}\nRust: {:?}\nC: {:?}",
name, rust_value, c_value
);
}
}
};
......@@ -166,24 +166,31 @@ fn cross_validate_layout_with_c() {
let tmpdir = tempdir::TempDir::new("abi").expect("temporary directory");
let cc = Compiler::new().expect("configured compiler");
assert_eq!(Layout {size: 1, alignment: 1},
get_c_layout(tmpdir.path(), &cc, "char").expect("C layout"),
"failed to obtain correct layout for char type");
assert_eq!(
Layout {
size: 1,
alignment: 1
},
get_c_layout(tmpdir.path(), &cc, "char").expect("C layout"),
"failed to obtain correct layout for char type"
);
let mut results : Results = Default::default();
let mut results: Results = Default::default();
for (i, &(name, rust_layout)) in RUST_LAYOUTS.iter().enumerate() {
match get_c_layout(tmpdir.path(), &cc, name) {
Err(e) => {
results.record_failed_to_compile();
eprintln!("{}", e);
},
}
Ok(c_layout) => {
if rust_layout == c_layout {
results.record_passed();
} else {
results.record_failed();
eprintln!("Layout mismatch for {}\nRust: {:?}\nC: {:?}",
name, rust_layout, &c_layout);
eprintln!(
"Layout mismatch for {}\nRust: {:?}\nC: {:?}",
name, rust_layout, &c_layout
);
}
}
};
......@@ -203,15 +210,14 @@ fn get_c_layout(dir: &Path, cc: &Compiler, name: &str) -> Result<Layout, Box<Err
let mut abi_cmd = Command::new(exe);
let output = abi_cmd.output()?;
if !output.status.success() {
return Err(format!("command {:?} failed, {:?}",
&abi_cmd, &output).into());
return Err(format!("command {:?} failed, {:?}", &abi_cmd, &output).into());
}
let stdout = str::from_utf8(&output.stdout)?;
let mut words = stdout.trim().split_whitespace();
let size = words.next().unwrap().parse().unwrap();
let alignment = words.next().unwrap().parse().unwrap();
Ok(Layout {size, alignment})
Ok(Layout { size, alignment })
}
fn get_c_value(dir: &Path, cc: &Compiler, name: &str) -> Result<String, Box<Error>> {
......@@ -223,28 +229,71 @@ fn get_c_value(dir: &Path, cc: &Compiler, name: &str) -> Result<String, Box<Erro
let mut abi_cmd = Command::new(exe);
let output = abi_cmd.output()?;
if !output.status.success() {
return Err(format!("command {:?} failed, {:?}",
&abi_cmd, &output).into());
return Err(format!("command {:?} failed, {:?}", &abi_cmd, &output).into());
}
let output = str::from_utf8(&output.stdout)?.trim();
if !output.starts_with("###gir test###") ||
!output.ends_with("###gir test###") {
return Err(format!("command {:?} return invalid output, {:?}",
&abi_cmd, &output).into());
if !output.starts_with("###gir test###") || !output.ends_with("###gir test###") {
return Err(format!(
"command {:?} return invalid output, {:?}",
&abi_cmd, &output
)
.into());
}
Ok(String::from(&output[14..(output.len() - 14)]))
}
const RUST_LAYOUTS: &[(&str, Layout)] = &[
("GstAppSink", Layout {size: size_of::<GstAppSink>(), alignment: align_of::<GstAppSink>()}),
("GstAppSinkCallbacks", Layout {size: size_of::<GstAppSinkCallbacks>(), alignment: align_of::<GstAppSinkCallbacks>()}),
("GstAppSinkClass", Layout {size: size_of::<GstAppSinkClass>(), alignment: align_of::<GstAppSinkClass>()}),
("GstAppSrc", Layout {size: size_of::<GstAppSrc>(), alignment: align_of::<GstAppSrc>()}),
("GstAppSrcCallbacks", Layout {size: size_of::<GstAppSrcCallbacks>(), alignment: align_of::<GstAppSrcCallbacks>()}),
("GstAppSrcClass", Layout {size: size_of::<GstAppSrcClass>(), alignment: align_of::<GstAppSrcClass>()}),
("GstAppStreamType", Layout {size: size_of::<GstAppStreamType>(), alignment: align_of::<GstAppStreamType>()}),
(
"GstAppSink",
Layout {
size: size_of::<GstAppSink>(),
alignment: align_of::<GstAppSink>(),
},
),
(
"GstAppSinkCallbacks",
Layout {
size: size_of::<GstAppSinkCallbacks>(),
alignment: align_of::<GstAppSinkCallbacks>(),
},
),
(
"GstAppSinkClass",
Layout {
size: size_of::<GstAppSinkClass>(),
alignment: align_of::<GstAppSinkClass>(),
},
),
(
"GstAppSrc",
Layout {
size: size_of::<GstAppSrc>(),
alignment: align_of::<GstAppSrc>(),
},
),
(
"GstAppSrcCallbacks",
Layout {
size: size_of::<GstAppSrcCallbacks>(),
alignment: align_of::<GstAppSrcCallbacks>(),
},
),
(
"GstAppSrcClass",
Layout {
size: size_of::<GstAppSrcClass>(),
alignment: align_of::<GstAppSrcClass>(),
},
),
(
"GstAppStreamType",
Layout {
size: size_of::<GstAppStreamType>(),
alignment: align_of::<GstAppStreamType>(),
},
),
];
const RUST_CONSTANTS: &[(&str, &str)] = &[
......@@ -252,5 +301,3 @@ const RUST_CONSTANTS: &[(&str, &str)] = &[
("(gint) GST_APP_STREAM_TYPE_SEEKABLE", "1"),
("(gint) GST_APP_STREAM_TYPE_STREAM", "0"),
];
......@@ -6,8 +6,8 @@ extern crate pkg_config;
use pkg_config::{Config, Error};
use std::env;
use std::io::prelude::*;
use std::io;
use std::io::prelude::*;
use std::process;
fn main() {
......@@ -48,7 +48,7 @@ fn find() -> Result<(), Error> {
println!("cargo:rustc-link-lib=dylib={}", lib_);
}
println!("cargo:rustc-link-search=native={}", lib_dir);
return Ok(())
return Ok(());
}
let target = env::var("TARGET").expect("TARGET environment variable doesn't exist");
......@@ -70,8 +70,10 @@ fn find() -> Result<(), Error> {
println!("cargo:rustc-link-lib=dylib={}", lib_);
}
for path in library.link_paths.iter() {
println!("cargo:rustc-link-search=native={}",
path.to_str().expect("library path doesn't exist"));
println!(
"cargo:rustc-link-search=native={}",
path.to_str().expect("library path doesn't exist")
);
}
}
Ok(())
......@@ -85,4 +87,3 @@ fn find() -> Result<(), Error> {
Err(err) => Err(err),
}
}
This diff is collapsed.
This diff is collapsed.
......@@ -6,8 +6,8 @@ extern crate pkg_config;
use pkg_config::{Config, Error};
use std::env;
use std::io::prelude::*;
use std::io;
use std::io::prelude::*;
use std::process;
fn main() {
......@@ -56,7 +56,7 @@ fn find() -> Result<(), Error> {
println!("cargo:rustc-link-lib=dylib={}", lib_);
}
println!("cargo:rustc-link-search=native={}", lib_dir);
return Ok(())
return Ok(());
}
let target = env::var("TARGET").expect("TARGET environment variable doesn't exist");
......@@ -78,8 +78,10 @@ fn find() -> Result<(), Error> {
println!("cargo:rustc-link-lib=dylib={}", lib_);
}
for path in library.link_paths.iter() {
println!("cargo:rustc-link-search=native={}",
path.to_str().expect("library path doesn't exist"));
println!(
"cargo:rustc-link-search=native={}",
path.to_str().expect("library path doesn't exist")
);
}
}
Ok(())
......@@ -93,4 +95,3 @@ fn find() -> Result<(), Error> {
Err(err) => Err(err),
}
}
This diff is collapsed.
......@@ -5,13 +5,13 @@
extern crate gstreamer_base_sys;
extern crate shell_words;
extern crate tempdir;
use gstreamer_base_sys::*;
use std::env;
use std::error::Error;
use std::path::Path;
use std::mem::{align_of, size_of};
use std::path::Path;
use std::process::Command;
use std::str;
use gstreamer_base_sys::*;
static PACKAGES: &[&str] = &["gstreamer-base-1.0"];
......@@ -47,8 +47,7 @@ impl Compiler {
cmd.arg(out);
let status = cmd.spawn()?.wait()?;