@@ -16,10 +16,7 @@ struct Property {
16
16
17
17
impl Property {
18
18
fn implement_via_trait ( & self ) -> bool {
19
- self . is_group ( )
20
- || self . is_channel ( )
21
- || self . is_sysex_payload ( )
22
- || self . is_jitter_reduction ( )
19
+ self . is_group ( ) || self . is_channel ( ) || self . is_sysex_payload ( )
23
20
}
24
21
fn is_group ( & self ) -> bool {
25
22
self . ident == "group"
@@ -30,9 +27,6 @@ impl Property {
30
27
fn is_sysex_payload ( & self ) -> bool {
31
28
self . ident == "sysex_payload"
32
29
}
33
- fn is_jitter_reduction ( & self ) -> bool {
34
- self . ident == "jitter_reduction"
35
- }
36
30
}
37
31
38
32
fn has_attr ( field : & syn:: Field , id : & str ) -> bool {
@@ -350,7 +344,7 @@ fn secondary_new_arr_impl(root_ident: &syn::Ident, properties: &Vec<Property>) -
350
344
}
351
345
352
346
fn arr_type_ump ( ) -> TokenStream {
353
- quote ! { [ u32 ; 5 ] }
347
+ quote ! { [ u32 ; 4 ] }
354
348
}
355
349
356
350
fn arr_type_bytes ( ) -> TokenStream {
@@ -362,20 +356,7 @@ fn size_impl(root_ident: &syn::Ident, args: &GenerateMessageArgs) -> TokenStream
362
356
quote ! {
363
357
impl <B : #constraint> crate :: traits:: Size <B > for #root_ident<B > {
364
358
fn size( & self ) -> usize {
365
- match <B :: Unit as crate :: buffer:: UnitPrivate >:: UNIT_ID {
366
- crate :: buffer:: UNIT_ID_U32 => {
367
- // account for jitter reduction header
368
- use crate :: buffer:: UmpPrivate ;
369
- <Self as crate :: traits:: MinSize <B >>:: min_size( )
370
- + self . buffer_access( ) . specialise_u32( ) . jitter_reduction( ) . len( )
371
- }
372
- crate :: buffer:: UNIT_ID_U8 => {
373
- // simple case
374
- // no jitter reduction logic here
375
- <Self as crate :: traits:: MinSize <B >>:: min_size( )
376
- }
377
- _ => unreachable!( ) ,
378
- }
359
+ <Self as crate :: traits:: MinSize <B >>:: min_size( )
379
360
}
380
361
}
381
362
}
@@ -426,32 +407,7 @@ fn data_impl(root_ident: &syn::Ident, args: &GenerateMessageArgs) -> TokenStream
426
407
quote ! {
427
408
impl <B : #constraint> crate :: traits:: Data <B > for #root_ident<B > {
428
409
fn data( & self ) -> & [ B :: Unit ] {
429
- match <B :: Unit as crate :: buffer:: UnitPrivate >:: UNIT_ID {
430
- crate :: buffer:: UNIT_ID_U32 => {
431
- use crate :: buffer:: UmpPrivate ;
432
- use crate :: detail:: BitOps ;
433
-
434
- // account for jitter reduction header
435
- let buffer = self . buffer_access( ) . specialise_u32( ) ;
436
- let jr_slice = buffer. jitter_reduction( ) ;
437
- let jr_offset = match jr_slice. len( ) {
438
- 0 => 0 ,
439
- _ => {
440
- match u8 :: from( jr_slice[ 0 ] . nibble( 2 ) ) {
441
- 0 => 1 , // the jr header is noop - skip from the data slice
442
- _ => 0 , // the jr header has data - include it!
443
- }
444
- }
445
- } ;
446
- & self . buffer_access( ) . buffer( ) [ jr_offset..self . size( ) ]
447
- }
448
- crate :: buffer:: UNIT_ID_U8 => {
449
- // simple case
450
- // no jitter reduction logic here
451
- & self . buffer_access( ) . buffer( ) [ ..self . size( ) ]
452
- }
453
- _ => unreachable!( ) ,
454
- }
410
+ & self . buffer_access( ) . buffer( ) [ ..self . size( ) ]
455
411
}
456
412
}
457
413
}
@@ -502,34 +458,9 @@ fn rebuffer_from_impl(root_ident: &syn::Ident, args: &GenerateMessageArgs) -> To
502
458
{
503
459
fn rebuffer_from( other: #root_ident<A >) -> Self {
504
460
let mut buffer = <B as crate :: buffer:: BufferDefault >:: default ( ) ;
505
- match <B :: Unit as crate :: buffer:: UnitPrivate >:: UNIT_ID {
506
- crate :: buffer:: UNIT_ID_U32 => {
507
- // account for jitter reduction header
508
- use crate :: buffer:: UmpPrivate ;
509
- let message_size = other. data( ) . len( ) ;
510
- let jr_offset: usize = match other. data( )
511
- . specialise_u32( )
512
- . jitter_reduction( )
513
- . len( ) {
514
- 0 => {
515
- // other message had no jitter reduction header
516
- // -> we add it in on our side
517
- 1
518
- } ,
519
- _ => 0 ,
520
- } ;
521
- buffer. resize( message_size + jr_offset) ;
522
- buffer. buffer_mut( ) [ jr_offset..( message_size + jr_offset) ] . copy_from_slice( other. data( ) ) ;
523
- }
524
- crate :: buffer:: UNIT_ID_U8 => {
525
- // simple case
526
- // no jitter reduction logic here
527
- let message_size = other. data( ) . len( ) ;
528
- buffer. resize( message_size) ;
529
- buffer. buffer_mut( ) [ ..message_size] . copy_from_slice( other. data( ) ) ;
530
- }
531
- _ => unreachable!( ) ,
532
- }
461
+ let message_size = other. data( ) . len( ) ;
462
+ buffer. resize( message_size) ;
463
+ buffer. buffer_mut( ) [ ..message_size] . copy_from_slice( other. data( ) ) ;
533
464
#root_ident( buffer)
534
465
}
535
466
}
@@ -543,34 +474,9 @@ fn try_rebuffer_from_impl(root_ident: &syn::Ident, args: &GenerateMessageArgs) -
543
474
{
544
475
fn try_rebuffer_from( other: #root_ident<A >) -> core:: result:: Result <Self , crate :: error:: BufferOverflow > {
545
476
let mut buffer = <B as crate :: buffer:: BufferDefault >:: default ( ) ;
546
- match <B :: Unit as crate :: buffer:: UnitPrivate >:: UNIT_ID {
547
- crate :: buffer:: UNIT_ID_U32 => {
548
- // account for jitter reduction header
549
- use crate :: buffer:: UmpPrivate ;
550
- let message_size = other. data( ) . len( ) ;
551
- let jr_offset: usize = match other. data( )
552
- . specialise_u32( )
553
- . jitter_reduction( )
554
- . len( ) {
555
- 0 => {
556
- // other message had no jitter reduction header
557
- // -> we add it in on our side
558
- 1
559
- } ,
560
- _ => 0 ,
561
- } ;
562
- buffer. try_resize( message_size + jr_offset) ?;
563
- buffer. buffer_mut( ) [ jr_offset..( message_size + jr_offset) ] . copy_from_slice( other. data( ) ) ;
564
- }
565
- crate :: buffer:: UNIT_ID_U8 => {
566
- // simple case
567
- // no jitter reduction logic here
568
- let message_size = other. data( ) . len( ) ;
569
- buffer. try_resize( message_size) ?;
570
- buffer. buffer_mut( ) [ ..message_size] . copy_from_slice( other. data( ) ) ;
571
- }
572
- _ => unreachable!( ) ,
573
- }
477
+ let message_size = other. data( ) . len( ) ;
478
+ buffer. try_resize( message_size) ?;
479
+ buffer. buffer_mut( ) [ ..message_size] . copy_from_slice( other. data( ) ) ;
574
480
Ok ( #root_ident( buffer) )
575
481
}
576
482
}
@@ -594,13 +500,7 @@ fn new_impl(
594
500
pub fn new( ) -> #root_ident<B >
595
501
{
596
502
let mut buffer = <B as crate :: buffer:: BufferDefault >:: default ( ) ;
597
- let jr_offset = match <B :: Unit as crate :: buffer:: UnitPrivate >:: UNIT_ID {
598
- // account for jitter reduction header
599
- crate :: buffer:: UNIT_ID_U32 => 1 ,
600
- crate :: buffer:: UNIT_ID_U8 => 0 ,
601
- _ => unreachable!( ) ,
602
- } ;
603
- buffer. resize( <Self as crate :: traits:: MinSize <B >>:: min_size( ) + jr_offset) ;
503
+ buffer. resize( <Self as crate :: traits:: MinSize <B >>:: min_size( ) ) ;
604
504
#initialise_properties
605
505
#root_ident:: <B >( buffer)
606
506
}
@@ -625,13 +525,7 @@ fn try_new_impl(
625
525
pub fn try_new( ) -> core:: result:: Result <#root_ident<B >, crate :: error:: BufferOverflow >
626
526
{
627
527
let mut buffer = <B as crate :: buffer:: BufferDefault >:: default ( ) ;
628
- let jr_offset = match <B :: Unit as crate :: buffer:: UnitPrivate >:: UNIT_ID {
629
- // account for jitter reduction header
630
- crate :: buffer:: UNIT_ID_U32 => 1 ,
631
- crate :: buffer:: UNIT_ID_U8 => 0 ,
632
- _ => unreachable!( ) ,
633
- } ;
634
- buffer. try_resize( <Self as crate :: traits:: MinSize <B >>:: min_size( ) + jr_offset) ?;
528
+ buffer. try_resize( <Self as crate :: traits:: MinSize <B >>:: min_size( ) ) ?;
635
529
#initialise_properties
636
530
Ok ( #root_ident:: <B >( buffer) )
637
531
}
@@ -681,17 +575,6 @@ fn grouped_impl(root_ident: &syn::Ident, property: &Property) -> TokenStream {
681
575
}
682
576
}
683
577
684
- fn jitter_reduction_impl ( root_ident : & syn:: Ident , property : & Property ) -> TokenStream {
685
- let setter = property_setter ( property, false ) ;
686
- let getter = property_getter ( property, false ) ;
687
- quote ! {
688
- impl <B : crate :: buffer:: Ump > crate :: traits:: JitterReduced <B > for #root_ident<B > {
689
- #getter
690
- #setter
691
- }
692
- }
693
- }
694
-
695
578
fn channeled_impl (
696
579
root_ident : & syn:: Ident ,
697
580
property : & Property ,
@@ -721,10 +604,7 @@ fn from_bytes_impl(root_ident: &syn::Ident, properties: &Vec<Property>) -> Token
721
604
{
722
605
fn from_bytes( other: #root_ident<A >) -> Self {
723
606
let mut buffer = <B as crate :: buffer:: BufferDefault >:: default ( ) ;
724
- buffer. resize(
725
- <#root_ident<B > as crate :: traits:: MinSize <B >>:: min_size( )
726
- + crate :: buffer:: OFFSET_FOR_JITTER_REDUCTION
727
- ) ;
607
+ buffer. resize( <#root_ident<B > as crate :: traits:: MinSize <B >>:: min_size( ) ) ;
728
608
#convert_properties
729
609
Self ( buffer)
730
610
}
@@ -745,10 +625,7 @@ fn try_from_bytes_impl(root_ident: &syn::Ident, properties: &Vec<Property>) -> T
745
625
{
746
626
fn try_from_bytes( other: #root_ident<A >) -> core:: result:: Result <Self , crate :: error:: BufferOverflow > {
747
627
let mut buffer = <B as crate :: buffer:: BufferDefault >:: default ( ) ;
748
- buffer. try_resize(
749
- <#root_ident<B > as crate :: traits:: MinSize <B >>:: min_size( )
750
- + crate :: buffer:: OFFSET_FOR_JITTER_REDUCTION
751
- ) ?;
628
+ buffer. try_resize( <#root_ident<B > as crate :: traits:: MinSize <B >>:: min_size( ) ) ?;
752
629
#convert_properties
753
630
Ok ( Self ( buffer) )
754
631
}
@@ -860,9 +737,6 @@ pub fn generate_message(attrs: TokenStream1, item: TokenStream1) -> TokenStream1
860
737
if args. fixed_size {
861
738
tokens. extend ( size_impl ( root_ident, & args) )
862
739
}
863
- if let Some ( property) = properties. iter ( ) . find ( |p| p. is_jitter_reduction ( ) ) {
864
- tokens. extend ( jitter_reduction_impl ( root_ident, property) ) ;
865
- }
866
740
if let Some ( property) = properties. iter ( ) . find ( |p| p. is_group ( ) ) {
867
741
tokens. extend ( grouped_impl ( root_ident, property) ) ;
868
742
}
0 commit comments