@@ -47,13 +47,10 @@ extension ABIv0 {
47
47
/// callback.
48
48
public static var entryPoint : EntryPoint {
49
49
return { configurationJSON, recordHandler in
50
- let args = try configurationJSON. map { configurationJSON in
51
- try JSON . decode ( __CommandLineArguments_v0. self, from: configurationJSON)
52
- }
53
-
54
- let eventHandler = try eventHandlerForStreamingEvents ( version: args? . eventStreamVersion, forwardingTo: recordHandler)
55
- let exitCode = await Testing . entryPoint ( passing: args, eventHandler: eventHandler)
56
- return exitCode == EXIT_SUCCESS
50
+ try await Testing . entryPoint (
51
+ configurationJSON: configurationJSON,
52
+ recordHandler: recordHandler
53
+ ) == EXIT_SUCCESS
57
54
}
58
55
}
59
56
}
@@ -88,7 +85,39 @@ typealias ABIEntryPoint_v0 = @Sendable (
88
85
@_cdecl ( " swt_copyABIEntryPoint_v0 " )
89
86
@usableFromInline func copyABIEntryPoint_v0( ) -> UnsafeMutableRawPointer {
90
87
let result = UnsafeMutablePointer< ABIEntryPoint_v0> . allocate( capacity: 1 )
91
- result. initialize { try await ABIv0 . entryPoint ( $0, $1) ? EXIT_SUCCESS : EXIT_FAILURE }
88
+ result. initialize { configurationJSON, recordHandler in
89
+ try await entryPoint (
90
+ configurationJSON: configurationJSON,
91
+ eventStreamVersionIfNil: - 1 ,
92
+ recordHandler: recordHandler
93
+ )
94
+ }
92
95
return . init( result)
93
96
}
97
+
98
+ /// A common implementation for ``ABIv0/entryPoint-swift.type.property`` and
99
+ /// ``copyABIEntryPoint_v0()`` that provides Xcode 16 Beta 1 compatibility.
100
+ ///
101
+ /// This function will be removed (with its logic incorporated into
102
+ /// ``ABIv0/entryPoint-swift.type.property``) in a future update.
103
+ private func entryPoint(
104
+ configurationJSON: UnsafeRawBufferPointer ? ,
105
+ eventStreamVersionIfNil: Int ? = nil ,
106
+ recordHandler: @escaping @Sendable ( _ recordJSON: UnsafeRawBufferPointer ) -> Void
107
+ ) async throws -> CInt {
108
+ var args = try configurationJSON. map { configurationJSON in
109
+ try JSON . decode ( __CommandLineArguments_v0. self, from: configurationJSON)
110
+ }
111
+
112
+ // If the caller needs a nil event stream version to default to a specific
113
+ // JSON schema, apply it here as if they'd specified it in the configuration
114
+ // JSON blob.
115
+ if let eventStreamVersionIfNil, args? . eventStreamVersion == nil {
116
+ args? . eventStreamVersion = eventStreamVersionIfNil
117
+ }
118
+
119
+ let eventHandler = try eventHandlerForStreamingEvents ( version: args? . eventStreamVersion, forwardingTo: recordHandler)
120
+ let exitCode = await entryPoint ( passing: args, eventHandler: eventHandler)
121
+ return exitCode
122
+ }
94
123
#endif
0 commit comments