Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

BridgeJS: Support @JS struct on return type of async exported @JS func #753

Copy link
Copy link
@kateinoigakukun

Description

@kateinoigakukun
Issue body actions

https://swiftwasm.org/JavaScriptKit/PlayBridgeJS/?code=H4sIAAAAAAAAE6tWKi7PTCtRslJy8ApWKC4pKk0uUXDLz1eoro3JAwmlleYlK6Snlrjl52toKiQWV%2BYlK%2BjaQZUo6SillBQrWSkp1QIAGbFRnEkAAAA%3D&enc=gzip-b64

Input:

@JS struct Foo {}
@JS func getFoo() async -> Foo {}

Expected Output:

@JSFunction func Promise_resolve_<mangled Foo>(_ promise: JSObject, _ value: Foo) throws(JSException)
@JSFunction func Promise_reject(_ promise: JSObject, _ value: JSValue) throws(JSException)

@_expose(wasm, "bjs_getFoo")
@_cdecl("bjs_getFoo")
public func _bjs_getFoo() -> Int32 {
    #if arch(wasm32)
    return _bjs_makePromise(resolve: Promise_resolve_<mangled Foo> reject: Promise_reject) {
        return await getFoo()
    }
    #else
    fatalError("Only available on WebAssembly")
    #endif
}

Actual Output:

@_expose(wasm, "bjs_getFoo")
@_cdecl("bjs_getFoo")
public func _bjs_getFoo() -> Int32 {
    #if arch(wasm32)
    let ret = JSPromise.async {
        return await getFoo().jsValue
    }.jsObject
    return ret.bridgeJSLowerReturn()
    #else
    fatalError("Only available on WebAssembly")
    #endif
}
Reactions are currently unavailable

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.