forked from swiftwasm/JavaScriptKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGlobalGetter.swift
More file actions
41 lines (38 loc) · 1.45 KB
/
Copy pathGlobalGetter.swift
File metadata and controls
41 lines (38 loc) · 1.45 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
#if arch(wasm32)
@_extern(wasm, module: "TestModule", name: "bjs_console_get")
fileprivate func bjs_console_get_extern() -> Int32
#else
fileprivate func bjs_console_get_extern() -> Int32 {
fatalError("Only available on WebAssembly")
}
#endif
@inline(never) fileprivate func bjs_console_get() -> Int32 {
return bjs_console_get_extern()
}
func _$console_get() throws(JSException) -> JSConsole {
let ret = bjs_console_get()
if let error = _swift_js_take_exception() {
throw error
}
return JSConsole.bridgeJSLiftReturn(ret)
}
#if arch(wasm32)
@_extern(wasm, module: "TestModule", name: "bjs_JSConsole_log")
fileprivate func bjs_JSConsole_log_extern(_ self: Int32, _ messageBytes: Int32, _ messageLength: Int32) -> Void
#else
fileprivate func bjs_JSConsole_log_extern(_ self: Int32, _ messageBytes: Int32, _ messageLength: Int32) -> Void {
fatalError("Only available on WebAssembly")
}
#endif
@inline(never) fileprivate func bjs_JSConsole_log(_ self: Int32, _ messageBytes: Int32, _ messageLength: Int32) -> Void {
return bjs_JSConsole_log_extern(self, messageBytes, messageLength)
}
func _$JSConsole_log(_ self: JSObject, _ message: String) throws(JSException) -> Void {
let selfValue = self.bridgeJSLowerParameter()
_swift_js_with_borrowed_utf8(message) { messageBytes, messageLength in
bjs_JSConsole_log(selfValue, messageBytes, messageLength)
}
if let error = _swift_js_take_exception() {
throw error
}
}