mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-12-23 08:36:31 +00:00
gstreamer: Automatically generate Allocator::alloc
Parameter mutability has been fixed (and reverted, hence overridden with const=true)for this function in gstreamer; it can now be automatically generated.
This commit is contained in:
parent
6b94083a07
commit
89c7883202
4 changed files with 32 additions and 58 deletions
|
@ -64,6 +64,8 @@ manual = [
|
||||||
"GLib.Source",
|
"GLib.Source",
|
||||||
"GObject.Object",
|
"GObject.Object",
|
||||||
"GObject.Value",
|
"GObject.Value",
|
||||||
|
"Gst.AllocationParams",
|
||||||
|
"Gst.Memory",
|
||||||
"Gst.Segment",
|
"Gst.Segment",
|
||||||
"Gst.StaticCaps",
|
"Gst.StaticCaps",
|
||||||
"Gst.StaticPadTemplate",
|
"Gst.StaticPadTemplate",
|
||||||
|
@ -72,7 +74,14 @@ manual = [
|
||||||
[[object]]
|
[[object]]
|
||||||
name = "Gst.Allocator"
|
name = "Gst.Allocator"
|
||||||
status = "generate"
|
status = "generate"
|
||||||
manual_traits = ["AllocatorExtManual"]
|
|
||||||
|
[[object.function]]
|
||||||
|
name = "alloc"
|
||||||
|
[object.function.return]
|
||||||
|
nullable_return_is_error = "Failed to allocate memory"
|
||||||
|
[[object.function.parameter]]
|
||||||
|
name = "params"
|
||||||
|
const = true
|
||||||
|
|
||||||
[[object]]
|
[[object]]
|
||||||
name = "Gst.Bin"
|
name = "Gst.Bin"
|
||||||
|
|
|
@ -1,42 +0,0 @@
|
||||||
// Take a look at the license at the top of the repository in the LICENSE file.
|
|
||||||
|
|
||||||
use std::ptr;
|
|
||||||
|
|
||||||
use glib::translate::from_glib_full;
|
|
||||||
use glib::IsA;
|
|
||||||
|
|
||||||
use crate::AllocationParams;
|
|
||||||
use crate::Allocator;
|
|
||||||
use crate::Memory;
|
|
||||||
|
|
||||||
pub trait AllocatorExtManual: 'static {
|
|
||||||
fn alloc(
|
|
||||||
&self,
|
|
||||||
size: usize,
|
|
||||||
params: Option<&AllocationParams>,
|
|
||||||
) -> Result<Memory, glib::BoolError>;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<O: IsA<Allocator>> AllocatorExtManual for O {
|
|
||||||
fn alloc(
|
|
||||||
&self,
|
|
||||||
size: usize,
|
|
||||||
params: Option<&AllocationParams>,
|
|
||||||
) -> Result<Memory, glib::BoolError> {
|
|
||||||
unsafe {
|
|
||||||
let ret = ffi::gst_allocator_alloc(
|
|
||||||
self.as_ptr() as *mut _,
|
|
||||||
size,
|
|
||||||
match params {
|
|
||||||
Some(val) => val.as_ptr() as *mut _,
|
|
||||||
None => ptr::null_mut(),
|
|
||||||
},
|
|
||||||
);
|
|
||||||
if ret.is_null() {
|
|
||||||
Err(glib::bool_error!("Failed to allocate memory"))
|
|
||||||
} else {
|
|
||||||
Ok(from_glib_full(ret))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -2,6 +2,8 @@
|
||||||
// from gir-files (https://github.com/gtk-rs/gir-files)
|
// from gir-files (https://github.com/gtk-rs/gir-files)
|
||||||
// DO NOT EDIT
|
// DO NOT EDIT
|
||||||
|
|
||||||
|
use crate::AllocationParams;
|
||||||
|
use crate::Memory;
|
||||||
use crate::Object;
|
use crate::Object;
|
||||||
use glib::object::IsA;
|
use glib::object::IsA;
|
||||||
use glib::translate::*;
|
use glib::translate::*;
|
||||||
|
@ -36,24 +38,32 @@ unsafe impl Sync for Allocator {}
|
||||||
pub const NONE_ALLOCATOR: Option<&Allocator> = None;
|
pub const NONE_ALLOCATOR: Option<&Allocator> = None;
|
||||||
|
|
||||||
pub trait AllocatorExt: 'static {
|
pub trait AllocatorExt: 'static {
|
||||||
//#[doc(alias = "gst_allocator_alloc")]
|
#[doc(alias = "gst_allocator_alloc")]
|
||||||
//fn alloc(&self, size: usize, params: /*Ignored*/Option<&mut AllocationParams>) -> /*Ignored*/Option<Memory>;
|
fn alloc(
|
||||||
|
&self,
|
||||||
//#[doc(alias = "gst_allocator_free")]
|
size: usize,
|
||||||
//fn free(&self, memory: /*Ignored*/&mut Memory);
|
params: Option<&AllocationParams>,
|
||||||
|
) -> Result<Memory, glib::BoolError>;
|
||||||
|
|
||||||
#[doc(alias = "gst_allocator_set_default")]
|
#[doc(alias = "gst_allocator_set_default")]
|
||||||
fn set_default(&self);
|
fn set_default(&self);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<O: IsA<Allocator>> AllocatorExt for O {
|
impl<O: IsA<Allocator>> AllocatorExt for O {
|
||||||
//fn alloc(&self, size: usize, params: /*Ignored*/Option<&mut AllocationParams>) -> /*Ignored*/Option<Memory> {
|
fn alloc(
|
||||||
// unsafe { TODO: call ffi:gst_allocator_alloc() }
|
&self,
|
||||||
//}
|
size: usize,
|
||||||
|
params: Option<&AllocationParams>,
|
||||||
//fn free(&self, memory: /*Ignored*/&mut Memory) {
|
) -> Result<Memory, glib::BoolError> {
|
||||||
// unsafe { TODO: call ffi:gst_allocator_free() }
|
unsafe {
|
||||||
//}
|
Option::<_>::from_glib_full(ffi::gst_allocator_alloc(
|
||||||
|
self.as_ref().to_glib_none().0,
|
||||||
|
size,
|
||||||
|
mut_override(params.to_glib_none().0),
|
||||||
|
))
|
||||||
|
.ok_or_else(|| glib::bool_error!("Failed to allocate memory"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn set_default(&self) {
|
fn set_default(&self) {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|
|
@ -126,8 +126,6 @@ mod element;
|
||||||
|
|
||||||
mod bin;
|
mod bin;
|
||||||
|
|
||||||
mod allocator;
|
|
||||||
pub use crate::allocator::AllocatorExtManual;
|
|
||||||
mod pipeline;
|
mod pipeline;
|
||||||
pub use crate::pipeline::GstPipelineExtManual;
|
pub use crate::pipeline::GstPipelineExtManual;
|
||||||
|
|
||||||
|
@ -317,7 +315,6 @@ pub mod prelude {
|
||||||
|
|
||||||
pub use crate::meta::MetaAPI;
|
pub use crate::meta::MetaAPI;
|
||||||
|
|
||||||
pub use crate::allocator::AllocatorExtManual;
|
|
||||||
pub use crate::bin::GstBinExtManual;
|
pub use crate::bin::GstBinExtManual;
|
||||||
pub use crate::element::{ElementClassExt, ElementExtManual};
|
pub use crate::element::{ElementClassExt, ElementExtManual};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue