Rerumu / Wasynth

WebAssembly to Lua translation library and tool
https://discord.gg/sgm5YcmgyD
GNU General Public License v3.0
130 stars 18 forks source link

Is there an example of this #20

Closed leiserfg closed 1 year ago

leiserfg commented 2 years ago

I'm interested in using this as a way to ship a C library into a nvim plugin. Is there an example project so I can pick up quickly on how to use it?

Rerumu commented 2 years ago

There are no examples yet sadly. It should be enough however to run the wasm2luajit tool on the WebAssembly file of your choice to translate it.

From there, it'll produce a module returning a sort of init function. Call that function with any host functions that your C code expects your Lua to implement (if any), and it will return a table with the module parts. Then, you should be able to call the C functions from the func_list directly.

Rerumu commented 1 year ago

While we currently lack a specific C example (I will get to it eventually), the new Rust one explains some universal concepts. https://github.com/Rerumu/Wasynth/wiki/From-Rust,-to-Lua

It sounds here like you want to specifically use a C library, in which case you'd just interface with the exports from the Lua end like I mentioned previously.