Skip to content

Commit

Permalink
glib-macros: Properties: Annotate methods with #[allow(dead_code)]
Browse files Browse the repository at this point in the history
  • Loading branch information
felinira authored and sdroege committed May 23, 2024
1 parent 8caf1e2 commit 9765deb
Showing 1 changed file with 27 additions and 16 deletions.
43 changes: 27 additions & 16 deletions glib-macros/src/properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -571,9 +571,11 @@ fn expand_impl_getset_properties(props: &[PropDesc]) -> Vec<syn::ImplItemFn> {
let span = p.attrs_span;
parse_quote_spanned!(span=>
#[must_use]
#[allow(dead_code)]
pub fn #ident(&self) -> <#ty as #crate_ident::property::Property>::Value {
self.property::<<#ty as #crate_ident::property::Property>::Value>(#stripped_name)
})
}
)
});

let setter = (p.set.is_some() && !p.is_construct_only).then(|| {
Expand All @@ -594,9 +596,12 @@ fn expand_impl_getset_properties(props: &[PropDesc]) -> Vec<syn::ImplItemFn> {
)
};
let span = p.attrs_span;
parse_quote_spanned!(span=> pub fn #ident<'a>(&self, value: #set_ty) {
self.set_property_from_value(#stripped_name, &::std::convert::From::from(#upcasted_borrowed_value))
})
parse_quote_spanned!(span=>
#[allow(dead_code)]
pub fn #ident<'a>(&self, value: #set_ty) {
self.set_property_from_value(#stripped_name, &::std::convert::From::from(#upcasted_borrowed_value))
}
)
});
[getter, setter]
});
Expand All @@ -612,11 +617,14 @@ fn expand_impl_connect_prop_notify(props: &[PropDesc]) -> Vec<syn::ImplItemFn> {
let stripped_name = strip_raw_prefix_from_name(name);
let fn_ident = format_ident!("connect_{}_notify", name_to_ident(name));
let span = p.attrs_span;
parse_quote_spanned!(span=> pub fn #fn_ident<F: Fn(&Self) + 'static>(&self, f: F) -> #crate_ident::SignalHandlerId {
self.connect_notify_local(::core::option::Option::Some(#stripped_name), move |this, _| {
f(this)
})
})
parse_quote_spanned!(span=>
#[allow(dead_code)]
pub fn #fn_ident<F: Fn(&Self) + 'static>(&self, f: F) -> #crate_ident::SignalHandlerId {
self.connect_notify_local(::core::option::Option::Some(#stripped_name), move |this, _| {
f(this)
})
}
)
});
connection_fns.collect::<Vec<_>>()
}
Expand All @@ -628,13 +636,16 @@ fn expand_impl_notify_prop(wrapper_type: &syn::Path, props: &[PropDesc]) -> Vec<
let fn_ident = format_ident!("notify_{}", name_to_ident(&name));
let span = p.attrs_span;
let enum_ident = name_to_enum_ident(name.value());
parse_quote_spanned!(span=> pub fn #fn_ident(&self) {
self.notify_by_pspec(
&<<#wrapper_type as #crate_ident::object::ObjectSubclassIs>::Subclass
as #crate_ident::subclass::object::DerivedObjectProperties>::derived_properties()
[DerivedPropertiesEnum::#enum_ident as usize]
);
})
parse_quote_spanned!(span=>
#[allow(dead_code)]
pub fn #fn_ident(&self) {
self.notify_by_pspec(
&<<#wrapper_type as #crate_ident::object::ObjectSubclassIs>::Subclass
as #crate_ident::subclass::object::DerivedObjectProperties>::derived_properties()
[DerivedPropertiesEnum::#enum_ident as usize]
);
}
)
});
emit_fns.collect::<Vec<_>>()
}
Expand Down

0 comments on commit 9765deb

Please sign in to comment.