1
+ use crate :: quote:: ToTokens ;
1
2
use crate :: svd:: {
2
3
Access , BitRange , EnumeratedValues , Field , Peripheral , Register , RegisterCluster ,
3
4
RegisterProperties , Usage , WriteConstraint ,
@@ -122,9 +123,7 @@ pub fn render(
122
123
123
124
mod_items. extend ( r_impl_items) ;
124
125
125
- mod_items. extend ( quote ! {
126
- #close
127
- } ) ;
126
+ close. to_tokens ( & mut mod_items) ;
128
127
}
129
128
130
129
if can_write {
@@ -134,9 +133,7 @@ pub fn render(
134
133
135
134
mod_items. extend ( w_impl_items) ;
136
135
137
- mod_items. extend ( quote ! {
138
- #close
139
- } ) ;
136
+ close. to_tokens ( & mut mod_items) ;
140
137
}
141
138
142
139
let mut out = TokenStream :: new ( ) ;
@@ -216,6 +213,7 @@ pub fn fields(
216
213
let can_write = access != Access :: ReadOnly ;
217
214
218
215
// TODO enumeratedValues
216
+ let inline = quote ! { #[ inline( always) ] } ;
219
217
for f in fields. iter ( ) {
220
218
// TODO(AJM) - do we need to do anything with this range type?
221
219
let BitRange { offset, width, .. } = f. bit_range ;
@@ -317,7 +315,7 @@ pub fn fields(
317
315
let doc = & util:: replace_suffix ( & description, suffixes_str) ;
318
316
r_impl_items. extend ( quote ! {
319
317
#[ doc = #doc]
320
- #[ inline( always ) ]
318
+ #inline
321
319
pub unsafe fn #sc( & self , n: usize ) -> #_pc_r {
322
320
#_pc_r:: new ( #value )
323
321
}
@@ -344,7 +342,7 @@ pub fn fields(
344
342
) ;
345
343
r_impl_items. extend ( quote ! {
346
344
#[ doc = #doc]
347
- #[ inline( always ) ]
345
+ #inline
348
346
pub fn #sc_n( & self ) -> #_pc_r {
349
347
#_pc_r:: new ( #value )
350
348
}
@@ -354,7 +352,7 @@ pub fn fields(
354
352
let doc = description_with_bits ( & description, offset, width) ;
355
353
r_impl_items. extend ( quote ! {
356
354
#[ doc = #doc]
357
- #[ inline( always ) ]
355
+ #inline
358
356
pub fn #sc( & self ) -> #_pc_r {
359
357
#_pc_r:: new ( #value )
360
358
}
@@ -410,7 +408,7 @@ pub fn fields(
410
408
if has_reserved_variant {
411
409
enum_items. extend ( quote ! {
412
410
///Get enumerated values variant
413
- #[ inline( always ) ]
411
+ #inline
414
412
pub fn variant( & self ) -> crate :: Variant <#fty, #pc_r> {
415
413
use crate :: Variant :: * ;
416
414
match self . bits {
@@ -421,7 +419,7 @@ pub fn fields(
421
419
} else {
422
420
enum_items. extend ( quote ! {
423
421
///Get enumerated values variant
424
- #[ inline( always ) ]
422
+ #inline
425
423
pub fn variant( & self ) -> #pc_r {
426
424
match self . bits {
427
425
#arms
@@ -446,7 +444,7 @@ pub fn fields(
446
444
let doc = format ! ( "Checks if the value of the field is `{}`" , pc) ;
447
445
enum_items. extend ( quote ! {
448
446
#[ doc = #doc]
449
- #[ inline( always ) ]
447
+ #inline
450
448
pub fn #is_variant( & self ) -> bool {
451
449
* self == #pc_r:: #pc
452
450
}
@@ -499,7 +497,7 @@ pub fn fields(
499
497
500
498
proxy_items. extend ( quote ! {
501
499
///Writes `variant` to the field
502
- #[ inline( always ) ]
500
+ #inline
503
501
pub fn variant( self , variant: #pc_w) -> & ' a mut W {
504
502
#unsafety {
505
503
self . #bits( variant. into( ) )
@@ -514,7 +512,7 @@ pub fn fields(
514
512
let doc = util:: escape_brackets ( util:: respace ( & v. doc ) . as_ref ( ) ) ;
515
513
proxy_items. extend ( quote ! {
516
514
#[ doc = #doc]
517
- #[ inline( always ) ]
515
+ #inline
518
516
pub fn #sc( self ) -> & ' a mut W {
519
517
self . variant( #pc_w:: #pc)
520
518
}
@@ -525,13 +523,13 @@ pub fn fields(
525
523
if width == 1 {
526
524
proxy_items. extend ( quote ! {
527
525
///Sets the field bit
528
- #[ inline( always ) ]
526
+ #inline
529
527
pub #unsafety fn set_bit( self ) -> & ' a mut W {
530
528
self . bit( true )
531
529
}
532
530
533
531
///Clears the field bit
534
- #[ inline( always ) ]
532
+ #inline
535
533
pub #unsafety fn clear_bit( self ) -> & ' a mut W {
536
534
self . bit( false )
537
535
}
@@ -541,7 +539,7 @@ pub fn fields(
541
539
proxy_items. extend ( if field_dim. is_some ( ) {
542
540
quote ! {
543
541
///Writes raw bits to the field
544
- #[ inline( always ) ]
542
+ #inline
545
543
pub #unsafety fn #bits( self , value: #fty) -> & ' a mut W {
546
544
self . w. bits = ( self . w. bits & !( #hexmask << self . offset) ) | ( ( ( value as #rty) & #hexmask) << self . offset) ;
547
545
self . w
@@ -551,7 +549,7 @@ pub fn fields(
551
549
let offset = & util:: unsuffixed ( offset) ;
552
550
quote ! {
553
551
///Writes raw bits to the field
554
- #[ inline( always ) ]
552
+ #inline
555
553
pub #unsafety fn #bits( self , value: #fty) -> & ' a mut W {
556
554
self . w. bits = ( self . w. bits & !( #hexmask << #offset) ) | ( ( ( value as #rty) & #hexmask) << #offset) ;
557
555
self . w
@@ -560,7 +558,7 @@ pub fn fields(
560
558
} else {
561
559
quote ! {
562
560
///Writes raw bits to the field
563
- #[ inline( always ) ]
561
+ #inline
564
562
pub #unsafety fn #bits( self , value: #fty) -> & ' a mut W {
565
563
self . w. bits = ( self . w. bits & !#hexmask) | ( ( value as #rty) & #hexmask) ;
566
564
self . w
@@ -594,7 +592,7 @@ pub fn fields(
594
592
let doc = & util:: replace_suffix ( & description, suffixes_str) ;
595
593
w_impl_items. extend ( quote ! {
596
594
#[ doc = #doc]
597
- #[ inline( always ) ]
595
+ #inline
598
596
pub unsafe fn #sc( & mut self , n: usize ) -> #_pc_w {
599
597
#_pc_w { w: self , offset: #offset_calc }
600
598
}
@@ -612,7 +610,7 @@ pub fn fields(
612
610
let sub_offset = util:: unsuffixed ( sub_offset as u64 ) ;
613
611
w_impl_items. extend ( quote ! {
614
612
#[ doc = #doc]
615
- #[ inline( always ) ]
613
+ #inline
616
614
pub fn #sc_n( & mut self ) -> #_pc_w {
617
615
#_pc_w { w: self , offset: #sub_offset }
618
616
}
@@ -622,7 +620,7 @@ pub fn fields(
622
620
let doc = description_with_bits ( & description, offset, width) ;
623
621
w_impl_items. extend ( quote ! {
624
622
#[ doc = #doc]
625
- #[ inline( always ) ]
623
+ #inline
626
624
pub fn #sc( & mut self ) -> #_pc_w {
627
625
#_pc_w { w: self }
628
626
}
0 commit comments