@@ -332,6 +332,9 @@ impl PropDesc {
332
332
is_construct_only,
333
333
} )
334
334
}
335
+ fn is_overriding ( & self ) -> bool {
336
+ self . override_class . is_some ( ) || self . override_interface . is_some ( )
337
+ }
335
338
}
336
339
337
340
fn expand_param_spec ( prop : & PropDesc ) -> TokenStream2 {
@@ -558,7 +561,7 @@ fn strip_raw_prefix_from_name(name: &LitStr) -> LitStr {
558
561
559
562
fn expand_impl_getset_properties ( props : & [ PropDesc ] ) -> Vec < syn:: ImplItemFn > {
560
563
let crate_ident = crate_ident_new ( ) ;
561
- let defs = props. iter ( ) . map ( |p| {
564
+ let defs = props. iter ( ) . filter ( |p| !p . is_overriding ( ) ) . map ( |p| {
562
565
let name = & p. name ;
563
566
let stripped_name = strip_raw_prefix_from_name ( name) ;
564
567
let ident = name_to_ident ( name) ;
@@ -604,7 +607,7 @@ fn expand_impl_getset_properties(props: &[PropDesc]) -> Vec<syn::ImplItemFn> {
604
607
605
608
fn expand_impl_connect_prop_notify ( props : & [ PropDesc ] ) -> Vec < syn:: ImplItemFn > {
606
609
let crate_ident = crate_ident_new ( ) ;
607
- let connection_fns = props. iter ( ) . map ( |p| -> syn:: ImplItemFn {
610
+ let connection_fns = props. iter ( ) . filter ( |p| !p . is_overriding ( ) ) . map ( |p| -> syn:: ImplItemFn {
608
611
let name = & p. name ;
609
612
let stripped_name = strip_raw_prefix_from_name ( name) ;
610
613
let fn_ident = format_ident ! ( "connect_{}_notify" , name_to_ident( name) ) ;
@@ -618,16 +621,16 @@ fn expand_impl_connect_prop_notify(props: &[PropDesc]) -> Vec<syn::ImplItemFn> {
618
621
connection_fns. collect :: < Vec < _ > > ( )
619
622
}
620
623
621
- fn expand_impl_notify_prop ( props : & [ PropDesc ] ) -> Vec < syn:: ImplItemFn > {
624
+ fn expand_impl_notify_prop ( wrapper_type : & syn :: Path , props : & [ PropDesc ] ) -> Vec < syn:: ImplItemFn > {
622
625
let crate_ident = crate_ident_new ( ) ;
623
- let emit_fns = props. iter ( ) . map ( |p| -> syn:: ImplItemFn {
626
+ let emit_fns = props. iter ( ) . filter ( |p| !p . is_overriding ( ) ) . map ( |p| -> syn:: ImplItemFn {
624
627
let name = strip_raw_prefix_from_name ( & p. name ) ;
625
628
let fn_ident = format_ident ! ( "notify_{}" , name_to_ident( & name) ) ;
626
629
let span = p. attrs_span ;
627
630
let enum_ident = name_to_enum_ident ( name. value ( ) ) ;
628
631
parse_quote_spanned ! ( span=> pub fn #fn_ident( & self ) {
629
632
self . notify_by_pspec(
630
- & <<Self as #crate_ident:: object:: ObjectSubclassIs >:: Subclass
633
+ & <<#wrapper_type as #crate_ident:: object:: ObjectSubclassIs >:: Subclass
631
634
as #crate_ident:: subclass:: object:: DerivedObjectProperties >:: derived_properties( )
632
635
[ DerivedPropertiesEnum :: #enum_ident as usize ]
633
636
) ;
@@ -692,7 +695,7 @@ pub fn impl_derive_props(input: PropsMacroInput) -> TokenStream {
692
695
let fn_set_property = expand_set_property_fn ( & input. props ) ;
693
696
let getset_properties = expand_impl_getset_properties ( & input. props ) ;
694
697
let connect_prop_notify = expand_impl_connect_prop_notify ( & input. props ) ;
695
- let notify_prop = expand_impl_notify_prop ( & input. props ) ;
698
+ let notify_prop = expand_impl_notify_prop ( & wrapper_type , & input. props ) ;
696
699
let properties_enum = expand_properties_enum ( & input. props ) ;
697
700
698
701
let rust_interface = if let Some ( ext_trait) = input. ext_trait {
@@ -704,17 +707,7 @@ pub fn impl_derive_props(input: PropsMacroInput) -> TokenStream {
704
707
wrapper_type. segments. last( ) . unwrap( ) . ident
705
708
)
706
709
} ;
707
- let signatures = getset_properties
708
- . iter ( )
709
- . chain ( connect_prop_notify. iter ( ) )
710
- . chain ( notify_prop. iter ( ) )
711
- . map ( |item| & item. sig ) ;
712
- let trait_def = quote ! {
713
- pub trait #trait_ident {
714
- #( #signatures; ) *
715
- }
716
- } ;
717
- let impls = getset_properties
710
+ let fns_without_visibility_modifier = getset_properties
718
711
. into_iter ( )
719
712
. chain ( connect_prop_notify)
720
713
. chain ( notify_prop)
@@ -723,10 +716,10 @@ pub fn impl_derive_props(input: PropsMacroInput) -> TokenStream {
723
716
item
724
717
} ) ;
725
718
quote ! {
726
- #trait_def
727
- impl #trait_ident for #wrapper_type {
728
- #( #impls) *
719
+ pub trait #trait_ident: #crate_ident:: IsA <#wrapper_type> {
720
+ #( #fns_without_visibility_modifier) *
729
721
}
722
+ impl <T : #crate_ident:: IsA <#wrapper_type>> #trait_ident for T { }
730
723
}
731
724
} else {
732
725
quote ! {
0 commit comments