@@ -332,11 +332,9 @@ enum Arg<'t> {
332332 Bool ( Arc < Bool > ) ,
333333 F32 ( f32 ) ,
334334 /// U8, U16, U24 and U32
335- Uxx ( u64 ) ,
336- U128 ( u128 ) ,
335+ Uxx ( u128 ) ,
337336 /// I8, I16, I24 and I32
338- Ixx ( i64 ) ,
339- I128 ( i128 ) ,
337+ Ixx ( i128 ) ,
340338 /// Str
341339 Str ( String ) ,
342340 /// Interned string
@@ -697,7 +695,7 @@ impl<'t, 'b> Decoder<'t, 'b> {
697695 match & param. ty {
698696 Type :: U8 => {
699697 let data = self . bytes . read_u8 ( ) ?;
700- args. push ( Arg :: Uxx ( data as u64 ) ) ;
698+ args. push ( Arg :: Uxx ( data as u128 ) ) ;
701699 }
702700
703701 Type :: Bool => {
@@ -739,78 +737,78 @@ impl<'t, 'b> Decoder<'t, 'b> {
739737 }
740738 Type :: I16 => {
741739 let data = self . bytes . read_i16 :: < LE > ( ) ?;
742- args. push ( Arg :: Ixx ( data as i64 ) ) ;
740+ args. push ( Arg :: Ixx ( data as i128 ) ) ;
743741 }
744742 Type :: I32 => {
745743 let data = self . bytes . read_i32 :: < LE > ( ) ?;
746- args. push ( Arg :: Ixx ( data as i64 ) ) ;
744+ args. push ( Arg :: Ixx ( data as i128 ) ) ;
747745 }
748746 Type :: I64 => {
749747 let data = self . bytes . read_i64 :: < LE > ( ) ?;
750- args. push ( Arg :: Ixx ( data as i64 ) ) ;
748+ args. push ( Arg :: Ixx ( data as i128 ) ) ;
751749 }
752750 Type :: I128 => {
753751 let data = self . bytes . read_i128 :: < LE > ( ) ?;
754- args. push ( Arg :: I128 ( data) ) ;
752+ args. push ( Arg :: Ixx ( data) ) ;
755753 }
756754 Type :: I8 => {
757755 let data = self . bytes . read_i8 ( ) ?;
758- args. push ( Arg :: Ixx ( data as i64 ) ) ;
756+ args. push ( Arg :: Ixx ( data as i128 ) ) ;
759757 }
760758 Type :: Isize => {
761759 // Signed isize is encoded in zigzag-encoding.
762760 let unsigned = read_leb128 ( & mut self . bytes ) ?;
763- args. push ( Arg :: Ixx ( zigzag_decode ( unsigned) ) )
761+ args. push ( Arg :: Ixx ( zigzag_decode ( unsigned) as i128 ) )
764762 }
765763 Type :: U16 => {
766764 let data = self . bytes . read_u16 :: < LE > ( ) ?;
767- args. push ( Arg :: Uxx ( data as u64 ) ) ;
765+ args. push ( Arg :: Uxx ( data as u128 ) ) ;
768766 }
769767 Type :: U24 => {
770768 let data_low = self . bytes . read_u8 ( ) ?;
771769 let data_high = self . bytes . read_u16 :: < LE > ( ) ?;
772- let data = data_low as u64 | ( data_high as u64 ) << 8 ;
773- args. push ( Arg :: Uxx ( data as u64 ) ) ;
770+ let data = data_low as u128 | ( data_high as u128 ) << 8 ;
771+ args. push ( Arg :: Uxx ( data as u128 ) ) ;
774772 }
775773 Type :: U32 => {
776774 let data = self . bytes . read_u32 :: < LE > ( ) ?;
777- args. push ( Arg :: Uxx ( data as u64 ) ) ;
775+ args. push ( Arg :: Uxx ( data as u128 ) ) ;
778776 }
779777 Type :: U64 => {
780778 let data = self . bytes . read_u64 :: < LE > ( ) ?;
781- args. push ( Arg :: Uxx ( data as u64 ) ) ;
779+ args. push ( Arg :: Uxx ( data as u128 ) ) ;
782780 }
783781 Type :: U128 => {
784782 let data = self . bytes . read_u128 :: < LE > ( ) ?;
785- args. push ( Arg :: U128 ( data) ) ;
783+ args. push ( Arg :: Uxx ( data as u128 ) ) ;
786784 }
787785 Type :: Usize => {
788786 let unsigned = read_leb128 ( & mut self . bytes ) ?;
789- args. push ( Arg :: Uxx ( unsigned) )
787+ args. push ( Arg :: Uxx ( unsigned as u128 ) )
790788 }
791789 Type :: F32 => {
792790 let data = self . bytes . read_u32 :: < LE > ( ) ?;
793791 args. push ( Arg :: F32 ( f32:: from_bits ( data) ) ) ;
794792 }
795793 Type :: BitField ( range) => {
796- let mut data: u64 ;
794+ let mut data: u128 ;
797795 let lowest_byte = range. start / 8 ;
798796 // -1 because `range` is range-exclusive
799797 let highest_byte = ( range. end - 1 ) / 8 ;
800798 let size_after_truncation = highest_byte - lowest_byte + 1 ; // in octets
801799
802800 match size_after_truncation {
803801 1 => {
804- data = self . bytes . read_u8 ( ) ? as u64 ;
802+ data = self . bytes . read_u8 ( ) ? as u128 ;
805803 }
806804 2 => {
807- data = self . bytes . read_u16 :: < LE > ( ) ? as u64 ;
805+ data = self . bytes . read_u16 :: < LE > ( ) ? as u128 ;
808806 }
809807 3 => {
810- data = self . bytes . read_u24 :: < LE > ( ) ? as u64 ;
808+ data = self . bytes . read_u24 :: < LE > ( ) ? as u128 ;
811809 }
812810 4 => {
813- data = self . bytes . read_u32 :: < LE > ( ) ? as u64 ;
811+ data = self . bytes . read_u32 :: < LE > ( ) ? as u128 ;
814812 }
815813 _ => {
816814 unreachable ! ( ) ;
@@ -1009,7 +1007,7 @@ fn format_args_real(
10091007 Arg :: Uxx ( x) => {
10101008 match param. ty {
10111009 Type :: BitField ( range) => {
1012- let left_zeroes = mem:: size_of :: < u64 > ( ) * 8 - range. end as usize ;
1010+ let left_zeroes = mem:: size_of :: < u128 > ( ) * 8 - range. end as usize ;
10131011 let right_zeroes = left_zeroes + range. start as usize ;
10141012 // isolate the desired bitfields
10151013 let bitfields = ( * x << left_zeroes) >> right_zeroes;
@@ -1018,9 +1016,7 @@ fn format_args_real(
10181016 _ => format_u128 ( * x as u128 , hint, & mut buf) ?,
10191017 }
10201018 }
1021- Arg :: U128 ( x) => format_u128 ( * x, hint, & mut buf) ?,
10221019 Arg :: Ixx ( x) => format_i128 ( * x as i128 , hint, & mut buf) ?,
1023- Arg :: I128 ( x) => format_i128 ( * x, hint, & mut buf) ?,
10241020 Arg :: Str ( x) => format_str ( x, hint, & mut buf) ?,
10251021 Arg :: IStr ( x) => format_str ( x, hint, & mut buf) ?,
10261022 Arg :: Format { format, args } => buf. push_str ( & format_args ( format, args, hint) ) ,
@@ -1167,17 +1163,17 @@ mod tests {
11671163 format: FMT ,
11681164 timestamp: 2 ,
11691165 args: vec![
1170- Arg :: Uxx ( 42 ) , // u8
1171- Arg :: Uxx ( u16 :: max_value( ) . into( ) ) , // u16
1172- Arg :: Uxx ( 0x10000 ) , // u24
1173- Arg :: Uxx ( u32 :: max_value( ) . into( ) ) , // u32
1174- Arg :: Uxx ( u64 :: max_value( ) . into( ) ) , // u64
1175- Arg :: U128 ( u128 :: max_value( ) . into( ) ) ,
1176- Arg :: Ixx ( -1 ) , // i8
1177- Arg :: Ixx ( -1 ) , // i16
1178- Arg :: Ixx ( -1 ) , // i32
1179- Arg :: Ixx ( -1 ) , // i64
1180- Arg :: I128 ( -1 ) , // i128
1166+ Arg :: Uxx ( 42 ) , // u8
1167+ Arg :: Uxx ( u16 :: max_value( ) . into( ) ) , // u16
1168+ Arg :: Uxx ( 0x10000 ) , // u24
1169+ Arg :: Uxx ( u32 :: max_value( ) . into( ) ) , // u32
1170+ Arg :: Uxx ( u64 :: max_value( ) . into( ) ) , // u64
1171+ Arg :: Uxx ( u128 :: max_value( ) . into( ) ) , // u128
1172+ Arg :: Ixx ( -1 ) , // i8
1173+ Arg :: Ixx ( -1 ) , // i16
1174+ Arg :: Ixx ( -1 ) , // i32
1175+ Arg :: Ixx ( -1 ) , // i64
1176+ Arg :: Ixx ( -1 ) , // i128
11811177 ] ,
11821178 } ,
11831179 bytes. len( ) ,
0 commit comments