@@ -354,12 +354,7 @@ pub fn expand<T: AttrParse + Into<ImplAttrs>, M: AttrParse + Into<MethodAttrs>>(
354
354
355
355
let ( iface_name, with_spawn, mut proxy) = {
356
356
let ( name, interface, spawn, proxy) = match T :: parse_nested_metas ( args) ?. into ( ) {
357
- ImplAttrs :: New ( new) => (
358
- new. name ,
359
- new. interface ,
360
- new. spawn ,
361
- new. proxy . map ( |p| Proxy :: new ( ty, p) ) ,
362
- ) ,
357
+ ImplAttrs :: New ( new) => ( new. name , new. interface , new. spawn , new. proxy ) ,
363
358
// New proxy attributes are not supported for old `dbus_interface`.
364
359
ImplAttrs :: Old ( old) => ( old. name , old. interface , old. spawn , None ) ,
365
360
} ;
@@ -373,6 +368,7 @@ pub fn expand<T: AttrParse + Into<ImplAttrs>, M: AttrParse + Into<MethodAttrs>>(
373
368
"`name` and `interface` attributes should not be specified at the same time" ,
374
369
) ) ,
375
370
} ;
371
+ let proxy = proxy. map ( |p| Proxy :: new ( ty, & name, p, & zbus) ) ;
376
372
377
373
( name, !spawn. unwrap_or ( false ) , proxy)
378
374
} ;
@@ -773,7 +769,7 @@ pub fn expand<T: AttrParse + Into<ImplAttrs>, M: AttrParse + Into<MethodAttrs>>(
773
769
}
774
770
775
771
if let Some ( proxy) = & mut proxy {
776
- proxy. add_method ( info, & properties, & zbus ) ;
772
+ proxy. add_method ( info, & properties) ;
777
773
}
778
774
}
779
775
@@ -794,7 +790,7 @@ pub fn expand<T: AttrParse + Into<ImplAttrs>, M: AttrParse + Into<MethodAttrs>>(
794
790
}
795
791
} ;
796
792
797
- let proxy = proxy. map ( |proxy| proxy. gen ( & iface_name , & zbus ) ) ;
793
+ let proxy = proxy. map ( |proxy| proxy. gen ( ) ) ;
798
794
799
795
Ok ( quote ! {
800
796
#input
@@ -1307,6 +1303,10 @@ impl Parse for ImplItemSignal {
1307
1303
struct Proxy {
1308
1304
// The type name
1309
1305
ty : Ident ,
1306
+ // The interface name
1307
+ iface_name : String ,
1308
+ // The zbus crate
1309
+ zbus : TokenStream ,
1310
1310
1311
1311
// Input
1312
1312
attrs : ProxyAttributes ,
@@ -1316,20 +1316,17 @@ struct Proxy {
1316
1316
}
1317
1317
1318
1318
impl Proxy {
1319
- fn new ( ty : & Ident , attrs : ProxyAttributes ) -> Self {
1319
+ fn new ( ty : & Ident , iface_name : & str , attrs : ProxyAttributes , zbus : & TokenStream ) -> Self {
1320
1320
Self {
1321
+ iface_name : iface_name. to_string ( ) ,
1321
1322
ty : ty. clone ( ) ,
1323
+ zbus : zbus. clone ( ) ,
1322
1324
attrs,
1323
1325
methods : quote ! ( ) ,
1324
1326
}
1325
1327
}
1326
1328
1327
- fn add_method (
1328
- & mut self ,
1329
- method_info : MethodInfo ,
1330
- properties : & BTreeMap < String , Property < ' _ > > ,
1331
- zbus : & TokenStream ,
1332
- ) {
1329
+ fn add_method ( & mut self , method_info : MethodInfo , properties : & BTreeMap < String , Property < ' _ > > ) {
1333
1330
let inputs: Punctuated < PatType , Comma > = method_info
1334
1331
. typed_inputs
1335
1332
. iter ( )
@@ -1386,14 +1383,15 @@ impl Proxy {
1386
1383
}
1387
1384
}
1388
1385
let cfg_attrs = method_info. cfg_attrs ;
1386
+ let zbus = & self . zbus ;
1389
1387
self . methods . extend ( quote ! {
1390
1388
#( #cfg_attrs) *
1391
1389
#[ zbus( #proxy_method_attrs) ]
1392
1390
fn #ident( & self , #inputs) -> #zbus:: Result <#ret>;
1393
1391
} ) ;
1394
1392
}
1395
1393
1396
- fn gen ( & self , iface_name : & str , zbus : & TokenStream ) -> TokenStream {
1394
+ fn gen ( & self ) -> TokenStream {
1397
1395
let attrs = & self . attrs ;
1398
1396
let (
1399
1397
assume_defaults,
@@ -1432,6 +1430,8 @@ impl Proxy {
1432
1430
& self . ty ,
1433
1431
& self . methods ,
1434
1432
) ;
1433
+ let iface_name = & self . iface_name ;
1434
+ let zbus = & self . zbus ;
1435
1435
quote ! {
1436
1436
#[ #zbus:: proxy(
1437
1437
name = #iface_name,
0 commit comments