Mercurial > touhou
comparison formats/src/th06/anm0.rs @ 776:94033091458b
formats: Update to ${concat(…)} to build on current nightly
${concat(…)} replaces the removed concat_idents!() macro, but doesn’t support
being used in nested repetitions for now. We can remove the gen_match!() macro
once this is supported again.
| author | Link Mauve <linkmauve@linkmauve.fr> |
|---|---|
| date | Tue, 14 Oct 2025 12:41:29 +0000 |
| parents | d08eb4c9fce3 |
| children |
comparison
equal
deleted
inserted
replaced
| 775:28d8b892fd06 | 776:94033091458b |
|---|---|
| 106 width, | 106 width, |
| 107 height, | 107 height, |
| 108 })) | 108 })) |
| 109 } | 109 } |
| 110 | 110 |
| 111 macro_rules! gen_match { | |
| 112 ($arg_type:ident) => { | |
| 113 ${concat(le_, $arg_type)} | |
| 114 }; | |
| 115 } | |
| 116 | |
| 111 macro_rules! declare_anm_instructions { | 117 macro_rules! declare_anm_instructions { |
| 112 ($($opcode:tt => fn $name:ident($($arg:ident: $arg_type:ident),*)),*,) => { | 118 ($($opcode:tt => fn $name:ident($($arg:ident: $arg_type:ident),*)),*,) => { |
| 113 /// Available instructions in an `Anm0`. | 119 /// Available instructions in an `Anm0`. |
| 114 #[allow(missing_docs)] | 120 #[allow(missing_docs)] |
| 115 #[derive(Debug, Clone, Copy)] | 121 #[derive(Debug, Clone, Copy)] |
| 122 fn parse_instruction_args(mut i: &[u8], opcode: u8) -> IResult<&[u8], Instruction> { | 128 fn parse_instruction_args(mut i: &[u8], opcode: u8) -> IResult<&[u8], Instruction> { |
| 123 let instr = match opcode { | 129 let instr = match opcode { |
| 124 $( | 130 $( |
| 125 $opcode => { | 131 $opcode => { |
| 126 $( | 132 $( |
| 127 let (i2, $arg) = concat_idents!(le_, $arg_type)(i)?; | 133 let (i2, $arg) = gen_match!($arg_type)(i)?; |
| 128 i = i2; | 134 i = i2; |
| 129 )* | 135 )* |
| 130 Instruction::$name($($arg),*) | 136 Instruction::$name($($arg),*) |
| 131 } | 137 } |
| 132 )* | 138 )* |
