Skip to content

Commit

Permalink
macros: generate GlibPtrDefault when deriving Boxed and SharedBoxed
Browse files Browse the repository at this point in the history
  • Loading branch information
pbor authored and sdroege committed Dec 30, 2023
1 parent 5a17fef commit 574908c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions glib-macros/src/boxed_derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,10 @@ pub fn impl_boxed(input: &syn::DeriveInput) -> TokenStream {

#impl_from_value

impl #crate_ident::translate::GlibPtrDefault for #name {
type GlibType = *mut #name;
}

impl #crate_ident::translate::FromGlibPtrBorrow<*const #name> for #name {
#[inline]
unsafe fn from_glib_borrow(ptr: *const #name) -> #crate_ident::translate::Borrowed<Self> {
Expand Down
4 changes: 4 additions & 0 deletions glib-macros/src/shared_boxed_derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,10 @@ pub fn impl_shared_boxed(input: &syn::DeriveInput) -> proc_macro2::TokenStream {

#impl_from_value

impl #crate_ident::translate::GlibPtrDefault for #name {
type GlibType = *mut #refcounted_type_prefix::InnerType;
}

impl #crate_ident::translate::FromGlibPtrBorrow<*const #refcounted_type_prefix::InnerType> for #name {
#[inline]
unsafe fn from_glib_borrow(ptr: *const #refcounted_type_prefix::InnerType) -> #crate_ident::translate::Borrowed<Self> {
Expand Down

0 comments on commit 574908c

Please sign in to comment.