File tree Expand file tree Collapse file tree 6 files changed +119
-28
lines changed
AppStructure/AppOrganization Expand file tree Collapse file tree 6 files changed +119
-28
lines changed Original file line number Diff line number Diff line change
1
+ //
2
+ // AppGraph.swift
3
+ // OpenSwiftUI
4
+ //
5
+ // Created by Kyle on 2023/9/22.
6
+ // Lastest Version: iOS 15.5
7
+ // Status: WIP
8
+ // ID: A363922CEBDF47986D9772B903C8737A
9
+
10
+ #if canImport(Darwin)
11
+ import Darwin
12
+ #elseif canImport(Glibc)
13
+ import Glibc
14
+ #elseif os(WASI)
15
+ import WASILibc
16
+ #endif
17
+
18
+ final class AppGraph : GraphHost {
19
+ static var shared : AppGraph ? = nil
20
+ static var delegateBox : AnyFallbackDelegateBox ? = nil
21
+
22
+ private struct LaunchProfileOptions : OptionSet {
23
+ let rawValue : Int32
24
+
25
+ static var enable : LaunchProfileOptions { . init( rawValue: 1 << 1 ) }
26
+ }
27
+
28
+ private lazy var launchProfileOptions : LaunchProfileOptions = {
29
+ let env = getenv ( " SWIFTUI_PROFILE_LAUNCH " )
30
+ if let env {
31
+ return . init( rawValue: atoi ( env) )
32
+ } else {
33
+ return [ ]
34
+ }
35
+ } ( )
36
+
37
+ var didCollectLaunchProfile : Bool = false
38
+
39
+ init ( app _: some App ) { }
40
+
41
+ func extendedLaunchTestName( ) -> String ? { nil }
42
+
43
+ func startProfilingIfNecessary( ) {
44
+ guard !didCollectLaunchProfile else {
45
+ return
46
+ }
47
+
48
+ if launchProfileOptions. contains ( . enable) {
49
+ // AGGraphStartProfiling
50
+ }
51
+ }
52
+
53
+ func stopProfilingIfNecessary( ) {
54
+ guard !didCollectLaunchProfile else {
55
+ return
56
+ }
57
+ didCollectLaunchProfile = true
58
+
59
+ if launchProfileOptions. contains ( . enable) {
60
+ // AGGraphStopProfiling
61
+ }
62
+
63
+ if launchProfileOptions. rawValue != 0 {
64
+ // AGGraphArchiveJSON
65
+ }
66
+ }
67
+ }
Original file line number Diff line number Diff line change
1
+ //
2
+ // FinishLaunchTestAction.swift
3
+ // OpenSwiftUI
4
+ //
5
+ // Created by Kyle on 2024/2/25.
6
+ // Lastest Version: iOS 15.5
7
+ // Status: Complete
8
+
9
+ #if os(iOS)
10
+ import UIKit
11
+ #elseif os(macOS)
12
+ import AppKit
13
+ #endif
14
+
15
+ struct FinishLaunchTestAction {
16
+ func callAsFunction( ) {
17
+ AppGraph . shared? . stopProfilingIfNecessary ( )
18
+ #if os(iOS)
19
+ UIApplication . shared. finishedTest ( UIApplication . shared. _launchTestName ( ) )
20
+ #else
21
+ fatalError ( " Unimplemented for other platform " )
22
+ #endif
23
+ }
24
+ }
25
+
26
+ extension EnvironmentValues {
27
+ var finishLaunchTest : FinishLaunchTestAction {
28
+ FinishLaunchTestAction ( )
29
+ }
30
+ }
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 6
6
// Lastest Version: iOS 15.5
7
7
// Status: WIP
8
8
9
- #if canImport(Darwin)
10
9
import Foundation
11
10
#if OPENSWIFTUI_OPENCOMBINE
12
11
import OpenCombine
@@ -39,6 +38,10 @@ class FallbackDelegateBox<Delegate: NSObject>: AnyFallbackDelegateBox {
39
38
}
40
39
41
40
override var delegate : NSObject ? {
41
+ // FIXME: error: constructing an object of class type 'Delegate' with a metatype value must use a 'required' initializer
42
+ #if !canImport(Darwin)
43
+ return nil
44
+ #else
42
45
switch storage {
43
46
case let . type( type) :
44
47
let delegate = type. init ( )
@@ -47,6 +50,6 @@ class FallbackDelegateBox<Delegate: NSObject>: AnyFallbackDelegateBox {
47
50
case let . instance( delegate) :
48
51
return delegate
49
52
}
53
+ #endif
50
54
}
51
55
}
52
- #endif
Original file line number Diff line number Diff line change @@ -35,24 +35,30 @@ extension _BenchmarkHost {
35
35
public func _started( test: _PerformanceTest ) {
36
36
#if os(iOS)
37
37
UIApplication . shared. startedTest ( test. name)
38
+ #elseif os(macOS)
39
+ NSApplication . shared. startedTest ( test. name)
38
40
#else
39
- fatalError ( " TODO " )
41
+ fatalError ( " Unimplemented for other platform " )
40
42
#endif
41
43
}
42
44
43
45
public func _finished( test: _PerformanceTest ) {
44
46
#if os(iOS)
45
47
UIApplication . shared. finishedTest ( test. name)
48
+ #elseif os(macOS)
49
+ NSApplication . shared. finishedTest ( test. name)
46
50
#else
47
- fatalError ( " TODO " )
51
+ fatalError ( " Unimplemented for other platform " )
48
52
#endif
49
53
}
50
54
51
55
public func _failed( test: _PerformanceTest ) {
52
56
#if os(iOS)
53
57
UIApplication . shared. failedTest ( test. name, withFailure: nil )
58
+ #elseif os(macOS)
59
+ NSApplication . shared. failedTest ( test. name, withFailure: nil )
54
60
#else
55
- fatalError ( " TODO " )
61
+ fatalError ( " Unimplemented for other platform " )
56
62
#endif
57
63
}
58
64
}
Original file line number Diff line number Diff line change 14
14
- (void )startedTest : (nullable NSString *)name ;
15
15
- (void )finishedTest : (nullable NSString *)name ;
16
16
- (void )failedTest : (nullable NSString *)name withFailure : (nullable NSError *)failure ;
17
+ - (nullable NSString *)_launchTestName ;
18
+ @end
19
+ #elif __has_include(<AppKit/AppKit.h>)
20
+ #import < AppKit/AppKit.h>
21
+ @interface NSApplication (OpenSwiftUI_SPI)
22
+ - (void )startedTest : (nullable NSString *)name ;
23
+ - (void )finishedTest : (nullable NSString *)name ;
24
+ - (void )failedTest : (nullable NSString *)name withFailure : (nullable NSError *)failure ;
17
25
@end
18
- #else
19
-
20
26
#endif
21
27
22
28
#endif /* OpenSwiftUI_SPI_h */
You can’t perform that action at this time.
0 commit comments