File tree Expand file tree Collapse file tree 2 files changed +8
-3
lines changed
Sources/BinaryParsingMacros
Tests/BinaryParsingMacrosTests Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -51,9 +51,14 @@ public struct MagicNumberStringMacro: ExpressionMacro {
5151 return " "
5252 }
5353
54+ var parsingExpr = " input "
55+ if let parsingArg = node. arguments. first ( where: { $0. label? . text == " parsing " } ) {
56+ parsingExpr = parsingArg. expression. description
57+ }
58+
5459 return """
5560 _loadAndCheckDirectBytes( \
56- parsing: &input , \
61+ parsing: \( raw : parsingExpr ) , \
5762 bigEndianValue: 0x \( raw: String ( integerValue, radix: 16 ) ) as \( raw: integerType) )
5863 """
5964 }
Original file line number Diff line number Diff line change @@ -20,9 +20,9 @@ struct StringifyMacroSwiftTestingTests {
2020 @Test
2121 func magicNumberString( ) {
2222 assertMacro {
23- #"try #magicNumber("qoif", parsing: &input )"#
23+ #"try #magicNumber("qoif", parsing: &data )"#
2424 } expansion: {
25- " try _loadAndCheckDirectBytes(parsing: &input , bigEndianValue: 0x716f6966 as UInt32) "
25+ " try _loadAndCheckDirectBytes(parsing: &data , bigEndianValue: 0x716f6966 as UInt32) "
2626 }
2727 }
2828}
You can’t perform that action at this time.
0 commit comments