Skip to content

Commit c830a21

Browse files
committed
[JSON] Import for non-Darwin platforms
1 parent 39acd5a commit c830a21

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

Sources/SwiftCompilerPluginMessageHandling/JSON/CodingUtilities.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13+
// Copied from swift-foundation
14+
1315
//===----------------------------------------------------------------------===//
1416
// Coding Path Node
1517
//===----------------------------------------------------------------------===//

Sources/SwiftCompilerPluginMessageHandling/JSON/JSONDecoding.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,24 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13+
#if swift(>=6.0)
14+
#if canImport(Darwin)
15+
private import Darwin
16+
#elseif canImport(Glibc)
17+
private import Glibc
18+
#elseif canImport(ucrt)
19+
private import ucrt
20+
#endif
21+
#else
22+
#if canImport(Darwin)
1323
import Darwin
24+
#elseif canImport(Glibc)
25+
import Glibc
26+
#elseif canImport(ucrt)
27+
import ucrt
28+
#endif
29+
#endif
30+
1431

1532
func decodeFromJSON<T: Decodable>(json: UnsafeBufferPointer<UInt8>) throws -> T {
1633
try withExtendedLifetime(try JSONScanner.scan(buffer: json)) { map in

0 commit comments

Comments
 (0)