mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-29 21:11:14 +00:00
Allow passing normal strings to gst_plugin_define!() without explicit \0 at the end
See https://gitlab.freedesktop.org/gstreamer/gst-plugin-rs/issues/38
This commit is contained in:
parent
9ff906eb8e
commit
d2f00ca1e0
1 changed files with 19 additions and 26 deletions
|
@ -27,13 +27,6 @@ macro_rules! gst_plugin_define(
|
||||||
pub mod plugin_desc {
|
pub mod plugin_desc {
|
||||||
use $crate::glib::translate::{from_glib_borrow, ToGlib, from_glib};
|
use $crate::glib::translate::{from_glib_borrow, ToGlib, from_glib};
|
||||||
|
|
||||||
const MAJOR_VERSION: i32 = $crate::subclass::MAJOR_VERSION;
|
|
||||||
const MINOR_VERSION: i32 = $crate::subclass::MINOR_VERSION;
|
|
||||||
|
|
||||||
// Not using c_char here because it requires the libc crate
|
|
||||||
#[allow(non_camel_case_types)]
|
|
||||||
type c_char = i8;
|
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct GstPluginDesc($crate::ffi::GstPluginDesc);
|
pub struct GstPluginDesc($crate::ffi::GstPluginDesc);
|
||||||
unsafe impl Sync for GstPluginDesc {}
|
unsafe impl Sync for GstPluginDesc {}
|
||||||
|
@ -41,33 +34,33 @@ macro_rules! gst_plugin_define(
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
#[allow(non_upper_case_globals)]
|
#[allow(non_upper_case_globals)]
|
||||||
pub static gst_plugin_desc: GstPluginDesc = GstPluginDesc($crate::ffi::GstPluginDesc {
|
pub static gst_plugin_desc: GstPluginDesc = GstPluginDesc($crate::ffi::GstPluginDesc {
|
||||||
major_version: MAJOR_VERSION,
|
major_version: $crate::subclass::plugin::MAJOR_VERSION,
|
||||||
minor_version: MINOR_VERSION,
|
minor_version: $crate::subclass::plugin::MINOR_VERSION,
|
||||||
name: $name as *const u8 as *const c_char,
|
name: concat!($name, "\0") as *const str as *const _,
|
||||||
description: $description as *const u8 as *const c_char,
|
description: concat!($description, "\0") as *const str as *const _,
|
||||||
plugin_init: Some(plugin_init_trampoline),
|
plugin_init: Some(plugin_init_trampoline),
|
||||||
version: $version as *const u8 as *const c_char,
|
version: concat!($version, "\0") as *const str as *const _,
|
||||||
license: $license as *const u8 as *const c_char,
|
license: concat!($license, "\0") as *const str as *const _,
|
||||||
source: $source as *const u8 as *const c_char,
|
source: concat!($source, "\0") as *const str as *const _,
|
||||||
package: $package as *const u8 as *const c_char,
|
package: concat!($package, "\0") as *const str as *const _,
|
||||||
origin: $origin as *const u8 as *const c_char,
|
origin: concat!($origin, "\0") as *const str as *const _,
|
||||||
release_datetime: $release_datetime as *const u8 as *const c_char,
|
release_datetime: concat!($release_datetime, "\0") as *const str as *const _,
|
||||||
_gst_reserved: [0 as $crate::glib_ffi::gpointer; 4],
|
_gst_reserved: [0 as $crate::glib_ffi::gpointer; 4],
|
||||||
});
|
});
|
||||||
|
|
||||||
pub fn plugin_register_static() -> bool {
|
pub fn plugin_register_static() -> bool {
|
||||||
unsafe {
|
unsafe {
|
||||||
from_glib($crate::ffi::gst_plugin_register_static(
|
from_glib($crate::ffi::gst_plugin_register_static(
|
||||||
MAJOR_VERSION,
|
$crate::subclass::plugin::MAJOR_VERSION,
|
||||||
MINOR_VERSION,
|
$crate::subclass::plugin::MINOR_VERSION,
|
||||||
$name as *const u8 as *const c_char,
|
concat!($name, "\0") as *const str as *const _,
|
||||||
$description as *const u8 as *const c_char,
|
concat!($description, "\0") as *const str as _,
|
||||||
Some(plugin_init_trampoline),
|
Some(plugin_init_trampoline),
|
||||||
$version as *const u8 as *const c_char,
|
concat!($version, "\0") as *const str as *const _,
|
||||||
$license as *const u8 as *const c_char,
|
concat!($license, "\0") as *const str as *const _,
|
||||||
$source as *const u8 as *const c_char,
|
concat!($source, "\0") as *const str as *const _,
|
||||||
$package as *const u8 as *const c_char,
|
concat!($package, "\0") as *const str as *const _,
|
||||||
$origin as *const u8 as *const c_char,
|
concat!($origin, "\0") as *const str as *const _,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue