-
Notifications
You must be signed in to change notification settings - Fork 103
/
Copy pathABI.swift
88 lines (77 loc) · 2.64 KB
/
ABI.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2024–2025 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for Swift project authors
//
/// A namespace for ABI symbols.
@_spi(ForToolsIntegrationOnly)
public enum ABI: Sendable {}
// MARK: - ABI version abstraction
extension ABI {
/// A protocol describing the types that represent different ABI versions.
protocol Version: Sendable {
/// The numeric representation of this ABI version.
static var versionNumber: Int { get }
/// Create an event handler that encodes events as JSON and forwards them to
/// an ABI-friendly event handler.
///
/// - Parameters:
/// - encodeAsJSONLines: Whether or not to ensure JSON passed to
/// `eventHandler` is encoded as JSON Lines (i.e. that it does not
/// contain extra newlines.)
/// - eventHandler: The event handler to forward events to.
///
/// - Returns: An event handler.
///
/// The resulting event handler outputs data as JSON. For each event handled
/// by the resulting event handler, a JSON object representing it and its
/// associated context is created and is passed to `eventHandler`.
static func eventHandler(
encodeAsJSONLines: Bool,
forwardingTo eventHandler: @escaping @Sendable (_ recordJSON: UnsafeRawBufferPointer) -> Void
) -> Event.Handler
}
/// The current supported ABI version (ignoring any experimental versions.)
typealias CurrentVersion = v0
}
// MARK: - Concrete ABI versions
extension ABI {
#if !SWT_NO_SNAPSHOT_TYPES
#if SWT_NO_FOUNDATION || !canImport(Foundation)
#error("Platform-specific misconfiguration: Foundation is required for snapshot type support")
#endif
/// A namespace and version type for Xcode 16 compatibility.
///
/// - Warning: This type will be removed in a future update.
enum Xcode16: Sendable, Version {
static var versionNumber: Int {
-1
}
}
#endif
/// A namespace and type for ABI version 0 symbols.
public enum v0: Sendable, Version {
static var versionNumber: Int {
0
}
}
/// A namespace and type for ABI version 1 symbols.
///
/// @Metadata {
/// @Available("Swift Testing ABI", introduced: 1)
/// }
@_spi(Experimental)
public enum v1: Sendable, Version {
static var versionNumber: Int {
1
}
}
}
/// A namespace for ABI version 0 symbols.
@_spi(ForToolsIntegrationOnly)
@available(*, deprecated, renamed: "ABI.v0")
public typealias ABIv0 = ABI.v0