Skip to content

Commit ed8dc6a

Browse files
committed
make generics work in boxed_inline wrapper macro
1 parent c1d6dcd commit ed8dc6a

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

glib/src/boxed_inline.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ macro_rules! glib_boxed_inline_wrapper {
180180
}
181181

182182
#[doc(hidden)]
183-
impl<'a $(, $($generic $(: $bound $(+ $bound2)*)?),+)?> $crate::translate::ToGlibPtr<'a, *const $ffi_name> for $name $(<$($generic),+>)? {
183+
impl<'a $(, $($generic: 'a + $($bound $(+ $bound2)*)?),+)?> $crate::translate::ToGlibPtr<'a, *const $ffi_name> for $name $(<$($generic),+>)? {
184184
type Storage = &'a Self;
185185

186186
#[inline]
@@ -198,7 +198,7 @@ macro_rules! glib_boxed_inline_wrapper {
198198
}
199199

200200
#[doc(hidden)]
201-
impl<'a $(, $($generic $(: $bound $(+ $bound2)*)?),+)?> $crate::translate::ToGlibPtrMut<'a, *mut $ffi_name> for $name $(<$($generic),+>)? {
201+
impl<'a $(, $($generic: 'a + $($bound $(+ $bound2)*)?),+)?> $crate::translate::ToGlibPtrMut<'a, *mut $ffi_name> for $name $(<$($generic),+>)? {
202202
type Storage = &'a mut Self;
203203

204204
#[inline]
@@ -209,7 +209,7 @@ macro_rules! glib_boxed_inline_wrapper {
209209
}
210210

211211
#[doc(hidden)]
212-
impl<'a $(, $($generic $(: $bound $(+ $bound2)*)?),+)?> $crate::translate::ToGlibContainerFromSlice<'a, *mut *const $ffi_name> for $name $(<$($generic),+>)? {
212+
impl<'a $(, $($generic: 'a + $($bound $(+ $bound2)*)?),+)?> $crate::translate::ToGlibContainerFromSlice<'a, *mut *const $ffi_name> for $name $(<$($generic),+>)? {
213213
type Storage = Option<Vec<*const $ffi_name>>;
214214

215215
fn to_glib_none_from_slice(t: &'a [Self]) -> (*mut *const $ffi_name, Self::Storage) {
@@ -247,7 +247,7 @@ macro_rules! glib_boxed_inline_wrapper {
247247
}
248248

249249
#[doc(hidden)]
250-
impl<'a $(, $($generic $(: $bound $(+ $bound2)*)?),+)?> $crate::translate::ToGlibContainerFromSlice<'a, *const *const $ffi_name> for $name $(<$($generic),+>)? {
250+
impl<'a $(, $($generic: 'a + $($bound $(+ $bound2)*)?),+)?> $crate::translate::ToGlibContainerFromSlice<'a, *const *const $ffi_name> for $name $(<$($generic),+>)? {
251251
type Storage = Option<Vec<*const $ffi_name>>;
252252

253253
fn to_glib_none_from_slice(t: &'a [Self]) -> (*const *const $ffi_name, Self::Storage) {
@@ -267,7 +267,7 @@ macro_rules! glib_boxed_inline_wrapper {
267267
}
268268

269269
#[doc(hidden)]
270-
impl<'a $(, $($generic $(: $bound $(+ $bound2)*)?),+)?> $crate::translate::ToGlibContainerFromSlice<'a, *mut $ffi_name> for $name $(<$($generic),+>)? {
270+
impl<'a $(, $($generic: 'a + $($bound $(+ $bound2)*)?),+)?> $crate::translate::ToGlibContainerFromSlice<'a, *mut $ffi_name> for $name $(<$($generic),+>)? {
271271
type Storage = Option<&'a [Self]>;
272272

273273
fn to_glib_none_from_slice(t: &'a [Self]) -> (*mut $ffi_name, Self::Storage) {
@@ -298,7 +298,7 @@ macro_rules! glib_boxed_inline_wrapper {
298298
}
299299

300300
#[doc(hidden)]
301-
impl<'a $(, $($generic $(: $bound $(+ $bound2)*)?),+)?> $crate::translate::ToGlibContainerFromSlice<'a, *const $ffi_name> for $name $(<$($generic),+>)? {
301+
impl<'a $(, $($generic: 'a $($bound $(+ $bound2)*)?),+)?> $crate::translate::ToGlibContainerFromSlice<'a, *const $ffi_name> for $name $(<$($generic),+>)? {
302302
type Storage = Option<&'a [Self]>;
303303

304304
fn to_glib_none_from_slice(t: &'a [Self]) -> (*const $ffi_name, Self::Storage) {
@@ -427,7 +427,7 @@ macro_rules! glib_boxed_inline_wrapper {
427427

428428
let mut res = Vec::with_capacity(num);
429429
for i in 0..num {
430-
res.push(std::ptr::read(ptr.add(i) as *const $name));
430+
res.push(std::ptr::read(ptr.add(i) as *const $name $(<$($generic),+>)?));
431431
}
432432
$crate::ffi::g_free(ptr as *mut _);
433433
res
@@ -495,26 +495,26 @@ macro_rules! glib_boxed_inline_wrapper {
495495
}
496496

497497
#[doc(hidden)]
498-
impl $(<$($generic $(: $bound $(+ $bound2)*)?),+>)? $crate::value::ValueType for $name $(<$($generic),+>)? {
498+
impl$(<$($generic: 'static + $($bound $(+ $bound2)*)?),+>)? $crate::value::ValueType for $name $(<$($generic),+>)? {
499499
type Type = Self;
500500
}
501501

502502
#[doc(hidden)]
503-
unsafe impl<'a> $crate::value::FromValue<'a> for $name $(<$($generic),+>)? {
503+
unsafe impl $(<$($generic $(: $bound $(+ $bound2)*)?),+>)? $crate::value::FromValue<'_> for $name $(<$($generic),+>)? {
504504
type Checker = $crate::value::GenericValueTypeOrNoneChecker<Self>;
505505

506-
unsafe fn from_value(value: &'a $crate::Value) -> Self {
506+
unsafe fn from_value(value: &'_ $crate::Value) -> Self {
507507
let ptr = $crate::gobject_ffi::g_value_get_boxed($crate::translate::ToGlibPtr::to_glib_none(value).0);
508508
assert!(!ptr.is_null());
509509
<Self as $crate::translate::FromGlibPtrNone<*const $ffi_name>>::from_glib_none(ptr as *const $ffi_name)
510510
}
511511
}
512512

513513
#[doc(hidden)]
514-
unsafe impl<'a> $crate::value::FromValue<'a> for &'a $name $(<$($generic),+>)? {
514+
unsafe impl $(<$($generic $(: $bound $(+ $bound2)*)?),+>)? $crate::value::FromValue<'_> for &'_ $name $(<$($generic),+>)? {
515515
type Checker = $crate::value::GenericValueTypeOrNoneChecker<Self>;
516516

517-
unsafe fn from_value(value: &'a $crate::Value) -> Self {
517+
unsafe fn from_value(value: &'_ $crate::Value) -> Self {
518518
let ptr = $crate::gobject_ffi::g_value_get_boxed($crate::translate::ToGlibPtr::to_glib_none(value).0);
519519
assert!(!ptr.is_null());
520520
&*(ptr as *const $ffi_name as *const $name $(<$($generic),+>)?)
@@ -540,7 +540,7 @@ macro_rules! glib_boxed_inline_wrapper {
540540
}
541541

542542
#[doc(hidden)]
543-
impl $(<$($generic $(: $bound $(+ $bound2)*)?),+>)? $crate::value::ToValueOptional for $name $(<$($generic),+>)? {
543+
impl $(<$($generic: 'static + $($bound $(+ $bound2)*)?),+>)? $crate::value::ToValueOptional for $name $(<$($generic),+>)? {
544544
fn to_value_optional(s: Option<&Self>) -> $crate::Value {
545545
let mut value = $crate::Value::for_value_type::<Self>();
546546
unsafe {

0 commit comments

Comments
 (0)