|
5 | 5 | use crate::formatter_item_info::{FormatWriter, FormatterItemInfo}; |
6 | 6 |
|
7 | 7 | /// format string to print octal using `int_writer_unsigned` |
8 | | -macro_rules! OCT { |
| 8 | +macro_rules! oct { |
9 | 9 | () => { |
10 | 10 | " {:0width$o}" |
11 | 11 | }; |
12 | 12 | } |
13 | 13 | /// format string to print hexadecimal using `int_writer_unsigned` |
14 | | -macro_rules! HEX { |
| 14 | +macro_rules! hex { |
15 | 15 | () => { |
16 | 16 | " {:0width$x}" |
17 | 17 | }; |
18 | 18 | } |
19 | 19 | /// format string to print decimal using `int_writer_unsigned` or `int_writer_signed` |
20 | | -macro_rules! DEC { |
| 20 | +macro_rules! dec { |
21 | 21 | () => { |
22 | 22 | " {:width$}" |
23 | 23 | }; |
@@ -68,25 +68,25 @@ fn sign_extend(item: u64, item_bytes: usize) -> i64 { |
68 | 68 | (item << shift) as i64 >> shift |
69 | 69 | } |
70 | 70 |
|
71 | | -int_writer_unsigned!(FORMAT_ITEM_OCT8, 1, 4, format_item_oct8, OCT!()); // max: 377 |
72 | | -int_writer_unsigned!(FORMAT_ITEM_OCT16, 2, 7, format_item_oct16, OCT!()); // max: 177777 |
73 | | -int_writer_unsigned!(FORMAT_ITEM_OCT32, 4, 12, format_item_oct32, OCT!()); // max: 37777777777 |
74 | | -int_writer_unsigned!(FORMAT_ITEM_OCT64, 8, 23, format_item_oct64, OCT!()); // max: 1777777777777777777777 |
75 | | - |
76 | | -int_writer_unsigned!(FORMAT_ITEM_HEX8, 1, 3, format_item_hex8, HEX!()); // max: ff |
77 | | -int_writer_unsigned!(FORMAT_ITEM_HEX16, 2, 5, format_item_hex16, HEX!()); // max: ffff |
78 | | -int_writer_unsigned!(FORMAT_ITEM_HEX32, 4, 9, format_item_hex32, HEX!()); // max: ffffffff |
79 | | -int_writer_unsigned!(FORMAT_ITEM_HEX64, 8, 17, format_item_hex64, HEX!()); // max: ffffffffffffffff |
80 | | - |
81 | | -int_writer_unsigned!(FORMAT_ITEM_DEC8U, 1, 4, format_item_dec_u8, DEC!()); // max: 255 |
82 | | -int_writer_unsigned!(FORMAT_ITEM_DEC16U, 2, 6, format_item_dec_u16, DEC!()); // max: 65535 |
83 | | -int_writer_unsigned!(FORMAT_ITEM_DEC32U, 4, 11, format_item_dec_u32, DEC!()); // max: 4294967295 |
84 | | -int_writer_unsigned!(FORMAT_ITEM_DEC64U, 8, 21, format_item_dec_u64, DEC!()); // max: 18446744073709551615 |
85 | | - |
86 | | -int_writer_signed!(FORMAT_ITEM_DEC8S, 1, 5, format_item_dec_s8, DEC!()); // max: -128 |
87 | | -int_writer_signed!(FORMAT_ITEM_DEC16S, 2, 7, format_item_dec_s16, DEC!()); // max: -32768 |
88 | | -int_writer_signed!(FORMAT_ITEM_DEC32S, 4, 12, format_item_dec_s32, DEC!()); // max: -2147483648 |
89 | | -int_writer_signed!(FORMAT_ITEM_DEC64S, 8, 21, format_item_dec_s64, DEC!()); // max: -9223372036854775808 |
| 71 | +int_writer_unsigned!(FORMAT_ITEM_OCT8, 1, 4, format_item_oct8, oct!()); // max: 377 |
| 72 | +int_writer_unsigned!(FORMAT_ITEM_OCT16, 2, 7, format_item_oct16, oct!()); // max: 177777 |
| 73 | +int_writer_unsigned!(FORMAT_ITEM_OCT32, 4, 12, format_item_oct32, oct!()); // max: 37777777777 |
| 74 | +int_writer_unsigned!(FORMAT_ITEM_OCT64, 8, 23, format_item_oct64, oct!()); // max: 1777777777777777777777 |
| 75 | + |
| 76 | +int_writer_unsigned!(FORMAT_ITEM_HEX8, 1, 3, format_item_hex8, hex!()); // max: ff |
| 77 | +int_writer_unsigned!(FORMAT_ITEM_HEX16, 2, 5, format_item_hex16, hex!()); // max: ffff |
| 78 | +int_writer_unsigned!(FORMAT_ITEM_HEX32, 4, 9, format_item_hex32, hex!()); // max: ffffffff |
| 79 | +int_writer_unsigned!(FORMAT_ITEM_HEX64, 8, 17, format_item_hex64, hex!()); // max: ffffffffffffffff |
| 80 | + |
| 81 | +int_writer_unsigned!(FORMAT_ITEM_DEC8U, 1, 4, format_item_dec_u8, dec!()); // max: 255 |
| 82 | +int_writer_unsigned!(FORMAT_ITEM_DEC16U, 2, 6, format_item_dec_u16, dec!()); // max: 65535 |
| 83 | +int_writer_unsigned!(FORMAT_ITEM_DEC32U, 4, 11, format_item_dec_u32, dec!()); // max: 4294967295 |
| 84 | +int_writer_unsigned!(FORMAT_ITEM_DEC64U, 8, 21, format_item_dec_u64, dec!()); // max: 18446744073709551615 |
| 85 | + |
| 86 | +int_writer_signed!(FORMAT_ITEM_DEC8S, 1, 5, format_item_dec_s8, dec!()); // max: -128 |
| 87 | +int_writer_signed!(FORMAT_ITEM_DEC16S, 2, 7, format_item_dec_s16, dec!()); // max: -32768 |
| 88 | +int_writer_signed!(FORMAT_ITEM_DEC32S, 4, 12, format_item_dec_s32, dec!()); // max: -2147483648 |
| 89 | +int_writer_signed!(FORMAT_ITEM_DEC64S, 8, 21, format_item_dec_s64, dec!()); // max: -9223372036854775808 |
90 | 90 |
|
91 | 91 | #[test] |
92 | 92 | #[allow(clippy::cognitive_complexity)] |
|
0 commit comments