forked from swiftwasm/JavaScriptKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOptionals.swift
More file actions
171 lines (136 loc) · 4.85 KB
/
Copy pathOptionals.swift
File metadata and controls
171 lines (136 loc) · 4.85 KB
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
@JS class Greeter {
@JS var name: String?
@JS init(name: String?) {
self.name = name
}
@JS func greet() -> String {
return "Hello, " + (self.name ?? "stranger") + "!"
}
@JS func changeName(name: String?) {
self.name = name
}
}
@JS
func roundTripOptionalClass(value: Greeter?) -> Greeter? {
return value
}
@JS
class OptionalPropertyHolder {
@JS var optionalName: String? = nil
@JS var optionalAge: Int? = nil
@JS var optionalGreeter: Greeter? = nil
@JS init() {}
}
@JS func testOptionalPropertyRoundtrip(_ holder: OptionalPropertyHolder?) -> OptionalPropertyHolder?
// Exported functions taking an optional jsObject use the direct (isSome, objId)
// parameter ABI; the return value travels through the stack ABI.
@JS func roundTripExportedOptionalJSObject(value: JSObject?) -> JSObject?
// Exported function taking/returning an optional imported @JSClass (issue #751).
@JS func roundTripExportedOptionalJSClass(value: WithOptionalJSClass?) -> WithOptionalJSClass?
@JS
func roundTripString(name: String?) -> String? {
return name
}
@JS
func roundTripInt(value: Int?) -> Int? {
return value
}
@JS
func roundTripInt8(value: Int8?) -> Int8? {
return value
}
@JS
func roundTripUInt8(value: UInt8?) -> UInt8? {
return value
}
@JS
func roundTripInt16(value: Int16?) -> Int16? {
return value
}
@JS
func roundTripUInt16(value: UInt16?) -> UInt16? {
return value
}
@JS
func roundTripInt32(value: Int32?) -> Int32? {
return value
}
@JS
func roundTripUInt32(value: UInt32?) -> UInt32? {
return value
}
@JS
func roundTripBool(flag: Bool?) -> Bool? {
return flag
}
@JS
func roundTripFloat(number: Float?) -> Float? {
return number
}
@JS
func roundTripDouble(precision: Double?) -> Double? {
return precision
}
@JS func roundTripSyntax(name: Optional<String>) -> Optional<String> {
return name
}
@JS func roundTripMixSyntax(name: String?) -> Optional<String> {
return name
}
@JS func roundTripSwiftSyntax(name: Swift.Optional<String>) -> Swift.Optional<String> {
return name
}
@JS func roundTripMixedSwiftSyntax(name: String?) -> Swift.Optional<String> {
return name
}
@JS func roundTripWithSpaces(value: Optional<Double>) -> Optional<Double> {
return value
}
typealias OptionalAge = Int?
@JS func roundTripAlias(age: OptionalAge) -> OptionalAge {
return age
}
typealias OptionalNameAlias = Optional<String>
@JS func roundTripOptionalAlias(name: OptionalNameAlias) -> OptionalNameAlias {
return name
}
@JS
func testMixedOptionals(firstName: String?, lastName: String?, age: Int?, active: Bool) -> String? {
return nil
}
@JSClass struct WithOptionalJSClass {
@JSFunction init(valueOrNull: String?, valueOrUndefined: JSUndefinedOr<String>) throws(JSException)
@JSGetter var stringOrNull: String?
@JSSetter func setStringOrNull(_ value: String?) throws(JSException)
@JSGetter var stringOrUndefined: JSUndefinedOr<String>
@JSSetter func setStringOrUndefined(_ value: JSUndefinedOr<String>) throws(JSException)
@JSFunction func roundTripStringOrNull(value: String?) throws(JSException) -> String?
@JSFunction func roundTripStringOrUndefined(
value: JSUndefinedOr<String>
) throws(JSException) -> JSUndefinedOr<String>
@JSGetter var doubleOrNull: Double?
@JSSetter func setDoubleOrNull(_ value: Double?) throws(JSException)
@JSGetter var doubleOrUndefined: JSUndefinedOr<Double>
@JSSetter func setDoubleOrUndefined(_ value: JSUndefinedOr<Double>) throws(JSException)
@JSFunction func roundTripDoubleOrNull(value: Double?) throws(JSException) -> Double?
@JSFunction func roundTripDoubleOrUndefined(
value: JSUndefinedOr<Double>
) throws(JSException) -> JSUndefinedOr<Double>
@JSGetter var boolOrNull: Bool?
@JSSetter func setBoolOrNull(_ value: Bool?) throws(JSException)
@JSGetter var boolOrUndefined: JSUndefinedOr<Bool>
@JSSetter func setBoolOrUndefined(_ value: JSUndefinedOr<Bool>) throws(JSException)
@JSFunction func roundTripBoolOrNull(value: Bool?) throws(JSException) -> Bool?
@JSFunction func roundTripBoolOrUndefined(value: JSUndefinedOr<Bool>) throws(JSException) -> JSUndefinedOr<Bool>
@JSGetter var intOrNull: Int?
@JSSetter func setIntOrNull(_ value: Int?) throws(JSException)
@JSGetter var intOrUndefined: JSUndefinedOr<Int>
@JSSetter func setIntOrUndefined(_ value: JSUndefinedOr<Int>) throws(JSException)
@JSFunction func roundTripIntOrNull(value: Int?) throws(JSException) -> Int?
@JSFunction func roundTripIntOrUndefined(value: JSUndefinedOr<Int>) throws(JSException) -> JSUndefinedOr<Int>
@JSGetter var childOrNull: WithOptionalJSClass?
@JSSetter func setChildOrNull(_ value: WithOptionalJSClass?) throws(JSException)
@JSFunction func roundTripChildOrNull(
value: WithOptionalJSClass?
) throws(JSException) -> WithOptionalJSClass?
}