-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathWinRTInterfaceImplementations.swift
106 lines (83 loc) · 2.36 KB
/
WinRTInterfaceImplementations.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import Foundation
import test_component
import WinSDK
class DoubleDelegate : IBasic, ISimpleDelegate {
func method() {
print("method doubled up")
}
func doThis() {
print("Swift Double! - doThis!")
}
func doThat(_ val: Int32) {
print("Swift Double! - Do that: ", val)
}
}
class MySimpleDelegate : ISimpleDelegate {
private var thisCount: Int32 = 0
private var that: Int32 = 0
func doThis()
{
print("Swift - doThis!")
thisCount += 1
}
func doThat(_ val: Int32)
{
print("Swift - Do that: ", val)
that = val
}
func getThisCount() -> Int32 { thisCount }
func getThat() -> Int32 { that }
}
class MyImplementableDelegate: IIAmImplementable {
private var thisCount = 9
func inInt32(_ value: Int32) -> String {
return .init(repeating: "abc", count: Int(value))
}
func inString(_ value: String) -> String {
return .init(value.reversed())
}
func inEnum(_ value: Signed) -> String {
switch value {
case .first: return "1 banana"
case .second: return "2 banana"
case .third: return "3 banana"
default: return "n/a"
}
}
func outInt32(_ value: inout Int32) {
value = 987
}
func outString(_ value: inout String) {
value = "987"
}
func outBlittableStruct(_ value: inout BlittableStruct) {
value = .init(first: 9876, second: 54321)
}
func outNonBlittableStruct(_ value: inout NonBlittableStruct) {
value = .init(first: "to be", second: "or not", third: 2, fourth: "be, that is the question")
}
func outEnum(_ value: inout Signed) {
value = .second
}
func returnEnum() -> Signed {
.third
}
var enumProperty: Fruit = .apple
var id: Foundation.UUID?
func fireEvent(_ data: String) {
try! _implementableEvent.invoke(data)
}
private var object: Any?
func inObject(_ value: Any!) throws -> String {
object = value
guard let value else { return "nil" }
return String(describing: value)
}
func outObject(_ value: inout Any!) throws {
value = object
}
func returnObject() throws -> Any! {
return object
}
@EventSource<InDelegate> var implementableEvent: Event<InDelegate>
}