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

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #428 from GuillaumeGomez/borrow
generate from_glib_borrow implementation for const pointers
  • Loading branch information
GuillaumeGomez committed Jan 22, 2019
2 parents 96493f1 + 9dbaa81 commit d778e3a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/boxed.rs
Expand Up @@ -205,6 +205,14 @@ macro_rules! glib_boxed_wrapper {
}
}

#[doc(hidden)]
impl $crate::translate::FromGlibPtrBorrow<*const $ffi_name> for $name {
#[inline]
unsafe fn from_glib_borrow(ptr: *const $ffi_name) -> Self {
$crate::translate::from_glib_borrow(ptr as *mut $ffi_name)
}
}

#[doc(hidden)]
impl $crate::translate::FromGlibContainerAsVec<*mut $ffi_name, *mut *mut $ffi_name> for $name {
unsafe fn from_glib_none_num_as_vec(ptr: *mut *mut $ffi_name, num: usize) -> Vec<Self> {
Expand Down
9 changes: 9 additions & 0 deletions src/object.rs
Expand Up @@ -531,6 +531,15 @@ macro_rules! glib_object_wrapper {
}
}

#[doc(hidden)]
impl $crate::translate::FromGlibPtrBorrow<*const $ffi_name> for $name {
#[inline]
#[cfg_attr(feature = "cargo-clippy", allow(cast_ptr_alignment))]
unsafe fn from_glib_borrow(ptr: *const $ffi_name) -> Self {
$crate::translate::from_glib_borrow(ptr as *mut $ffi_name)
}
}

#[doc(hidden)]
impl $crate::translate::FromGlibContainerAsVec<*mut $ffi_name, *mut *mut $ffi_name> for $name {
unsafe fn from_glib_none_num_as_vec(ptr: *mut *mut $ffi_name, num: usize) -> Vec<Self> {
Expand Down
8 changes: 8 additions & 0 deletions src/shared.rs
Expand Up @@ -184,6 +184,14 @@ macro_rules! glib_shared_wrapper {
}
}

#[doc(hidden)]
impl $crate::translate::FromGlibPtrBorrow<*const $ffi_name> for $name {
#[inline]
unsafe fn from_glib_borrow(ptr: *const $ffi_name) -> Self {
$crate::translate::from_glib_borrow(ptr as *mut $ffi_name)
}
}

#[doc(hidden)]
impl $crate::translate::FromGlibContainerAsVec<*mut $ffi_name, *mut *mut $ffi_name> for $name {
unsafe fn from_glib_none_num_as_vec(ptr: *mut *mut $ffi_name, num: usize) -> Vec<Self> {
Expand Down

0 comments on commit d778e3a

Please sign in to comment.