forked from swiftwasm/JavaScriptKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNamespaces.swift
More file actions
50 lines (38 loc) · 978 Bytes
/
Namespaces.swift
File metadata and controls
50 lines (38 loc) · 978 Bytes
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
@JS func plainFunction() -> String { "plain" }
@JS(namespace: "MyModule.Utils") func namespacedFunction() -> String { "namespaced" }
@JS(namespace: "__Swift.Foundation") class Greeter {
var name: String
@JS init(name: String) {
self.name = name
}
@JS func greet() -> String {
return "Hello, " + self.name + "!"
}
func changeName(name: String) {
self.name = name
}
}
@JS(namespace: "Utils.Converters") class Converter {
@JS init() {}
@JS func toString(value: Int) -> String {
return String(value)
}
}
@JS(namespace: "__Swift.Foundation")
class UUID {
@JS func uuidString() -> String {
Foundation.UUID().uuidString
}
}
@JS(namespace: "Collections") class Container {
var items: [Greeter]
@JS init() {
self.items = []
}
@JS func getItems() -> [Greeter] {
return items
}
@JS func addItem(_ item: Greeter) {
items.append(item)
}
}