Skip to content
This repository was archived by the owner on Jun 8, 2021. It is now read-only.

Commit d778e3a

Browse files
Merge pull request #428 from GuillaumeGomez/borrow
generate from_glib_borrow implementation for const pointers
2 parents 96493f1 + 9dbaa81 commit d778e3a

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

src/boxed.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,14 @@ macro_rules! glib_boxed_wrapper {
205205
}
206206
}
207207

208+
#[doc(hidden)]
209+
impl $crate::translate::FromGlibPtrBorrow<*const $ffi_name> for $name {
210+
#[inline]
211+
unsafe fn from_glib_borrow(ptr: *const $ffi_name) -> Self {
212+
$crate::translate::from_glib_borrow(ptr as *mut $ffi_name)
213+
}
214+
}
215+
208216
#[doc(hidden)]
209217
impl $crate::translate::FromGlibContainerAsVec<*mut $ffi_name, *mut *mut $ffi_name> for $name {
210218
unsafe fn from_glib_none_num_as_vec(ptr: *mut *mut $ffi_name, num: usize) -> Vec<Self> {

src/object.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,15 @@ macro_rules! glib_object_wrapper {
531531
}
532532
}
533533

534+
#[doc(hidden)]
535+
impl $crate::translate::FromGlibPtrBorrow<*const $ffi_name> for $name {
536+
#[inline]
537+
#[cfg_attr(feature = "cargo-clippy", allow(cast_ptr_alignment))]
538+
unsafe fn from_glib_borrow(ptr: *const $ffi_name) -> Self {
539+
$crate::translate::from_glib_borrow(ptr as *mut $ffi_name)
540+
}
541+
}
542+
534543
#[doc(hidden)]
535544
impl $crate::translate::FromGlibContainerAsVec<*mut $ffi_name, *mut *mut $ffi_name> for $name {
536545
unsafe fn from_glib_none_num_as_vec(ptr: *mut *mut $ffi_name, num: usize) -> Vec<Self> {

src/shared.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,14 @@ macro_rules! glib_shared_wrapper {
184184
}
185185
}
186186

187+
#[doc(hidden)]
188+
impl $crate::translate::FromGlibPtrBorrow<*const $ffi_name> for $name {
189+
#[inline]
190+
unsafe fn from_glib_borrow(ptr: *const $ffi_name) -> Self {
191+
$crate::translate::from_glib_borrow(ptr as *mut $ffi_name)
192+
}
193+
}
194+
187195
#[doc(hidden)]
188196
impl $crate::translate::FromGlibContainerAsVec<*mut $ffi_name, *mut *mut $ffi_name> for $name {
189197
unsafe fn from_glib_none_num_as_vec(ptr: *mut *mut $ffi_name, num: usize) -> Vec<Self> {

0 commit comments

Comments
 (0)