Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to add additional imports? #174

Open
Vithanco opened this issue Jan 21, 2025 · 2 comments
Open

How to add additional imports? #174

Vithanco opened this issue Jan 21, 2025 · 2 comments

Comments

@Vithanco
Copy link

Vithanco commented Jan 21, 2025

I think I miss an introduction. I have a non-standard import in an emscripten created WASM

(import "env" "__syscall_faccessat" (func $env.__syscall_faccessat (type $t7)))
with t7 being
(type $t7 (func (param i32 i32 i32 i32) (result i32)))

How would I add an implementation for this to my setup?

let wasi = try WASIBridgeToHost()
let engine = Engine()
let store = Store(engine: engine)
var imports = Imports()
//add the missing import here
wasi.link(to: &imports, store: store)
let instance = try module.instantiate(store: store, imports: imports) 

Relevant types seem to have only private init functions.

@kateinoigakukun
Copy link
Member

You can use Imports.define

@Vithanco
Copy link
Author

Vithanco commented Jan 22, 2025

That seem to work. Thank you!!!!
is there anywhere an example of how to transfer a string from Swift to WASM (and back)?
All examples only use numbers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants