Skip to content

Commit 2770ac2

Browse files
fixed ByteBuffer initialization
1 parent 9415f36 commit 2770ac2

File tree

2 files changed

+8
-15
lines changed

2 files changed

+8
-15
lines changed

Sources/HTMLKitMacros/HTMLElement.swift

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,21 +73,14 @@ struct HTMLElement : ExpressionMacro {
7373
#endif
7474

7575
#if canImport(NIOCore)
76-
case .byteBuffer: return "ByteBuffer(string: \(raw: string))"
76+
case .byteBuffer: return "ByteBuffer(string: \"\(raw: string)\")"
7777
#endif
7878

7979
default: return "\"\(raw: string)\""
8080
}
8181
}
8282
}
8383

84-
extension HTMLDataRepresentation {
85-
enum Result {
86-
case string(String)
87-
case uint8Array([UInt8])
88-
}
89-
}
90-
9184
private extension HTMLElement {
9285
static func parse_macro(context: some MacroExpansionContext, expression: MacroExpansionExprSyntax) -> String {
9386
guard let elementType:HTMLElementType = HTMLElementType(rawValue: expression.macroName.text) else { return "\(expression)" }

Tests/HTMLKitTests/HTMLKitTests.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ struct HTMLKitTests {
4343
}
4444

4545
extension HTMLKitTests {
46-
func representation1() {
46+
func representations() {
4747
let _:StaticString = #html(representation: .string)
4848
let _:String = #html(representation: .string)
4949
let _:[UInt8] = #html(representation: .uint8Array)
@@ -52,25 +52,25 @@ extension HTMLKitTests {
5252
let _:Data = #html(representation: .data)
5353
#endif
5454
#if canImport(NIOCore)
55-
let _:[ByteBuffer] = #html(representation: .byteBuffer)
55+
let _:ByteBuffer = #html(representation: .byteBuffer)
5656
#endif
5757
}
58-
func representation2() -> StaticString {
58+
func representation1() -> StaticString {
5959
#html()
6060
}
61-
func representation3() -> String {
61+
func representation2() -> String {
6262
#html()
6363
}
64-
func representation4() -> [UInt8] {
64+
func representation3() -> [UInt8] {
6565
#html()
6666
}
6767
#if canImport(Foundation)
68-
func representation5() -> Data {
68+
func representation4() -> Data {
6969
#html()
7070
}
7171
#endif
7272
#if canImport(NIOCore)
73-
func representation6() -> ByteBuffer {
73+
func representation5() -> ByteBuffer {
7474
#html()
7575
}
7676
#endif

0 commit comments

Comments
 (0)