@@ -386,7 +386,12 @@ fn expand_property_fn(props: &[PropDesc]) -> TokenStream2 {
386
386
} )
387
387
} ) ;
388
388
quote ! (
389
- fn derived_property<' a>( & self , _obj: & Self :: Type , id: usize , pspec: & ' a #crate_ident:: ParamSpec ) -> Result <#crate_ident:: Value , #crate_ident:: subclass:: object:: MissingPropertyHandler <' a>> {
389
+ fn derived_property<' a>(
390
+ & self ,
391
+ _obj: & Self :: Type ,
392
+ id: usize ,
393
+ pspec: & ' a #crate_ident:: ParamSpec
394
+ ) -> Result <#crate_ident:: Value , #crate_ident:: subclass:: object:: MissingPropertyHandler <' a>> {
390
395
let prop = DerivedPropertiesEnum :: try_from( id-1 )
391
396
. map_err( |_| #crate_ident:: subclass:: object:: MissingPropertyHandler :: <' a>:: from( pspec) ) ?;
392
397
match prop {
@@ -442,7 +447,12 @@ fn expand_set_property_fn(props: &[PropDesc]) -> TokenStream2 {
442
447
} )
443
448
} ) ;
444
449
quote ! (
445
- fn derived_set_property<' a>( & self , _obj: & Self :: Type , id: usize , value: & #crate_ident:: Value , pspec: & ' a #crate_ident:: ParamSpec ) -> Result <( ) , #crate_ident:: subclass:: object:: MissingPropertyHandler <' a>> {
450
+ fn derived_set_property<' a>( & self ,
451
+ _obj: & Self :: Type ,
452
+ id: usize ,
453
+ value: & #crate_ident:: Value ,
454
+ pspec: & ' a #crate_ident:: ParamSpec
455
+ ) -> Result <( ) , #crate_ident:: subclass:: object:: MissingPropertyHandler <' a>> {
446
456
let prop = DerivedPropertiesEnum :: try_from( id-1 )
447
457
. map_err( |_| #crate_ident:: subclass:: object:: MissingPropertyHandler :: <' a>:: from( pspec) ) ?;
448
458
match prop {
@@ -492,18 +502,15 @@ fn expand_getset_properties_impl(props: &[PropDesc]) -> TokenStream2 {
492
502
let ty = & p. ty ;
493
503
494
504
let getter = p. get . is_some ( ) . then ( || {
495
- let body = quote ! ( self . property:: <<#ty as #crate_ident:: Property >:: Value >( #name) ) ;
496
- let fn_prototype =
497
- { quote ! ( pub fn #ident( & self ) -> <#ty as #crate_ident:: Property >:: Value ) } ;
498
- quote ! ( #fn_prototype { #body } )
505
+ quote ! ( pub fn #ident( & self ) -> <#ty as #crate_ident:: Property >:: Value {
506
+ self . property:: <<#ty as #crate_ident:: Property >:: Value >( #name)
507
+ } )
499
508
} ) ;
500
509
let setter = ( p. set . is_some ( ) && !p. flags . contains ( & "construct_only" ) ) . then ( || {
501
- let body = quote ! ( self . set_property_from_value( #name, & std:: borrow:: Borrow :: borrow( & value) . to_value( ) ) ) ;
502
- let fn_prototype = {
503
- let ident = format_ident ! ( "set_{}" , ident) ;
504
- quote ! ( pub fn #ident<' a>( & self , value: impl std:: borrow:: Borrow <<<#ty as #crate_ident:: Property >:: Value as #crate_ident:: HasParamSpec >:: SetValue >) )
505
- } ;
506
- quote ! ( #fn_prototype { #body } )
510
+ let ident = format_ident ! ( "set_{}" , ident) ;
511
+ quote ! ( pub fn #ident<' a>( & self , value: impl std:: borrow:: Borrow <<<#ty as #crate_ident:: Property >:: Value as #crate_ident:: HasParamSpec >:: SetValue >) {
512
+ self . set_property_from_value( #name, & std:: borrow:: Borrow :: borrow( & value) . to_value( ) )
513
+ } )
507
514
} ) ;
508
515
let span = p. attrs_span ;
509
516
quote_spanned ! ( span=>
@@ -518,12 +525,9 @@ fn expand_connect_prop_notify_impl(props: &[PropDesc]) -> TokenStream2 {
518
525
let crate_ident = crate_ident_new ( ) ;
519
526
let connection_fns = props. iter ( ) . map ( |p| {
520
527
let name = & p. name ;
521
- let fn_prototype = {
522
- let fn_ident = format_ident ! ( "connect_{}_notify" , name_to_ident( name) ) ;
523
- quote ! ( pub fn #fn_ident<F : Fn ( & Self ) + ' static >( & self , f: F ) -> #crate_ident:: SignalHandlerId )
524
- } ;
528
+ let fn_ident = format_ident ! ( "connect_{}_notify" , name_to_ident( name) ) ;
525
529
let span = p. attrs_span ;
526
- quote_spanned ! ( span=> #fn_prototype {
530
+ quote_spanned ! ( span=> pub fn #fn_ident< F : Fn ( & Self ) + ' static > ( & self , f : F ) -> #crate_ident :: SignalHandlerId {
527
531
self . connect_notify_local( Some ( #name) , move |this, _| {
528
532
f( this)
529
533
} )
@@ -536,13 +540,10 @@ fn expand_emit_impl(props: &[PropDesc]) -> TokenStream2 {
536
540
let crate_ident = crate_ident_new ( ) ;
537
541
let emit_fns = props. iter ( ) . map ( |p| {
538
542
let name = & p. name ;
539
- let fn_prototype = {
540
- let fn_ident = format_ident ! ( "emit_{}" , name_to_ident( name) ) ;
541
- quote ! ( pub fn #fn_ident( & self ) )
542
- } ;
543
+ let fn_ident = format_ident ! ( "emit_{}" , name_to_ident( name) ) ;
543
544
let span = p. attrs_span ;
544
545
let enum_ident = name_to_enum_ident ( name. value ( ) ) ;
545
- quote_spanned ! ( span=> #fn_prototype {
546
+ quote_spanned ! ( span=> pub fn #fn_ident ( & self ) {
546
547
self . notify_by_pspec(
547
548
& <<Self as #crate_ident:: object:: ObjectSubclassIs >:: Subclass
548
549
as #crate_ident:: subclass:: object:: DerivedObjectProperties >:: derived_properties( )
0 commit comments